comparison vendor/psy/psysh/src/CodeCleaner/ValidConstantPass.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
41 * 41 *
42 * @param Node $node 42 * @param Node $node
43 */ 43 */
44 public function leaveNode(Node $node) 44 public function leaveNode(Node $node)
45 { 45 {
46 if ($node instanceof ConstFetch && count($node->name->parts) > 1) { 46 if ($node instanceof ConstFetch && \count($node->name->parts) > 1) {
47 $name = $this->getFullyQualifiedName($node->name); 47 $name = $this->getFullyQualifiedName($node->name);
48 if (!defined($name)) { 48 if (!\defined($name)) {
49 $msg = sprintf('Undefined constant %s', $name); 49 $msg = \sprintf('Undefined constant %s', $name);
50 throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine()); 50 throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
51 } 51 }
52 } elseif ($node instanceof ClassConstFetch) { 52 } elseif ($node instanceof ClassConstFetch) {
53 $this->validateClassConstFetchExpression($node); 53 $this->validateClassConstFetchExpression($node);
54 } 54 }
75 if (!$stmt->class instanceof Expr) { 75 if (!$stmt->class instanceof Expr) {
76 $className = $this->getFullyQualifiedName($stmt->class); 76 $className = $this->getFullyQualifiedName($stmt->class);
77 77
78 // if the class doesn't exist, don't throw an exception… it might be 78 // if the class doesn't exist, don't throw an exception… it might be
79 // defined in the same line it's used or something stupid like that. 79 // defined in the same line it's used or something stupid like that.
80 if (class_exists($className) || interface_exists($className)) { 80 if (\class_exists($className) || \interface_exists($className)) {
81 $refl = new \ReflectionClass($className); 81 $refl = new \ReflectionClass($className);
82 if (!$refl->hasConstant($constName)) { 82 if (!$refl->hasConstant($constName)) {
83 $constType = class_exists($className) ? 'Class' : 'Interface'; 83 $constType = \class_exists($className) ? 'Class' : 'Interface';
84 $msg = sprintf('%s constant \'%s::%s\' not found', $constType, $className, $constName); 84 $msg = \sprintf('%s constant \'%s::%s\' not found', $constType, $className, $constName);
85 throw new FatalErrorException($msg, 0, E_ERROR, null, $stmt->getLine()); 85 throw new FatalErrorException($msg, 0, E_ERROR, null, $stmt->getLine());
86 } 86 }
87 } 87 }
88 } 88 }
89 } 89 }