Skip to content

Always show all deprecations except legacy ones when not weak #25997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Symfony/Bridge/PhpUnit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

4.1.0
-----

* all deprecations but those from tests marked with `@group legacy` are always
displayed when not in `weak` mode.

4.0.0
-----

Expand Down
11 changes: 5 additions & 6 deletions src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public static function register($mode = 0)

$trace = debug_backtrace(true);
$group = 'other';
$isVendor = false;
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file));
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file);

$i = count($trace);
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
Expand All @@ -128,7 +127,7 @@ public static function register($mode = 0)
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
// then we need to use the serialized information to determine
// if the error has been triggered from vendor code.
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']));
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
} else {
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
$method = $trace[$i]['function'];
Expand All @@ -145,7 +144,7 @@ public static function register($mode = 0)
|| in_array('legacy', $Test::getGroups($class, $method), true)
) {
$group = 'legacy';
} elseif (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor) {
} elseif ($isVendor) {
$group = 'remaining vendor';
} else {
$group = 'remaining';
Expand All @@ -165,13 +164,13 @@ public static function register($mode = 0)

exit(1);
}
if ('legacy' !== $group && !$isWeak) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the $isWeak variable is not used anymore, isn't it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, good riddance!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but now $isVendor is always false and $inVendors is never called :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spotted and pushed again yeah :P should have checked the tests before pushing 😅

if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) {
$ref = &$deprecations[$group][$msg]['count'];
++$ref;
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
++$ref;
}
} elseif (!$isWeak) {
} elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) {
$ref = &$deprecations[$group][$msg]['count'];
++$ref;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ Unsilenced deprecation notices (1)
Legacy deprecation notices (1)

Other deprecation notices (1)

Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);")
--EXPECTF--

Other deprecation notices (1)

1x: who knows where I come from?
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ include 'phar://deprecation.phar/deprecation.php';
--EXPECTF--

Other deprecation notices (1)

1x: I come from… afar! :D
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ require __DIR__.'/fake_vendor/acme/lib/deprecation_riddled.php';
--EXPECTF--
Unsilenced deprecation notices (2)

1x: unsilenced foo deprecation
1x in FooTestCase::testLegacyFoo

1x: unsilenced bar deprecation
1x in FooTestCase::testNonLegacyBar

Remaining vendor deprecation notices (1)

1x: silenced bar deprecation
1x in FooTestCase::testNonLegacyBar

Legacy deprecation notices (1)

Other deprecation notices (1)

1x: root deprecation