4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\CodeCleaner;
15 use PhpParser\Node\Expr\Variable;
16 use Psy\Exception\RuntimeException;
19 * Validate that the user input does not reference the `$__psysh__` variable.
21 class LeavePsyshAlonePass extends CodeCleanerPass
24 * Validate that the user input does not reference the `$__psysh__` variable.
26 * @throws RuntimeException if the user is messing with $__psysh__
30 public function enterNode(Node $node)
32 if ($node instanceof Variable && $node->name === '__psysh__') {
33 throw new RuntimeException('Don\'t mess with $__psysh__. Bad things will happen.');