Skip to content

Add option to ignore method when resolving subscriptions #74

@Brajk19

Description

@Brajk19

When using the ForGroups target for a serialization group that is defined for a method not linked to a specific property, such as:

#[Groups('common')]
public function getType(): string
{
    return 'some string';
}

an error occurs during compilation. This happens because Purgatory is unable to resolve properties affected by this method.

In cases where a method accesses properties, this behavior is expected, and the #[TargetedProperties] attribute should be applied to indicate which properties are used by the method. However, even when a method returns data unrelated to any properties, the error is still triggered (which is not good).

One workaround is to use a placeholder #[TargetedProperties] attribute with an existing property for that serialization group, like so:

#[Groups('common')]
#[TargetedProperties('name')]
public function getType(): string
{
    return 'some string';
}

However, this is not ideal. I propose introducing a new attribute (#[DoesNotAccessProperties]?) to signal that the method does not interact with any properties and should therefore be exempt from this validation.

#[Groups('common')]
#[DoesNotAccessProperties]
public function getType(): string
{
    return 'some string';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions