Skip to content

Commit 993980b

Browse files
committed
Always show all deprecations except legacy ones
When using any mode but the weak mode, you want your build to fail on some or all deprecations, but it is still nice to be able to see what you could fix without having to change modes.
1 parent f74bda5 commit 993980b

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

src/Symfony/Bridge/PhpUnit/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
4.1.0
5+
-----
6+
7+
* all deprecations but those from tests marked with `@group legacy` are always
8+
displayed, regardless of the mode.
9+
410
4.0.0
511
-----
612

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ public static function register($mode = 0)
111111
$trace = debug_backtrace(true);
112112
$group = 'other';
113113
$isVendor = false;
114-
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file));
115114

116115
$i = count($trace);
117116
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
@@ -128,7 +127,6 @@ public static function register($mode = 0)
128127
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
129128
// then we need to use the serialized information to determine
130129
// if the error has been triggered from vendor code.
131-
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']));
132130
} else {
133131
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
134132
$method = $trace[$i]['function'];
@@ -165,13 +163,13 @@ public static function register($mode = 0)
165163

166164
exit(1);
167165
}
168-
if ('legacy' !== $group && !$isWeak) {
166+
if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) {
169167
$ref = &$deprecations[$group][$msg]['count'];
170168
++$ref;
171169
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
172170
++$ref;
173171
}
174-
} elseif (!$isWeak) {
172+
} elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) {
175173
$ref = &$deprecations[$group][$msg]['count'];
176174
++$ref;
177175
}

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@ Unsilenced deprecation notices (1)
3737
Legacy deprecation notices (1)
3838

3939
Other deprecation notices (1)
40-

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_eval_d_deprecation.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);")
2121
--EXPECTF--
2222

2323
Other deprecation notices (1)
24+
25+
1x: who knows where I come from?

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_phar_deprecation.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ include 'phar://deprecation.phar/deprecation.php';
2323
--EXPECTF--
2424

2525
Other deprecation notices (1)
26+
27+
1x: I come from… afar! :D

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_vendor.phpt

+11
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,19 @@ require __DIR__.'/fake_vendor/acme/lib/deprecation_riddled.php';
2222
--EXPECTF--
2323
Unsilenced deprecation notices (2)
2424

25+
1x: unsilenced foo deprecation
26+
1x in FooTestCase::testLegacyFoo
27+
28+
1x: unsilenced bar deprecation
29+
1x in FooTestCase::testNonLegacyBar
30+
2531
Remaining vendor deprecation notices (1)
2632

33+
1x: silenced bar deprecation
34+
1x in FooTestCase::testNonLegacyBar
35+
2736
Legacy deprecation notices (1)
2837

2938
Other deprecation notices (1)
39+
40+
1x: root deprecation

0 commit comments

Comments
 (0)