@@ -61,29 +61,6 @@ public static function register($mode = 0)
61
61
return $ memoizedMode = $ mode ;
62
62
};
63
63
64
- $ inVendors = function ($ path ) {
65
- /** @var string[] absolute paths to vendor directories */
66
- static $ vendors ;
67
- if (null === $ vendors ) {
68
- foreach (get_declared_classes () as $ class ) {
69
- if ('C ' === $ class [0 ] && 0 === strpos ($ class , 'ComposerAutoloaderInit ' )) {
70
- $ r = new \ReflectionClass ($ class );
71
- $ v = dirname (dirname ($ r ->getFileName ()));
72
- if (file_exists ($ v .'/composer/installed.json ' )) {
73
- $ vendors [] = $ v ;
74
- }
75
- }
76
- }
77
- }
78
- $ path = realpath ($ path ) ?: $ path ;
79
- foreach ($ vendors as $ vendor ) {
80
- if (0 === strpos ($ path , $ vendor ) && false !== strpbrk (substr ($ path , strlen ($ vendor ), 1 ), '/ ' .DIRECTORY_SEPARATOR )) {
81
- return true ;
82
- }
83
- }
84
-
85
- return false ;
86
- };
87
64
88
65
$ deprecations = array (
89
66
'unsilencedCount ' => 0 ,
@@ -97,7 +74,7 @@ public static function register($mode = 0)
97
74
'other ' => array (),
98
75
'remaining vendor ' => array (),
99
76
);
100
- $ deprecationHandler = function ($ type , $ msg , $ file , $ line , $ context = array ()) use (&$ deprecations , $ getMode , $ UtilPrefix, $ inVendors ) {
77
+ $ deprecationHandler = function ($ type , $ msg , $ file , $ line , $ context = array ()) use (&$ deprecations , $ getMode , $ UtilPrefix ) {
101
78
$ mode = $ getMode ();
102
79
if ((E_USER_DEPRECATED !== $ type && E_DEPRECATED !== $ type ) || DeprecationErrorHandler::MODE_DISABLED === $ mode ) {
103
80
$ ErrorHandler = $ UtilPrefix .'ErrorHandler ' ;
@@ -108,7 +85,7 @@ public static function register($mode = 0)
108
85
$ trace = debug_backtrace (true );
109
86
$ group = 'other ' ;
110
87
111
- $ isWeak = DeprecationErrorHandler::MODE_WEAK === $ mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $ mode && $ isVendor = $ inVendors ($ file ));
88
+ $ isWeak = DeprecationErrorHandler::MODE_WEAK === $ mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $ mode && $ isVendor = self :: inVendors ($ file ));
112
89
113
90
$ i = count ($ trace );
114
91
while (1 < $ i && (!isset ($ trace [--$ i ]['class ' ]) || ('ReflectionMethod ' === $ trace [$ i ]['class ' ] || 0 === strpos ($ trace [$ i ]['class ' ], 'PHPUnit_ ' ) || 0 === strpos ($ trace [$ i ]['class ' ], 'PHPUnit \\' )))) {
@@ -246,6 +223,31 @@ public static function register($mode = 0)
246
223
}
247
224
}
248
225
226
+ private static function inVendors (string $ path ): bool
227
+ {
228
+ /** @var string[] absolute paths to vendor directories */
229
+ static $ vendors ;
230
+ if (null === $ vendors ) {
231
+ foreach (get_declared_classes () as $ class ) {
232
+ if ('C ' === $ class [0 ] && 0 === strpos ($ class , 'ComposerAutoloaderInit ' )) {
233
+ $ r = new \ReflectionClass ($ class );
234
+ $ v = dirname (dirname ($ r ->getFileName ()));
235
+ if (file_exists ($ v .'/composer/installed.json ' )) {
236
+ $ vendors [] = $ v ;
237
+ }
238
+ }
239
+ }
240
+ }
241
+ $ path = realpath ($ path ) ?: $ path ;
242
+ foreach ($ vendors as $ vendor ) {
243
+ if (0 === strpos ($ path , $ vendor ) && false !== strpbrk (substr ($ path , strlen ($ vendor ), 1 ), '/ ' .DIRECTORY_SEPARATOR )) {
244
+ return true ;
245
+ }
246
+ }
247
+
248
+ return false ;
249
+ }
250
+
249
251
public static function collectDeprecations ($ outputFile )
250
252
{
251
253
$ deprecations = array ();
0 commit comments