Skip to content

Commit 145fa98

Browse files
minor symfony#61863 [PhpUnitBridge] Move Doctrine deprecations setup to extension (HypeMC)
This PR was merged into the 7.4 branch. Discussion ---------- [PhpUnitBridge] Move Doctrine deprecations setup to extension | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Follow-up to symfony#60645 The `SymfonyExtension::bootstrap()` method seems like a more appropriate place to configure Doctrine deprecations behavior. With this, once support for PHPUnit <10 i dropped, the `bootstrap.php` file can be completely removed. Commits ------- 173dca6 [PhpUnitBridge] Move Doctrine deprecations setup to extension
2 parents 2a9ff61 + 173dca6 commit 145fa98

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/Symfony/Bridge/PhpUnit/SymfonyExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\PhpUnit;
1313

14+
use Doctrine\Deprecations\Deprecation;
1415
use PHPUnit\Event\Code\Test;
1516
use PHPUnit\Event\Code\TestMethod;
1617
use PHPUnit\Event\Test\BeforeTestMethodErrored;
@@ -42,6 +43,10 @@ public function bootstrap(Configuration $configuration, Facade $facade, Paramete
4243
DebugClassLoader::enable();
4344
}
4445

46+
if (class_exists(Deprecation::class)) {
47+
Deprecation::withoutDeduplication();
48+
}
49+
4550
$reader = new AttributeReader();
4651

4752
if ($parameters->has('clock-mock-namespaces')) {

src/Symfony/Bridge/PhpUnit/bootstrap.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
use Doctrine\Deprecations\Deprecation;
1313
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1414

15+
// Skip if we're using PHPUnit >=10
16+
if (class_exists(PHPUnit\Metadata\Metadata::class, false)) {
17+
return;
18+
}
19+
1520
// Detect if we need to serialize deprecations to a file.
16-
if (
17-
// Skip if we're using PHPUnit >=10
18-
!class_exists(PHPUnit\Metadata\Metadata::class)
19-
&& in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')
20-
) {
21+
if (in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
2122
DeprecationErrorHandler::collectDeprecations($file);
2223

2324
return;
@@ -36,10 +37,6 @@
3637
Deprecation::withoutDeduplication();
3738
}
3839

39-
if (
40-
// Skip if we're using PHPUnit >=10
41-
!class_exists(PHPUnit\Metadata\Metadata::class, false)
42-
&& 'disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')
43-
) {
40+
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
4441
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
4542
}

0 commit comments

Comments
 (0)