merged branch bschussek/issue3179 (PR #5069)
Commits
-------
9f4178b
[Validator] Fixed: StaticMethodLoader does not try to invoke methods of interfaces anymore
Discussion
----------
[Validator] Fixed: StaticMethodLoader does not try to invoke methods of interfaces anymore
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3179
Todo: -
This commit is contained in:
commit
d92daec6e1
@ -28,9 +28,10 @@ class StaticMethodLoader implements LoaderInterface
|
|||||||
*/
|
*/
|
||||||
public function loadClassMetadata(ClassMetadata $metadata)
|
public function loadClassMetadata(ClassMetadata $metadata)
|
||||||
{
|
{
|
||||||
|
/** @var \ReflectionClass $reflClass */
|
||||||
$reflClass = $metadata->getReflectionClass();
|
$reflClass = $metadata->getReflectionClass();
|
||||||
|
|
||||||
if ($reflClass->hasMethod($this->methodName)) {
|
if (!$reflClass->isInterface() && $reflClass->hasMethod($this->methodName)) {
|
||||||
$reflMethod = $reflClass->getMethod($this->methodName);
|
$reflMethod = $reflClass->getMethod($this->methodName);
|
||||||
|
|
||||||
if (!$reflMethod->isStatic()) {
|
if (!$reflMethod->isStatic()) {
|
||||||
|
@ -57,6 +57,21 @@ class StaticMethodLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
$this->assertSame(1, count($metadata->getConstraints()));
|
$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
|
class StaticLoaderEntity
|
||||||
|
Reference in New Issue
Block a user