Permalink
Browse files

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
  • Loading branch information...
2 parents 098b934 + 089188f commit 0078faa84b90e194221871c8adf27e48e20f8653 @fabpot fabpot committed Apr 14, 2012
@@ -37,7 +37,7 @@ public function loadClassMetadata(ClassMetadata $metadata)
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 @@ public function testLoadClassMetadataReturnsFalseIfNotSuccessful()
$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 @@ static public function loadMetadata(ClassMetadata $metadata)
$metadata->addConstraint(new ConstraintA());
}
}
+
+abstract class AbstractStaticLoaderEntity
+{
+ abstract public static function loadMetadata(ClassMetadata $metadata);
+}

0 comments on commit 0078faa

Please sign in to comment.