Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
52 return $memoizedMode; | 52 return $memoizedMode; |
53 } | 53 } |
54 if (false === $mode) { | 54 if (false === $mode) { |
55 $mode = getenv('SYMFONY_DEPRECATIONS_HELPER'); | 55 $mode = getenv('SYMFONY_DEPRECATIONS_HELPER'); |
56 } | 56 } |
57 if (self::MODE_DISABLED !== $mode | 57 if (DeprecationErrorHandler::MODE_DISABLED !== $mode |
58 && self::MODE_WEAK !== $mode | 58 && DeprecationErrorHandler::MODE_WEAK !== $mode |
59 && self::MODE_WEAK_VENDORS !== $mode | 59 && DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode |
60 && (!isset($mode[0]) || '/' !== $mode[0]) | 60 && (!isset($mode[0]) || '/' !== $mode[0]) |
61 ) { | 61 ) { |
62 $mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0; | 62 $mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0; |
63 } | 63 } |
64 | 64 |
103 'legacy' => array(), | 103 'legacy' => array(), |
104 'other' => array(), | 104 'other' => array(), |
105 'remaining vendor' => array(), | 105 'remaining vendor' => array(), |
106 ); | 106 ); |
107 $deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) { | 107 $deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) { |
108 $mode = $getMode(); | 108 if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode = $getMode()) { |
109 if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || self::MODE_DISABLED === $mode) { | |
110 $ErrorHandler = $UtilPrefix.'ErrorHandler'; | 109 $ErrorHandler = $UtilPrefix.'ErrorHandler'; |
111 | 110 |
112 return $ErrorHandler::handleError($type, $msg, $file, $line, $context); | 111 return $ErrorHandler::handleError($type, $msg, $file, $line, $context); |
113 } | 112 } |
114 | 113 |
115 $trace = debug_backtrace(); | 114 $trace = debug_backtrace(); |
116 $group = 'other'; | 115 $group = 'other'; |
117 $isVendor = self::MODE_WEAK_VENDORS === $mode && $inVendors($file); | 116 $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file); |
118 | 117 |
119 $i = \count($trace); | 118 $i = \count($trace); |
120 while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) { | 119 while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) { |
121 // No-op | 120 // No-op |
122 } | 121 } |
129 $method = $parsedMsg['method']; | 128 $method = $parsedMsg['method']; |
130 // If the deprecation has been triggered via | 129 // If the deprecation has been triggered via |
131 // \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest() | 130 // \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest() |
132 // then we need to use the serialized information to determine | 131 // then we need to use the serialized information to determine |
133 // if the error has been triggered from vendor code. | 132 // if the error has been triggered from vendor code. |
134 $isVendor = self::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']); | 133 $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']); |
135 } else { | 134 } else { |
136 $class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class']; | 135 $class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class']; |
137 $method = $trace[$i]['function']; | 136 $method = $trace[$i]['function']; |
138 } | 137 } |
139 | 138 |
166 echo "\n".str_replace(' '.getcwd().\DIRECTORY_SEPARATOR, ' ', $e->getTraceAsString()); | 165 echo "\n".str_replace(' '.getcwd().\DIRECTORY_SEPARATOR, ' ', $e->getTraceAsString()); |
167 echo "\n"; | 166 echo "\n"; |
168 | 167 |
169 exit(1); | 168 exit(1); |
170 } | 169 } |
171 if ('legacy' !== $group && self::MODE_WEAK !== $mode) { | 170 if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) { |
172 $ref = &$deprecations[$group][$msg]['count']; | 171 $ref = &$deprecations[$group][$msg]['count']; |
173 ++$ref; | 172 ++$ref; |
174 $ref = &$deprecations[$group][$msg][$class.'::'.$method]; | 173 $ref = &$deprecations[$group][$msg][$class.'::'.$method]; |
175 ++$ref; | 174 ++$ref; |
176 } | 175 } |
177 } elseif (self::MODE_WEAK !== $mode) { | 176 } elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) { |
178 $ref = &$deprecations[$group][$msg]['count']; | 177 $ref = &$deprecations[$group][$msg]['count']; |
179 ++$ref; | 178 ++$ref; |
180 } | 179 } |
181 ++$deprecations[$group.'Count']; | 180 ++$deprecations[$group.'Count']; |
182 }; | 181 }; |
205 return; | 204 return; |
206 } | 205 } |
207 $currErrorHandler = set_error_handler('var_dump'); | 206 $currErrorHandler = set_error_handler('var_dump'); |
208 restore_error_handler(); | 207 restore_error_handler(); |
209 | 208 |
210 if (self::MODE_WEAK === $mode) { | 209 if (DeprecationErrorHandler::MODE_WEAK === $mode) { |
211 $colorize = function ($str) { return $str; }; | 210 $colorize = function ($str) { return $str; }; |
212 } | 211 } |
213 if ($currErrorHandler !== $deprecationHandler) { | 212 if ($currErrorHandler !== $deprecationHandler) { |
214 echo "\n", $colorize('THE ERROR HANDLER HAS CHANGED!', true), "\n"; | 213 echo "\n", $colorize('THE ERROR HANDLER HAS CHANGED!', true), "\n"; |
215 } | 214 } |
217 $cmp = function ($a, $b) { | 216 $cmp = function ($a, $b) { |
218 return $b['count'] - $a['count']; | 217 return $b['count'] - $a['count']; |
219 }; | 218 }; |
220 | 219 |
221 $groups = array('unsilenced', 'remaining'); | 220 $groups = array('unsilenced', 'remaining'); |
222 if (self::MODE_WEAK_VENDORS === $mode) { | 221 if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) { |
223 $groups[] = 'remaining vendor'; | 222 $groups[] = 'remaining vendor'; |
224 } | 223 } |
225 array_push($groups, 'legacy', 'other'); | 224 array_push($groups, 'legacy', 'other'); |
226 | 225 |
227 $displayDeprecations = function ($deprecations) use ($colorize, $cmp, $groups) { | 226 $displayDeprecations = function ($deprecations) use ($colorize, $cmp, $groups) { |
253 }; | 252 }; |
254 | 253 |
255 $displayDeprecations($deprecations); | 254 $displayDeprecations($deprecations); |
256 | 255 |
257 // store failing status | 256 // store failing status |
258 $isFailing = self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']; | 257 $isFailing = DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']; |
259 | 258 |
260 // reset deprecations array | 259 // reset deprecations array |
261 foreach ($deprecations as $group => $arrayOrInt) { | 260 foreach ($deprecations as $group => $arrayOrInt) { |
262 $deprecations[$group] = \is_int($arrayOrInt) ? 0 : array(); | 261 $deprecations[$group] = \is_int($arrayOrInt) ? 0 : array(); |
263 } | 262 } |
268 echo "Shutdown-time deprecations:\n"; | 267 echo "Shutdown-time deprecations:\n"; |
269 break; | 268 break; |
270 } | 269 } |
271 } | 270 } |
272 $displayDeprecations($deprecations); | 271 $displayDeprecations($deprecations); |
273 if ($isFailing || self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) { | 272 if ($isFailing || DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) { |
274 exit(1); | 273 exit(1); |
275 } | 274 } |
276 }); | 275 }); |
277 }); | 276 }); |
278 } | 277 } |