Chris@0: name->parts) > 1) { Chris@0: $name = $this->getFullyQualifiedName($node->name); Chris@0: if (!defined($name)) { Chris@0: $msg = sprintf('Undefined constant %s', $name); Chris@0: throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine()); Chris@0: } Chris@0: } elseif ($node instanceof ClassConstFetch) { Chris@0: $this->validateClassConstFetchExpression($node); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Validate a class constant fetch expression. Chris@0: * Chris@0: * @throws FatalErrorException if a class constant is not defined Chris@0: * Chris@0: * @param ClassConstFetch $stmt Chris@0: */ Chris@0: protected function validateClassConstFetchExpression(ClassConstFetch $stmt) Chris@0: { Chris@0: // give the `class` pseudo-constant a pass Chris@0: if ($stmt->name === 'class') { Chris@0: return; Chris@0: } Chris@0: Chris@0: // if class name is an expression, give it a pass for now Chris@0: if (!$stmt->class instanceof Expr) { Chris@0: $className = $this->getFullyQualifiedName($stmt->class); Chris@0: Chris@0: // if the class doesn't exist, don't throw an exception… it might be Chris@0: // defined in the same line it's used or something stupid like that. Chris@0: if (class_exists($className) || interface_exists($className)) { Chris@0: $refl = new \ReflectionClass($className); Chris@0: if (!$refl->hasConstant($stmt->name)) { Chris@0: $constType = class_exists($className) ? 'Class' : 'Interface'; Chris@0: $msg = sprintf('%s constant \'%s::%s\' not found', $constType, $className, $stmt->name); Chris@0: throw new FatalErrorException($msg, 0, E_ERROR, null, $stmt->getLine()); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: }