merged branch jakzal/2.0-StaticMethodLoaderFix (PR #3937)
Commits
-------
089188f
[Validator] Fixed StaticMethodLoader when used with abstract methods.
Discussion
----------
[Validator] Fixed StaticMethodLoader when used with abstract methods.
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3179
This commit is contained in:
commit
0078faa84b
@ -37,7 +37,7 @@ class StaticMethodLoader implements LoaderInterface
|
||||
throw new MappingException(sprintf('The method %s::%s should be static', $reflClass->getName(), $this->methodName));
|
||||
}
|
||||
|
||||
if ($reflMethod->getDeclaringClass()->getName() != $reflClass->getName()) {
|
||||
if ($reflClass->isAbstract() || $reflMethod->getDeclaringClass()->getName() != $reflClass->getName()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,14 @@ class StaticMethodLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($loader->loadClassMetadata($metadata));
|
||||
}
|
||||
|
||||
public function testLoadClassMetadataReturnsFalseIfMethodIsAbstract()
|
||||
{
|
||||
$loader = new StaticMethodLoader('loadMetadata');
|
||||
$metadata = new ClassMetadata(__NAMESPACE__.'\AbstractStaticLoaderEntity');
|
||||
|
||||
$this->assertFalse($loader->loadClassMetadata($metadata));
|
||||
}
|
||||
|
||||
public function testLoadClassMetadata()
|
||||
{
|
||||
$loader = new StaticMethodLoader('loadMetadata');
|
||||
@ -80,3 +88,8 @@ class BaseStaticLoaderDocument
|
||||
$metadata->addConstraint(new ConstraintA());
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractStaticLoaderEntity
|
||||
{
|
||||
abstract public static function loadMetadata(ClassMetadata $metadata);
|
||||
}
|
||||
|
Reference in New Issue
Block a user