function it_will_remove_echo_and_eval_methods(ClassNode $node, MethodNode $method1, MethodNode $method2, MethodNode $method3) { $node->removeMethod('eval')->shouldBeCalled(); $node->removeMethod('echo')->shouldBeCalled(); $method1->getName()->willReturn('echo'); $method2->getName()->willReturn('eval'); $method3->getName()->willReturn('notKeyword'); $node->getMethods()->willReturn(array('echo' => $method1, 'eval' => $method2, 'notKeyword' => $method3)); $this->apply($node); }
/** * 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); } }