Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit caf8e6b

Browse filesBrowse files
committed
Always segregate vendor and non vendor deprecations
Even if it does not make the exit code change, this is valuable information. Besides, not doing this reduces the complexity (fewer tests for the weak vendors mode, which I plan to replace with different exit codes). I introduced a new closure for computing whether the build is failing or not, named using positive logic so that things are easier to understand.
1 parent 2ed0c67 commit caf8e6b
Copy full SHA for caf8e6b

File tree

1 file changed

+16
-10
lines changed
Filter options

1 file changed

+16
-10
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+16-10Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function register($mode = 0)
110110

111111
$trace = debug_backtrace(true);
112112
$group = 'other';
113-
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file);
113+
$isVendor = $inVendors($file);
114114

115115
$i = count($trace);
116116
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
@@ -127,7 +127,7 @@ public static function register($mode = 0)
127127
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
128128
// then we need to use the serialized information to determine
129129
// if the error has been triggered from vendor code.
130-
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
130+
$isVendor = isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
131131
} else {
132132
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
133133
$method = $trace[$i]['function'];
@@ -214,11 +214,7 @@ public static function register($mode = 0)
214214
return $b['count'] - $a['count'];
215215
};
216216

217-
$groups = array('unsilenced', 'remaining');
218-
if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) {
219-
$groups[] = 'remaining vendor';
220-
}
221-
array_push($groups, 'legacy', 'other');
217+
$groups = array('unsilenced', 'remaining', 'remaining vendor', 'legacy', 'other');
222218

223219
$displayDeprecations = function ($deprecations) use ($colorize, $cmp, $groups) {
224220
foreach ($groups as $group) {
@@ -249,24 +245,34 @@ public static function register($mode = 0)
249245
};
250246

251247
$displayDeprecations($deprecations);
248+
$isPassing = function ($mode, $deprecations) {
249+
if (DeprecationErrorHandler::MODE_WEAK === $mode) {
250+
return true;
251+
}
252+
if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) {
253+
return 0 === $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount'];
254+
}
255+
256+
return 0 === $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['remaining vendorCount'] + $deprecations['otherCount'];
257+
};
252258

253259
// store failing status
254-
$isFailing = DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount'];
260+
$passesBeforeShutdown = !$isPassing($mode, $deprecations);
255261

256262
// reset deprecations array
257263
foreach ($deprecations as $group => $arrayOrInt) {
258264
$deprecations[$group] = is_int($arrayOrInt) ? 0 : array();
259265
}
260266

261-
register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
267+
register_shutdown_function(function () use (&$deprecations, $passesBeforeShutdown, $displayDeprecations, $isPassing, $mode) {
262268
foreach ($deprecations as $group => $arrayOrInt) {
263269
if (0 < (is_int($arrayOrInt) ? $arrayOrInt : count($arrayOrInt))) {
264270
echo "Shutdown-time deprecations:\n";
265271
break;
266272
}
267273
}
268274
$displayDeprecations($deprecations);
269-
if ($isFailing || DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
275+
if (!$passesBeforeShutdown || !$isPassing($mode, $deprecations)) {
270276
exit(1);
271277
}
272278
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.