class MagicCallPatch 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
Discover Magical API using "@method" PHPDoc format.
@author Thomas Tourlourat <thomas@tourlourat.com>
Hierarchy
- class \Prophecy\Doubler\ClassPatch\MagicCallPatch implements ClassPatchInterface
Expanded class hierarchy of MagicCallPatch
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ ClassPatch/ MagicCallPatch.php, line 23
Namespace
Prophecy\Doubler\ClassPatchView source
class MagicCallPatch implements ClassPatchInterface {
/**
* Support any class
*
* @param ClassNode $node
*
* @return boolean
*/
public function supports(ClassNode $node) {
return true;
}
/**
* Discover Magical API
*
* @param ClassNode $node
*/
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);
}
}
}
/**
* Returns patch priority, which determines when patch will be applied.
*
* @return integer Priority number (higher - earlier)
*/
public function getPriority() {
return 50;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MagicCallPatch:: |
public | function |
Discover Magical API Overrides ClassPatchInterface:: |
|
MagicCallPatch:: |
public | function |
Returns patch priority, which determines when patch will be applied. Overrides ClassPatchInterface:: |
|
MagicCallPatch:: |
public | function |
Support any class Overrides ClassPatchInterface:: |