4 * This file is part of the Prophecy.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6 * Marcello Duarte <marcello.duarte@gmail.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Prophecy\Doubler\ClassPatch;
14 use Prophecy\Doubler\Generator\Node\ClassNode;
17 * Remove method functionality from the double which will clash with php keywords.
19 * @author Milan Magudia <milan@magudia.com>
21 class KeywordPatch implements ClassPatchInterface
26 * @param ClassNode $node
30 public function supports(ClassNode $node)
36 * Remove methods that clash with php keywords
38 * @param ClassNode $node
40 public function apply(ClassNode $node)
42 $methodNames = array_keys($node->getMethods());
43 $methodsToRemove = array_intersect($methodNames, $this->getKeywords());
44 foreach ($methodsToRemove as $methodName) {
45 $node->removeMethod($methodName);
50 * Returns patch priority, which determines when patch will be applied.
52 * @return int Priority number (higher - earlier)
54 public function getPriority()
60 * Returns array of php keywords.
64 private function getKeywords()
66 if (\PHP_VERSION_ID >= 70000) {
67 return array('__halt_compiler');