Created
March 1, 2013 13:53
-
-
Save docteurklein/5064805 to your computer and use it in GitHub Desktop.
failing test case for ReflectionMethod::getPrototype() when a class is using a trait that defines a method, chich class extends another class that defines the same method too.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait TestTrait | |
{ | |
public function getKernel() | |
{ | |
} | |
} | |
class BaseTest | |
{ | |
public function getKernel() | |
{ | |
} | |
} | |
class Test extends BaseTest | |
{ | |
use TestTrait; | |
} | |
$refl = new \ReflectionClass('Test'); | |
var_dump($refl->getMethod('getKernel')->getPrototype()); | |
var_dump($refl->getMethod('getKernel')->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()); |
PHP 5.5.5 (cli) (built: Oct 16 2013 05:59:03)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
<?php
class MyMethod extends \ReflectionMethod {
public function hasPrototype() {
try {
parent::getPrototype();
return true;
}
catch (\ReflectionException $e) {
return false;
}
}
public function getPrototype() {
return $this->hasPrototype() ? parent::getPrototype() : "Method {$this->getName()} does not have a prototype";
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://3v4l.org/M698X