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\FuncCall as FunctionCall;
16 use PhpParser\Node\Expr\MethodCall;
17 use PhpParser\Node\Expr\StaticCall;
18 use Psy\Exception\FatalErrorException;
21 * Validate that the user did not use the call-time pass-by-reference that causes a fatal error.
23 * As of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error.
25 * @author Martin HasoĊ <martin.hason@gmail.com>
27 class CallTimePassByReferencePass extends CodeCleanerPass
30 * Validate of use call-time pass-by-reference.
32 * @throws RuntimeException if the user used call-time pass-by-reference in PHP >= 5.4.0
36 public function enterNode(Node $node)
38 if (version_compare(PHP_VERSION, '5.4', '<')) {
42 if (!$node instanceof FunctionCall && !$node instanceof MethodCall && !$node instanceof StaticCall) {
46 foreach ($node->args as $arg) {
48 throw new FatalErrorException('Call-time pass-by-reference has been removed');