Mercurial > hg > isophonics-drupal-site
annotate vendor/psy/psysh/src/CodeCleaner/CallTimePassByReferencePass.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | c2387f117808 |
children |
rev | line source |
---|---|
Chris@13 | 1 <?php |
Chris@13 | 2 |
Chris@13 | 3 /* |
Chris@13 | 4 * This file is part of Psy Shell. |
Chris@13 | 5 * |
Chris@13 | 6 * (c) 2012-2018 Justin Hileman |
Chris@13 | 7 * |
Chris@13 | 8 * For the full copyright and license information, please view the LICENSE |
Chris@13 | 9 * file that was distributed with this source code. |
Chris@13 | 10 */ |
Chris@13 | 11 |
Chris@13 | 12 namespace Psy\CodeCleaner; |
Chris@13 | 13 |
Chris@13 | 14 use PhpParser\Node; |
Chris@13 | 15 use PhpParser\Node\Expr\FuncCall; |
Chris@13 | 16 use PhpParser\Node\Expr\MethodCall; |
Chris@13 | 17 use PhpParser\Node\Expr\StaticCall; |
Chris@13 | 18 use Psy\Exception\FatalErrorException; |
Chris@13 | 19 |
Chris@13 | 20 /** |
Chris@13 | 21 * Validate that the user did not use the call-time pass-by-reference that causes a fatal error. |
Chris@13 | 22 * |
Chris@13 | 23 * As of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error. |
Chris@13 | 24 * |
Chris@13 | 25 * @author Martin HasoĊ <martin.hason@gmail.com> |
Chris@13 | 26 */ |
Chris@13 | 27 class CallTimePassByReferencePass extends CodeCleanerPass |
Chris@13 | 28 { |
Chris@13 | 29 const EXCEPTION_MESSAGE = 'Call-time pass-by-reference has been removed'; |
Chris@13 | 30 |
Chris@13 | 31 /** |
Chris@13 | 32 * Validate of use call-time pass-by-reference. |
Chris@13 | 33 * |
Chris@16 | 34 * @throws RuntimeException if the user used call-time pass-by-reference |
Chris@13 | 35 * |
Chris@13 | 36 * @param Node $node |
Chris@13 | 37 */ |
Chris@13 | 38 public function enterNode(Node $node) |
Chris@13 | 39 { |
Chris@13 | 40 if (!$node instanceof FuncCall && !$node instanceof MethodCall && !$node instanceof StaticCall) { |
Chris@13 | 41 return; |
Chris@13 | 42 } |
Chris@13 | 43 |
Chris@13 | 44 foreach ($node->args as $arg) { |
Chris@13 | 45 if ($arg->byRef) { |
Chris@13 | 46 throw new FatalErrorException(self::EXCEPTION_MESSAGE, 0, E_ERROR, null, $node->getLine()); |
Chris@13 | 47 } |
Chris@13 | 48 } |
Chris@13 | 49 } |
Chris@13 | 50 } |