forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php.dist
95 lines (82 loc) · 3.37 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
<?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(0);
$oldErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) use (&$deprecations) {
if (E_USER_DEPRECATED !== $type) {
return PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
}
++$deprecations[0];
$trace = debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
$i = count($trace);
while (isset($trace[--$i]['class']) && ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_'))) {
// No-op
}
if (isset($trace[$i]['class'])) {
if (isset($deprecations[$trace[$i]['class']][$trace[$i]['function']][$msg])) {
++$deprecations[$trace[$i]['class']][$trace[$i]['function']][$msg];
} else {
$deprecations[$trace[$i]['class']][$trace[$i]['function']][$msg] = 1;
}
}
});
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) {
if ($deprecations[0]) {
if (function_exists('posix_isatty') && @posix_isatty(STDOUT)) {
echo "\n\x1B[43;30mDeprecation notices ($deprecations[0]):\x1B[0m\n";
} else {
echo "\nDeprecation notices ($deprecations[0]):\n";
}
foreach ($deprecations as $class => $notices) {
if (0 !== $class) {
echo "\n{$class}\n";
foreach ($notices as $method => $notices) {
echo " ->{$method}()\n";
foreach ($notices as $msg => $freq) {
echo " {$msg}: $freq\n";
}
}
}
}
} else {
if (function_exists('posix_isatty') && @posix_isatty(STDOUT)) {
echo "\n\x1B[42;30mNo deprecation notice\x1B[0m\n";
} else {
echo "\nNo deprecation notice\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;