<?php/* * This file is part of Psy Shell. * * (c) 2012-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */namespacePsy\CodeCleaner;usePhpParser\NodeasNode;usePhpParser\Node\Expr\Assign;usePhpParser\Node\Expr\Variable;usePsy\Exception\FatalErrorException;/** * Validate that the user input does not assign the `$this` variable. * * @author Martin Hasoň <martin.hason@gmail.com> */classAssignThisVariablePassextendsCodeCleanerPass{/** * Validate that the user input does not assign the `$this` variable. * * @throws RuntimeException if the user assign the `$this` variable * * @param Node $node */publicfunctionenterNode(Node$node){if($nodeinstanceofAssign&&$node->varinstanceofVariable&&$node->var->name==='this'){thrownewFatalErrorException('Cannot re-assign $this');}}}