Yaffs site version 1.1
[yaffs-website] / vendor / psy / psysh / src / Psy / CodeCleaner / ValidFunctionNamePass.php
index 6eca1fa32a78afcbdc602500cf261d02f0b6d9c6..8b4e184a97f207c70312791a416f4c095ba21ab6 100644 (file)
@@ -15,11 +15,11 @@ use PhpParser\Node;
 use PhpParser\Node\Expr;
 use PhpParser\Node\Expr\FuncCall;
 use PhpParser\Node\Expr\Variable;
-use PhpParser\Node\Stmt\Do_ as DoStmt;
-use PhpParser\Node\Stmt\Function_ as FunctionStmt;
-use PhpParser\Node\Stmt\If_ as IfStmt;
-use PhpParser\Node\Stmt\Switch_ as SwitchStmt;
-use PhpParser\Node\Stmt\While_ as WhileStmt;
+use PhpParser\Node\Stmt\Do_;
+use PhpParser\Node\Stmt\Function_;
+use PhpParser\Node\Stmt\If_;
+use PhpParser\Node\Stmt\Switch_;
+use PhpParser\Node\Stmt\While_;
 use Psy\Exception\FatalErrorException;
 
 /**
@@ -43,16 +43,16 @@ class ValidFunctionNamePass extends NamespaceAwarePass
 
         if (self::isConditional($node)) {
             $this->conditionalScopes++;
-        } elseif ($node instanceof FunctionStmt) {
+        } elseif ($node instanceof Function_) {
             $name = $this->getFullyQualifiedName($node->name);
 
-            // TODO: add an "else" here which adds a runtime check for instances where we can't tell
+            // @todo add an "else" here which adds a runtime check for instances where we can't tell
             // whether a function is being redefined by static analysis alone.
             if ($this->conditionalScopes === 0) {
                 if (function_exists($name) ||
                     isset($this->currentScope[strtolower($name)])) {
                     $msg = sprintf('Cannot redeclare %s()', $name);
-                    throw new FatalErrorException($msg, 0, 1, null, $node->getLine());
+                    throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
                 }
             }
 
@@ -81,7 +81,7 @@ class ValidFunctionNamePass extends NamespaceAwarePass
                 $inScope = isset($this->currentScope[strtolower($fullName)]);
                 if (!$inScope && !function_exists($shortName) && !function_exists($fullName)) {
                     $message = sprintf('Call to undefined function %s()', $name);
-                    throw new FatalErrorException($message, 0, 1, null, $node->getLine());
+                    throw new FatalErrorException($message, 0, E_ERROR, null, $node->getLine());
                 }
             }
         }
@@ -89,9 +89,9 @@ class ValidFunctionNamePass extends NamespaceAwarePass
 
     private static function isConditional(Node $node)
     {
-        return $node instanceof IfStmt ||
-            $node instanceof WhileStmt ||
-            $node instanceof DoStmt ||
-            $node instanceof SwitchStmt;
+        return $node instanceof If_ ||
+            $node instanceof While_ ||
+            $node instanceof Do_ ||
+            $node instanceof Switch_;
     }
 }