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