@@ -6,6 +6,86 @@ if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
6
6
gc_disable();
7
7
}
8
8
9
+ /**
10
+ * Catch deprecation notices and print a summary report at the end of the test suite
11
+ *
12
+ * @internal
13
+ */
14
+ class DeprecationErrorHandler
15
+ {
16
+ private static $isRegistered = false;
8000
17
+
18
+ public static function register()
19
+ {
20
+ if (self::$isRegistered) {
21
+ return;
22
+ }
23
+ $deprecations = array(0);
24
+ $oldErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) use (&$deprecations) {
25
+ if (E_USER_DEPRECATED !== $type) {
26
+ return PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
27
+ }
28
+
29
+ ++$deprecations[0];
30
+ $trace = debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
31
+
32
+ $i = count($trace);
33
+ while (isset($trace[--$i]['class']) && ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_'))) {
34
+ // No-op
35
+ }
36
+
37
+ if (isset($trace[$i]['class'])) {
38
+ if (isset($deprecations[$trace[$i]['class']][$trace[$i]['function']][$msg])) {
39
+ ++$deprecations[$trace[$i]['class']][$trace[$i]['function']][$msg];
40
+ } else {
41
+ $deprecations[$trace[$i]['class']][$trace[$i]['function']][$msg] = 1;
42
+ }
43
+ }
44
+ });
45
+
46
+ if (null !== $oldErrorHandler) {
47
+ restore_error_handler();
48
+ if (array('PHPUnit_Util_ErrorHandler', 'handleError') === $oldErrorHandler) {
49
+ restore_error_handler();
50
+ self::register();
51
+ }
52
+ } else {
53
+ self::$isRegistered = true;
54
+ register_shutdown_function(function () use (&$deprecations) {
55
+ if ($deprecations[0]) {
56
+ if (function_exists('posix_isatty') && @posix_isatty(STDOUT)) {
57
+ echo "\n\x1B[43;30mDeprecation notices ($deprecations[0]):\x1B[0m\n";
58
+ } else {
59
+ echo "\nDeprecation notices ($deprecations[0]):\n";
60
+ }
61
+
62
+ foreach ($deprecations as $class => $notices) {
63
+ if (0 !== $class) {
64
+ echo "\n{$class}\n";
65
+ foreach ($notices as $method => $notices) {
66
+ echo " ->{$method}()\n";
67
+ foreach ($notices as $msg => $freq) {
68
+ echo " {$msg}: $freq\n";
69
+ }
70
+ }
71
+ }
72
+ }
73
+ } else {
74
+ if (function_exists('posix_isatty') && @posix_isatty(STDOUT)) {
75
+ echo "\n\x1B[42;30mNo deprecation notice\x1B[0m\n";
76
+ } else {
77
+ echo "\nNo deprecation notice\n";
78
+ }
79
+ }
80
+ });
81
+ }
82
+ }
83
+ }
84
+
85
+ if (class_exists('PHPUnit_Util_ErrorHandler')) {
86
+ DeprecationErrorHandler::register();
87
+ }
88
+
9
89
$loader = require_once __DIR__.'/vendor/autoload.php';
10
90
11
91
use Doctrine\Common\Annotations\AnnotationRegistry;
0 commit comments