Skip to content

Commit 8ae323b

Browse files
bug symfony#38384 [PhpUnitBridge] Fix Deprecation file when it comes from the TestsListener (fancyweb)
This PR was merged into the 5.1 branch. Discussion ---------- [PhpUnitBridge] Fix Deprecation file when it comes from the TestsListener | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - symfony#38031 caused an unwanted regression: if the frame `class` matches `SymfonyTestsListenerFor` it used to always return, now it continues so the `originClass` and `originMethod` properties are set. Therefore, the deprecation is considered as coming from the test listener. It ends up in the "legacy" group and muted because the test listeners contains the word "Legacy" in their namespaces. Example test: ```php <?php namespace App\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\DependencyInjection\ExtractingEventDispatcher; final class FooTest extends TestCase { public function test(): void { // ExtractingEventDispatcher is @internal new class extends ExtractingEventDispatcher {}; $this->assertTrue(true); } } ``` On 4.4: ``` Other deprecation notices (1) 1x: The "Symfony\Component\EventDispatcher\DependencyInjection\ExtractingEventDispatcher" class is considered internal. It may change without further notice. You should not use it from "Symfony\Component\EventDispatcher\DependencyInjection\ExtractingEventDispatcher@anonymous". ``` On 5.1: ``` Legacy deprecation notices (1) ``` Commits ------- 1ba06a0 [PhpUnitBridge] Fix Deprecation file when it comes from the TestsListener
2 parents 8ea3e7a + 1ba06a0 commit 8ae323b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1313

1414
use PHPUnit\Util\Test;
15+
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
1516

1617
/**
1718
* @internal
@@ -83,6 +84,11 @@ public function __construct($message, array $trace, $file)
8384

8485
return;
8586
}
87+
88+
if (isset($line['class']) && 0 === strpos($line['class'], SymfonyTestsListenerFor::class)) {
89+
return;
90+
}
91+
8692
$this->originClass = isset($line['object']) ? \get_class($line['object']) : $line['class'];
8793
$this->originMethod = $line['function'];
8894
}

0 commit comments

Comments
 (0)