[Validator] Fixed StaticMethodLoader when used with abstract methods.
This commit is contained in:
parent
098b934410
commit
089188f603
@ -37,7 +37,7 @@ class StaticMethodLoader implements LoaderInterface
|
|||||||
throw new MappingException(sprintf('The method %s::%s should be static', $reflClass->getName(), $this->methodName));
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,14 @@ class StaticMethodLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse($loader->loadClassMetadata($metadata));
|
$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()
|
public function testLoadClassMetadata()
|
||||||
{
|
{
|
||||||
$loader = new StaticMethodLoader('loadMetadata');
|
$loader = new StaticMethodLoader('loadMetadata');
|
||||||
@ -80,3 +88,8 @@ class BaseStaticLoaderDocument
|
|||||||
$metadata->addConstraint(new ConstraintA());
|
$metadata->addConstraint(new ConstraintA());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class AbstractStaticLoaderEntity
|
||||||
|
{
|
||||||
|
abstract public static function loadMetadata(ClassMetadata $metadata);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user