public function MagicCallPatch::apply in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/MagicCallPatch.php \Prophecy\Doubler\ClassPatch\MagicCallPatch::apply()
Discover Magical API
Parameters
ClassNode $node:
Overrides ClassPatchInterface::apply
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ ClassPatch/ MagicCallPatch.php, line 42
Class
- MagicCallPatch
- Discover Magical API using "@method" PHPDoc format.
Namespace
Prophecy\Doubler\ClassPatchCode
public function apply(ClassNode $node) {
$parentClass = $node
->getParentClass();
$reflectionClass = new \ReflectionClass($parentClass);
$phpdoc = new DocBlock($reflectionClass
->getDocComment());
$tagList = $phpdoc
->getTagsByName('method');
foreach ($tagList as $tag) {
$methodName = $tag
->getMethodName();
if (!$reflectionClass
->hasMethod($methodName)) {
$methodNode = new MethodNode($tag
->getMethodName());
$methodNode
->setStatic($tag
->isStatic());
$node
->addMethod($methodNode);
}
}
}