[Validator] Fixed: StaticMethodLoader does not try to invoke methods of interfaces anymore

This commit is contained in:
Bernhard Schussek 2012-07-26 16:25:38 +02:00
parent 24e3e2a1cd
commit 9f4178b672
2 changed files with 17 additions and 1 deletions

View File

@ -28,9 +28,10 @@ class StaticMethodLoader implements LoaderInterface
*/
public function loadClassMetadata(ClassMetadata $metadata)
{
/** @var \ReflectionClass $reflClass */
$reflClass = $metadata->getReflectionClass();
if ($reflClass->hasMethod($this->methodName)) {
if (!$reflClass->isInterface() && $reflClass->hasMethod($this->methodName)) {
$reflMethod = $reflClass->getMethod($this->methodName);
if (!$reflMethod->isStatic()) {

View File

@ -57,6 +57,21 @@ class StaticMethodLoaderTest extends \PHPUnit_Framework_TestCase
$loader->loadClassMetadata($metadata);
$this->assertSame(1, count($metadata->getConstraints()));
}
public function testLoadClassMetadataIgnoresInterfaces()
{
$loader = new StaticMethodLoader('loadMetadata');
$metadata = new ClassMetadata(__NAMESPACE__.'\StaticLoaderInterface');
$loader->loadClassMetadata($metadata);
$this->assertSame(0, count($metadata->getConstraints()));
}
}
interface StaticLoaderInterface
{
public static function loadMetadata(ClassMetadata $metadata);
}
class StaticLoaderEntity