@@ -54,9 +54,9 @@ public static function register($mode = 0)
54
54
if (false === $ mode ) {
55
55
$ mode = getenv ('SYMFONY_DEPRECATIONS_HELPER ' );
56
56
}
57
- if (DeprecationErrorHandler ::MODE_DISABLED !== $ mode
58
- && DeprecationErrorHandler ::MODE_WEAK !== $ mode
59
- && DeprecationErrorHandler ::MODE_WEAK_VENDORS !== $ mode
57
+ if (self ::MODE_DISABLED !== $ mode
58
+ && self ::MODE_WEAK !== $ mode
59
+ && self ::MODE_WEAK_VENDORS !== $ mode
60
60
&& (!isset ($ mode [0 ]) || '/ ' !== $ mode [0 ])
61
61
) {
62
62
$ mode = preg_match ('/^[1-9][0-9]*$/ ' , $ mode ) ? (int ) $ mode : 0 ;
@@ -106,15 +106,15 @@ public static function register($mode = 0)
106
106
);
107
107
$ deprecationHandler = function ($ type , $ msg , $ file , $ line , $ context = array ()) use (&$ deprecations , $ getMode , $ UtilPrefix , $ inVendors ) {
108
108
$ mode = $ getMode ();
109
- if ((E_USER_DEPRECATED !== $ type && E_DEPRECATED !== $ type ) || DeprecationErrorHandler ::MODE_DISABLED === $ mode ) {
109
+ if ((E_USER_DEPRECATED !== $ type && E_DEPRECATED !== $ type ) || self ::MODE_DISABLED === $ mode ) {
110
110
$ ErrorHandler = $ UtilPrefix .'ErrorHandler ' ;
111
111
112
112
return $ ErrorHandler ::handleError ($ type , $ msg , $ file , $ line , $ context );
113
113
}
114
114
115
115
$ trace = debug_backtrace ();
116
116
$ group = 'other ' ;
117
- $ isVendor = DeprecationErrorHandler:: MODE_WEAK_VENDORS === $ mode && $ inVendors ($ file );
117
+ $ isVendor = $ inVendors ($ file );
118
118
119
119
$ i = \count ($ trace );
120
120
while (1 < $ i && (!isset ($ trace [--$ i ]['class ' ]) || ('ReflectionMethod ' === $ trace [$ i ]['class ' ] || 0 === strpos ($ trace [$ i ]['class ' ], 'PHPUnit_ ' ) || 0 === strpos ($ trace [$ i ]['class ' ], 'PHPUnit \\' )))) {
@@ -131,7 +131,7 @@ public static function register($mode = 0)
131
131
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
132
132
// then we need to use the serialized information to determine
133
133
// if the error has been triggered from vendor code.
134
- $ isVendor = DeprecationErrorHandler:: MODE_WEAK_VENDORS === $ mode && isset ($ parsedMsg ['triggering_file ' ]) && $ inVendors ($ parsedMsg ['triggering_file ' ]);
134
+ $ isVendor = isset ($ parsedMsg ['triggering_file ' ]) && $ inVendors ($ parsedMsg ['triggering_file ' ]);
135
135
} else {
136
136
$ class = isset ($ trace [$ i ]['object ' ]) ? \get_class ($ trace [$ i ]['object ' ]) : $ trace [$ i ]['class ' ];
137
137
$ method = $ trace [$ i ]['function ' ];
@@ -168,13 +168,13 @@ public static function register($mode = 0)
168
168
169
169
exit (1 );
170
170
}
171
- if ('legacy ' !== $ group && DeprecationErrorHandler ::MODE_WEAK !== $ mode ) {
171
+ if ('legacy ' !== $ group && self ::MODE_WEAK !== $ mode ) {
172
172
$ ref = &$ deprecations [$ group ][$ msg ]['count ' ];
173
173
++$ ref ;
174
174
$ ref = &$ deprecations [$ group ][$ msg ][$ class .':: ' .$ method ];
175
175
++$ ref ;
176
176
}
177
- } elseif (DeprecationErrorHandler ::MODE_WEAK !== $ mode ) {
177
+ } elseif (self ::MODE_WEAK !== $ mode ) {
178
178
$ ref = &$ deprecations [$ group ][$ msg ]['count ' ];
179
179
++$ ref ;
180
180
}
@@ -207,7 +207,7 @@ public static function register($mode = 0)
207
207
$ currErrorHandler = set_error_handler ('var_dump ' );
208
208
restore_error_handler ();
209
209
210
- if (DeprecationErrorHandler ::MODE_WEAK === $ mode ) {
210
+ if (self ::MODE_WEAK === $ mode ) {
211
211
$ colorize = function ($ str ) { return $ str ; };
212
212
}
213
213
if ($ currErrorHandler !== $ deprecationHandler ) {
@@ -218,11 +218,7 @@ public static function register($mode = 0)
218
218
return $ b ['count ' ] - $ a ['count ' ];
219
219
};
220
220
221
- $ groups = array ('unsilenced ' , 'remaining ' );
222
- if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $ mode ) {
223
- $ groups [] = 'remaining vendor ' ;
224
- }
225
- array_push ($ groups , 'legacy ' , 'other ' );
221
+ $ groups = array ('unsilenced ' , 'remaining ' , 'remaining vendor ' , 'legacy ' , 'other ' );
226
222
227
223
$ displayDeprecations = function ($ deprecations ) use ($ colorize , $ cmp , $ groups ) {
228
224
foreach ($ groups as $ group ) {
@@ -253,24 +249,34 @@ public static function register($mode = 0)
253
249
};
254
250
255
251
$ displayDeprecations ($ deprecations );
252
+ $ isPassing = function ($ mode , $ deprecations ) {
253
+ if (self ::MODE_WEAK === $ mode ) {
254
+ return true ;
255
+ }
256
+ if (self ::MODE_WEAK_VENDORS === $ mode ) {
257
+ return 0 === $ deprecations ['unsilencedCount ' ] + $ deprecations ['remainingCount ' ] + $ deprecations ['otherCount ' ];
258
+ }
259
+
260
+ return 0 === $ deprecations ['unsilencedCount ' ] + $ deprecations ['remainingCount ' ] + $ deprecations ['remaining vendorCount ' ] + $ deprecations ['otherCount ' ];
261
+ };
256
262
257
263
// store failing status
258
- $ isFailing = DeprecationErrorHandler:: MODE_WEAK !== $ mode && $ mode < $ deprecations[ ' unsilencedCount ' ] + $ deprecations [ ' remainingCount ' ] + $ deprecations [ ' otherCount ' ] ;
264
+ $ passesBeforeShutdown = $ isPassing ( $ mode, $ deprecations) ;
259
265
260
266
// reset deprecations array
261
267
foreach ($ deprecations as $ group => $ arrayOrInt ) {
262
268
$ deprecations [$ group ] = \is_int ($ arrayOrInt ) ? 0 : array ();
263
269
}
264
270
265
- register_shutdown_function (function () use (&$ deprecations , $ isFailing , $ displayDeprecations , $ mode ) {
271
+ register_shutdown_function (function () use (&$ deprecations , $ passesBeforeShutdown , $ displayDeprecations, $ isPassing , $ mode ) {
266
272
foreach ($ deprecations as $ group => $ arrayOrInt ) {
267
273
if (0 < (\is_int ($ arrayOrInt ) ? $ arrayOrInt : \count ($ arrayOrInt ))) {
268
274
echo "Shutdown-time deprecations: \n" ;
269
275
break ;
270
276
}
271
277
}
272
278
$ displayDeprecations ($ deprecations );
273
- if ($ isFailing || DeprecationErrorHandler:: MODE_WEAK !== $ mode && $ mode < $ deprecations[ ' unsilencedCount ' ] + $ deprecations [ ' remainingCount ' ] + $ deprecations [ ' otherCount ' ] ) {
279
+ if (! $ passesBeforeShutdown || ! $ isPassing ( $ mode, $ deprecations) ) {
274
280
exit (1 );
275
281
}
276
282
});
0 commit comments