-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Hi!
I have discovered an error in the following class:
/var/www/vhosts/abc/vendor/php-translation/extractor/src/Visitor/Php/Symfony/ValidationAnnotation.php:112 Warning: Undefined array key "message"
#0 /var/www/vhosts/abc/vendor/php-translation/extractor/src/Visitor/Php/Symfony/ValidationAnnotation.php(91): Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation->extractFromConstraints()while using constructor promoted properties instead a class var for $message.
During debugging I found following behaviour:
The reflection class of
public function __construct($options = NULL, array $groups = NULL, $payload = NULL, public string $message = 'validatoren.adresse.ungueltig', public string $message_connection_error = 'validatoren.adresse.connection')
{
parent::__construct($options, $groups, $payload);
}does not provide message as default properties so they are missing while dumping
$ref = new \ReflectionClass($constraint);
$defaultValues = $ref->getDefaultProperties();If you declare $message the old school way as class var:
public string $message = 'validatoren.adresse.ungueltig';
public function __construct($options = NULL, array $groups = NULL, $payload = NULL, public string $message_connection_error = 'validatoren.adresse.connection')
{
parent::__construct($options, $groups, $payload);
}
the default properties of the reflection class does contains message as array key and there is no warning during extraction:
A discussion about this behaviour as an potential php bug you can find here: https://bugs.php.net/bug.php?id=81386&edit=1
Not using constructor promoted properties as an PHP8 feature is not a solution for this issue.
Metadata
Metadata
Assignees
Labels
No labels

