comparison vendor/psy/psysh/src/CodeCleaner/CallTimePassByReferencePass.php @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents
children c2387f117808
comparison
equal deleted inserted replaced
12:7a779792577d 13:5fb285c0d0e3
1 <?php
2
3 /*
4 * This file is part of Psy Shell.
5 *
6 * (c) 2012-2018 Justin Hileman
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Psy\CodeCleaner;
13
14 use PhpParser\Node;
15 use PhpParser\Node\Expr\FuncCall;
16 use PhpParser\Node\Expr\MethodCall;
17 use PhpParser\Node\Expr\StaticCall;
18 use Psy\Exception\FatalErrorException;
19
20 /**
21 * Validate that the user did not use the call-time pass-by-reference that causes a fatal error.
22 *
23 * As of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error.
24 *
25 * @author Martin HasoĊˆ <martin.hason@gmail.com>
26 */
27 class CallTimePassByReferencePass extends CodeCleanerPass
28 {
29 const EXCEPTION_MESSAGE = 'Call-time pass-by-reference has been removed';
30
31 /**
32 * Validate of use call-time pass-by-reference.
33 *
34 * @throws RuntimeException if the user used call-time pass-by-reference in PHP >= 5.4.0
35 *
36 * @param Node $node
37 */
38 public function enterNode(Node $node)
39 {
40 if (!$node instanceof FuncCall && !$node instanceof MethodCall && !$node instanceof StaticCall) {
41 return;
42 }
43
44 foreach ($node->args as $arg) {
45 if ($arg->byRef) {
46 throw new FatalErrorException(self::EXCEPTION_MESSAGE, 0, E_ERROR, null, $node->getLine());
47 }
48 }
49 }
50 }