Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/src/CodeCleaner/ValidFunctionNamePass.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 5fb285c0d0e3 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
47 $name = $this->getFullyQualifiedName($node->name); | 47 $name = $this->getFullyQualifiedName($node->name); |
48 | 48 |
49 // @todo add an "else" here which adds a runtime check for instances where we can't tell | 49 // @todo add an "else" here which adds a runtime check for instances where we can't tell |
50 // whether a function is being redefined by static analysis alone. | 50 // whether a function is being redefined by static analysis alone. |
51 if ($this->conditionalScopes === 0) { | 51 if ($this->conditionalScopes === 0) { |
52 if (function_exists($name) || | 52 if (\function_exists($name) || |
53 isset($this->currentScope[strtolower($name)])) { | 53 isset($this->currentScope[\strtolower($name)])) { |
54 $msg = sprintf('Cannot redeclare %s()', $name); | 54 $msg = \sprintf('Cannot redeclare %s()', $name); |
55 throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine()); | 55 throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine()); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 $this->currentScope[strtolower($name)] = true; | 59 $this->currentScope[\strtolower($name)] = true; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 /** | 63 /** |
64 * Validate that function calls will succeed. | 64 * Validate that function calls will succeed. |
74 $this->conditionalScopes--; | 74 $this->conditionalScopes--; |
75 } elseif ($node instanceof FuncCall) { | 75 } elseif ($node instanceof FuncCall) { |
76 // if function name is an expression or a variable, give it a pass for now. | 76 // if function name is an expression or a variable, give it a pass for now. |
77 $name = $node->name; | 77 $name = $node->name; |
78 if (!$name instanceof Expr && !$name instanceof Variable) { | 78 if (!$name instanceof Expr && !$name instanceof Variable) { |
79 $shortName = implode('\\', $name->parts); | 79 $shortName = \implode('\\', $name->parts); |
80 $fullName = $this->getFullyQualifiedName($name); | 80 $fullName = $this->getFullyQualifiedName($name); |
81 $inScope = isset($this->currentScope[strtolower($fullName)]); | 81 $inScope = isset($this->currentScope[\strtolower($fullName)]); |
82 if (!$inScope && !function_exists($shortName) && !function_exists($fullName)) { | 82 if (!$inScope && !\function_exists($shortName) && !\function_exists($fullName)) { |
83 $message = sprintf('Call to undefined function %s()', $name); | 83 $message = \sprintf('Call to undefined function %s()', $name); |
84 throw new FatalErrorException($message, 0, E_ERROR, null, $node->getLine()); | 84 throw new FatalErrorException($message, 0, E_ERROR, null, $node->getLine()); |
85 } | 85 } |
86 } | 86 } |
87 } | 87 } |
88 } | 88 } |