Yaffs site version 1.1
[yaffs-website] / vendor / psy / psysh / src / Psy / CodeCleaner / ValidConstantPass.php
index abc4d54673853ced5fc5ec344c129e35386336dc..e84f3de6661cede28ce53a14311c133ff6cbe47e 100644 (file)
@@ -45,7 +45,8 @@ class ValidConstantPass extends NamespaceAwarePass
         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);
@@ -73,11 +74,11 @@ class ValidConstantPass extends NamespaceAwarePass
             // 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());
                 }
             }
         }