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.
This commit is contained in:
parent
f74bda51eb
commit
9e37873860
@ -1,6 +1,12 @@
|
|||||||
CHANGELOG
|
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
|
4.0.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -110,8 +110,7 @@ class DeprecationErrorHandler
|
|||||||
|
|
||||||
$trace = debug_backtrace(true);
|
$trace = debug_backtrace(true);
|
||||||
$group = 'other';
|
$group = 'other';
|
||||||
$isVendor = false;
|
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file);
|
||||||
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file));
|
|
||||||
|
|
||||||
$i = count($trace);
|
$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\\')))) {
|
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,7 @@ class DeprecationErrorHandler
|
|||||||
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
|
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
|
||||||
// then we need to use the serialized information to determine
|
// then we need to use the serialized information to determine
|
||||||
// if the error has been triggered from vendor code.
|
// 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 {
|
} else {
|
||||||
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
|
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
|
||||||
$method = $trace[$i]['function'];
|
$method = $trace[$i]['function'];
|
||||||
@ -145,7 +144,7 @@ class DeprecationErrorHandler
|
|||||||
|| in_array('legacy', $Test::getGroups($class, $method), true)
|
|| in_array('legacy', $Test::getGroups($class, $method), true)
|
||||||
) {
|
) {
|
||||||
$group = 'legacy';
|
$group = 'legacy';
|
||||||
} elseif (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor) {
|
} elseif ($isVendor) {
|
||||||
$group = 'remaining vendor';
|
$group = 'remaining vendor';
|
||||||
} else {
|
} else {
|
||||||
$group = 'remaining';
|
$group = 'remaining';
|
||||||
@ -165,13 +164,13 @@ class DeprecationErrorHandler
|
|||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if ('legacy' !== $group && !$isWeak) {
|
if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) {
|
||||||
$ref = &$deprecations[$group][$msg]['count'];
|
$ref = &$deprecations[$group][$msg]['count'];
|
||||||
++$ref;
|
++$ref;
|
||||||
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
|
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
|
||||||
++$ref;
|
++$ref;
|
||||||
}
|
}
|
||||||
} elseif (!$isWeak) {
|
} elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) {
|
||||||
$ref = &$deprecations[$group][$msg]['count'];
|
$ref = &$deprecations[$group][$msg]['count'];
|
||||||
++$ref;
|
++$ref;
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,3 @@ Unsilenced deprecation notices (1)
|
|||||||
Legacy deprecation notices (1)
|
Legacy deprecation notices (1)
|
||||||
|
|
||||||
Other deprecation notices (1)
|
Other deprecation notices (1)
|
||||||
|
|
||||||
|
@ -21,3 +21,5 @@ eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);")
|
|||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
|
|
||||||
Other deprecation notices (1)
|
Other deprecation notices (1)
|
||||||
|
|
||||||
|
1x: who knows where I come from?
|
||||||
|
@ -23,3 +23,5 @@ include 'phar://deprecation.phar/deprecation.php';
|
|||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
|
|
||||||
Other deprecation notices (1)
|
Other deprecation notices (1)
|
||||||
|
|
||||||
|
1x: I come from… afar! :D
|
||||||
|
@ -22,8 +22,19 @@ require __DIR__.'/fake_vendor/acme/lib/deprecation_riddled.php';
|
|||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Unsilenced deprecation notices (2)
|
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)
|
Remaining vendor deprecation notices (1)
|
||||||
|
|
||||||
|
1x: silenced bar deprecation
|
||||||
|
1x in FooTestCase::testNonLegacyBar
|
||||||
|
|
||||||
Legacy deprecation notices (1)
|
Legacy deprecation notices (1)
|
||||||
|
|
||||||
Other deprecation notices (1)
|
Other deprecation notices (1)
|
||||||
|
|
||||||
|
1x: root deprecation
|
||||||
|
Reference in New Issue
Block a user