[Validator] StaticMethodLoader invokes wrong method #3179
Closed
Description
interface FooInterface {
public static function loadValidatorMetadata($metadata);
}
class Bar implements FooInterface {
private $baz = 'bogus';
public static function loadValidatorMetadata($metadata) {
$metadata->addPropertyConstraint('baz', new Assert\MinLength(10));
}
}
$validator = new Validator(
new ClassMetadataFactory(new StaticMethodLoader()),
new ConstraintValidatorFactory()
);
$violations = $validator->validate(new Bar);
if ($violations->count()) {
throw new \Exception($violations);
}
I have classes that needs to be validated with Symfony\Component\Validator
and this classes uses StaticMethodLoader
strategy for validation. I declared loadValidatorMetadata
method in interface but StaticMethodLoader
invokes wrong method and following error occures.
Fatal error: Uncaught exception 'ReflectionException' with message 'Trying to invoke abstract method FooInterface::loadValidatorMetadata()' in Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php on line 44
ReflectionException: Trying to invoke abstract method Heatbeat\FooInterface::loadValidatorMetadata() in /Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php on line 44
Looks like there is a problem with Reflection.