Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to ignore method when resolving subscriptions #74

Open
Brajk19 opened this issue Oct 30, 2024 · 0 comments
Open

Add option to ignore method when resolving subscriptions #74

Brajk19 opened this issue Oct 30, 2024 · 0 comments

Comments

@Brajk19
Copy link
Member

Brajk19 commented Oct 30, 2024

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';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant