Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4af68d9

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 4af68d9

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

src/Symfony/Bridge/PhpUnit/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ 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));
114+
$isVendor = $inVendors($file);
115115

116116
$i = count($trace);
117117
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 +128,7 @@ public static function register($mode = 0)
128128
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
129129
// then we need to use the serialized information to determine
130130
// 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']));
131+
$isVendor = isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
132132
} else {
133133
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
134134
$method = $trace[$i]['function'];
@@ -165,13 +165,13 @@ public static function register($mode = 0)
165165

166166
exit(1);
167167
}
168-
if ('legacy' !== $group && !$isWeak) {
168+
if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) {
169169
$ref = &$deprecations[$group][$msg]['count'];
170170
++$ref;
171171
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
172172
++$ref;
173173
}
174-
} elseif (!$isWeak) {
174+
} elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) {
175175
$ref = &$deprecations[$group][$msg]['count'];
176176
++$ref;
177177
}

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 11 additions & 0 deletions
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)