class KeywordPatch in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/KeywordPatch.php \Prophecy\Doubler\ClassPatch\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 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 array
*/
private function getKeywords() {
return array(
'__halt_compiler',
'abstract',
'and',
'array',
'as',
'break',
'callable',
'case',
'catch',
'class',
'clone',
'const',
'continue',
'declare',
'default',
'die',
'do',
'echo',
'else',
'elseif',
'empty',
'enddeclare',
'endfor',
'endforeach',
'endif',
'endswitch',
'endwhile',
'eval',
'exit',
'extends',
'final',
'finally',
'for',
'foreach',
'function',
'global',
'goto',
'if',
'implements',
'include',
'include_once',
'instanceof',
'insteadof',
'interface',
'isset',
'list',
'namespace',
'new',
'or',
'print',
'private',
'protected',
'public',
'require',
'require_once',
'return',
'static',
'switch',
'throw',
'trait',
'try',
'unset',
'use',
'var',
'while',
'xor',
'yield',
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
KeywordPatch:: |
public | function |
Remove methods that clash with php keywords Overrides ClassPatchInterface:: |
|
KeywordPatch:: |
private | function | Returns array of php keywords. | |
KeywordPatch:: |
public | function |
Returns patch priority, which determines when patch will be applied. Overrides ClassPatchInterface:: |
|
KeywordPatch:: |
public | function |
Support any class Overrides ClassPatchInterface:: |