if ($node instanceof ConstFetch && count($node->name->parts) > 1) {
$name = $this->getFullyQualifiedName($node->name);
if (!defined($name)) {
- throw new FatalErrorException(sprintf('Undefined constant %s', $name), 0, 1, null, $node->getLine());
+ $msg = sprintf('Undefined constant %s', $name);
+ throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
}
} elseif ($node instanceof ClassConstFetch) {
$this->validateClassConstFetchExpression($node);
// if the class doesn't exist, don't throw an exception… it might be
// defined in the same line it's used or something stupid like that.
if (class_exists($className) || interface_exists($className)) {
- $constName = sprintf('%s::%s', $className, $stmt->name);
- if (!defined($constName)) {
+ $refl = new \ReflectionClass($className);
+ if (!$refl->hasConstant($stmt->name)) {
$constType = class_exists($className) ? 'Class' : 'Interface';
- $msg = sprintf('%s constant \'%s\' not found', $constType, $constName);
- throw new FatalErrorException($msg, 0, 1, null, $stmt->getLine());
+ $msg = sprintf('%s constant \'%s::%s\' not found', $constType, $className, $stmt->name);
+ throw new FatalErrorException($msg, 0, E_ERROR, null, $stmt->getLine());
}
}
}