class KeywordPatch
Remove method functionality from the double which will clash with php keywords.
@author Milan Magudia <milan@magudia.com>
Hierarchy
- class \Prophecy\Doubler\ClassPatch\KeywordPatch implements \Prophecy\Doubler\ClassPatch\ClassPatchInterface
Expanded class hierarchy of KeywordPatch
File
-
vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ ClassPatch/ KeywordPatch.php, line 21
Namespace
Prophecy\Doubler\ClassPatchView source
class KeywordPatch implements ClassPatchInterface {
/**
* Support any class
*
* @param ClassNode $node
*
* @return boolean
*/
public function supports(ClassNode $node) {
return true;
}
/**
* Remove methods that clash with php keywords
*
* @param ClassNode $node
*/
public function apply(ClassNode $node) {
$methodNames = array_keys($node->getMethods());
$methodsToRemove = array_intersect($methodNames, $this->getKeywords());
foreach ($methodsToRemove as $methodName) {
$node->removeMethod($methodName);
}
}
/**
* Returns patch priority, which determines when patch will be applied.
*
* @return int Priority number (higher - earlier)
*/
public function getPriority() {
return 49;
}
/**
* Returns array of php keywords.
*
* @return list<string>
*/
private function getKeywords() {
return [
'__halt_compiler',
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
KeywordPatch::apply | public | function | Remove methods that clash with php keywords | Overrides ClassPatchInterface::apply |
KeywordPatch::getKeywords | private | function | Returns array of php keywords. | |
KeywordPatch::getPriority | public | function | Returns patch priority, which determines when patch will be applied. | Overrides ClassPatchInterface::getPriority |
KeywordPatch::supports | public | function | Support any class | Overrides ClassPatchInterface::supports |