comparison vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
9 * file that was distributed with this source code. 9 * file that was distributed with this source code.
10 */ 10 */
11 11
12 namespace Symfony\Component\Debug\FatalErrorHandler; 12 namespace Symfony\Component\Debug\FatalErrorHandler;
13 13
14 use Symfony\Component\Debug\Exception\FatalErrorException;
14 use Symfony\Component\Debug\Exception\UndefinedFunctionException; 15 use Symfony\Component\Debug\Exception\UndefinedFunctionException;
15 use Symfony\Component\Debug\Exception\FatalErrorException;
16 16
17 /** 17 /**
18 * ErrorHandler for undefined functions. 18 * ErrorHandler for undefined functions.
19 * 19 *
20 * @author Fabien Potencier <fabien@symfony.com> 20 * @author Fabien Potencier <fabien@symfony.com>
24 /** 24 /**
25 * {@inheritdoc} 25 * {@inheritdoc}
26 */ 26 */
27 public function handleError(array $error, FatalErrorException $exception) 27 public function handleError(array $error, FatalErrorException $exception)
28 { 28 {
29 $messageLen = strlen($error['message']); 29 $messageLen = \strlen($error['message']);
30 $notFoundSuffix = '()'; 30 $notFoundSuffix = '()';
31 $notFoundSuffixLen = strlen($notFoundSuffix); 31 $notFoundSuffixLen = \strlen($notFoundSuffix);
32 if ($notFoundSuffixLen > $messageLen) { 32 if ($notFoundSuffixLen > $messageLen) {
33 return; 33 return;
34 } 34 }
35 35
36 if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { 36 if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
37 return; 37 return;
38 } 38 }
39 39
40 $prefix = 'Call to undefined function '; 40 $prefix = 'Call to undefined function ';
41 $prefixLen = strlen($prefix); 41 $prefixLen = \strlen($prefix);
42 if (0 !== strpos($error['message'], $prefix)) { 42 if (0 !== strpos($error['message'], $prefix)) {
43 return; 43 return;
44 } 44 }
45 45
46 $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); 46 $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
51 } else { 51 } else {
52 $functionName = $fullyQualifiedFunctionName; 52 $functionName = $fullyQualifiedFunctionName;
53 $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName); 53 $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
54 } 54 }
55 55
56 $candidates = array(); 56 $candidates = [];
57 foreach (get_defined_functions() as $type => $definedFunctionNames) { 57 foreach (get_defined_functions() as $type => $definedFunctionNames) {
58 foreach ($definedFunctionNames as $definedFunctionName) { 58 foreach ($definedFunctionNames as $definedFunctionName) {
59 if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) { 59 if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
60 $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1); 60 $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
61 } else { 61 } else {