forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php.dist
133 lines (108 loc) · 4.83 KB
/
autoload.php.dist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
// https://bugs.php.net/bug.php?id=53976
gc_disable();
}
/**
* Catch deprecation notices and print a summary report at the end of the test suite
*
* @internal
*/
class DeprecationErrorHandler
{
private static $isRegistered = false;
public static function register()
{
if (self::$isRegistered) {
return;
}
$deprecations = array(
'remainingCount' => 0,
'legacyCount' => 0,
'otherCount' => 0,
'remaining' => array(),
'legacy' => array(),
'other' => array(),
);
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations) {
if (E_USER_DEPRECATED !== $type) {
return PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
}
$trace = debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT : true);
$i = count($trace);
while (isset($trace[--$i]['class']) && ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_'))) {
// No-op
}
if (isset($trace[$i]['object']) || isset($trace[$i]['class'])) {
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
$method = $trace[$i]['function'];
$type = 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($class, '\Legacy') ? 'legacy' : 'remaining';
if ('legacy' === $type && 0 === (error_reporting() & E_USER_DEPRECATED)) {
@++$deprecations[$type]['Silenced']['count'];
} else {
@++$deprecations[$type][$msg]['count'];
@++$deprecations[$type][$msg][$class.'::'.$method];
}
} else {
$type = 'other';
@++$deprecations[$type][$msg]['count'];
}
++$deprecations[$type.'Count'];
};
$oldErrorHandler = set_error_handler($deprecationHandler);
if (null !== $oldErrorHandler) {
restore_error_handler();
if (array('PHPUnit_Util_ErrorHandler', 'handleError') === $oldErrorHandler) {
restore_error_handler();
self::register();
}
} else {
self::$isRegistered = true;
register_shutdown_function(function () use (&$deprecations, $deprecationHandler) {
$colorize = new \SebastianBergmann\Environment\Console();
if ($colorize->hasColorSupport()) {
$colorize = function ($str, $red) {
$color = $red ? '41;37' : '43;30';
return "\x1B[{$color}m{$str}\x1B[0m";
};
} else {
$colorize = function ($str) {return $str;};
}
$currErrorHandler = set_error_handler('var_dump');
restore_error_handler();
if ($currErrorHandler !== $deprecationHandler) {
echo "\n", $colorize('THE ERROR HANDLER HAS CHANGED!', true), "\n";
}
$cmp = function ($a, $b) {
return $b['count'] - $a['count'];
};
foreach (array('remaining', 'legacy', 'other') as $type) {
if ($deprecations[$type]) {
echo "\n", $colorize(sprintf('%s deprecation notices (%d)', ucfirst($type), $deprecations[$type.'Count']), 'legacy' !== $type), "\n";
uasort($deprecations[$type], $cmp);
foreach ($deprecations[$type] as $msg => $notices) {
echo "\n", $msg, ': ', $notices['count'], "x\n";
arsort($notices);
foreach ($notices as $method => $count) {
if ('count' !== $method) {
echo ' ', $count, 'x in ', preg_replace('/(.*)\\\\(.*?::.*?)$/', '$2 from $1', $method), "\n";
}
}
}
}
}
if (!empty($notices)) {
echo "\n";
}
});
}
}
}
if (class_exists('PHPUnit_Util_ErrorHandler')) {
DeprecationErrorHandler::register();
}
$loader = require_once __DIR__.'/vendor/autoload.php';
use Doctrine\Common\Annotations\AnnotationRegistry;
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;