Chris@0: Chris@0: */ Chris@0: class AssignThisVariablePass extends CodeCleanerPass Chris@0: { Chris@0: /** Chris@0: * Validate that the user input does not assign the `$this` variable. Chris@0: * Chris@0: * @throws RuntimeException if the user assign the `$this` variable Chris@0: * Chris@0: * @param Node $node Chris@0: */ Chris@0: public function enterNode(Node $node) Chris@0: { Chris@0: if ($node instanceof Assign && $node->var instanceof Variable && $node->var->name === 'this') { Chris@0: throw new FatalErrorException('Cannot re-assign $this', 0, E_ERROR, null, $node->getLine()); Chris@0: } Chris@0: } Chris@0: }