Skip to content

Commit f943689

Browse files
committed
[PhpUnitBridge] Move Doctrine deprecations setup to extension
1 parent 8988172 commit f943689

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

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')) {

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)