I would like to call some functions in my PHP 8 attributes use cases, to clean my classes.
But I don't know how to do it and I don't find any documentation about that. This is a sample example of what I would like to do :
Imagine, we have this :
#[Assert\GreaterThanOrEqual(propertyPath: 'beginDate', message: 'No sorry, impossible')]
private ?DateTimeInterface $endDate = null;
And I would like to get the 'message' value from a function, or an another class. So, by example :
#[Assert\GreaterThanOrEqual(propertyPath: 'beginDate', message: $this->myMessage())]
private ?DateTimeInterface $endDate = null;
private function myMessage(): string
{
return 'No sorry, impossible';
}
I'll have an error : Constant expression contains invalid operations
Is it really possible to do this ?