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';
}
When using the
ForGroupstarget for a serialization group that is defined for a method not linked to a specific property, such as: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:
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.