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;
/**
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());
}
}
$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());
}
}
}
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_;
}
}