Skip to content
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
77 changes: 77 additions & 0 deletions .github/patches/phpunit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
diff --git a/src/Runner/ErrorHandler.php b/src/Runner/ErrorHandler.php
index 54f35aa41..94a2bb600 100644
--- a/src/Runner/ErrorHandler.php
+++ b/src/Runner/ErrorHandler.php
@@ -59,6 +59,11 @@ final class ErrorHandler
private ?int $originalErrorReportingLevel = null;
private readonly Source $source;

+ /**
+ * @var list<array{int, string, string, int}>
+ */
+ private array $globalDeprecations = [];
+
/**
* @var ?array{functions: list<non-empty-string>, methods: list<array{className: class-string, methodName: non-empty-string}>}
*/
@@ -197,6 +202,23 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil
return false;
}

+ public function deprecationHandler(int $errorNumber, string $errorString, string $errorFile, int $errorLine): bool
+ {
+ $this->globalDeprecations[] = [$errorNumber, $errorString, $errorFile, $errorLine];
+
+ return true;
+ }
+
+ public function registerDeprecationHandler(): void
+ {
+ set_error_handler([self::$instance, 'deprecationHandler'], E_USER_DEPRECATED);
+ }
+
+ public function restoreDeprecationHandler(): void
+ {
+ restore_error_handler();
+ }
+
public function enable(): void
{
if ($this->enabled) {
@@ -213,6 +235,7 @@ public function enable(): void

$this->enabled = true;
$this->originalErrorReportingLevel = error_reporting();
+ $this->triggerGlobalDeprecations();

error_reporting($this->originalErrorReportingLevel & self::UNHANDLEABLE_LEVELS);
}
@@ -422,4 +445,11 @@ private function stackTrace(): string

return $buffer;
}
+
+ private function triggerGlobalDeprecations(): void
+ {
+ foreach ($this->globalDeprecations ?? [] as $d) {
+ $this->__invoke(...$d);
+ }
+ }
}
diff --git a/src/TextUI/Application.php b/src/TextUI/Application.php
index ca6da7005..d8965d41b 100644
--- a/src/TextUI/Application.php
+++ b/src/TextUI/Application.php
@@ -178,8 +178,12 @@ public function run(array $argv): int

EventFacade::instance()->seal();

+ ErrorHandler::instance()->registerDeprecationHandler();
+
$testSuite = $this->buildTestSuite($configuration);

+ ErrorHandler::instance()->restoreDeprecationHandler();
+
$this->executeCommandsThatRequireTheTestSuite($configuration, $cliConfiguration, $testSuite);

if ($testSuite->isEmpty() && !$configuration->hasCliArguments() && $configuration->testSuite()->isEmpty()) {
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ jobs:
composer global link .
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Patch phpunit
run: git apply --directory vendor/phpunit/phpunit .github/patches/phpunit.patch
- name: Run PHPUnit tests
run: vendor/bin/phpunit --fail-on-deprecation --display-deprecations

Expand Down Expand Up @@ -906,7 +908,7 @@ jobs:
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run PHPUnit tests
run: vendor/bin/phpunit
run: vendor/bin/phpunit --fail-on-deprecation

behat-symfony-next:
name: Behat (PHP ${{ matrix.php }}) (Symfony dev)
Expand Down
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
</groups>

<source ignoreSuppressionOfDeprecations="true" ignoreIndirectDeprecations="true" baseline="phpunit.baseline.xml">
<deprecationTrigger>
<function>trigger_deprecation</function>
<method>Doctrine\Deprecations\Deprecation::trigger</method>
<method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
</deprecationTrigger>
<include>
<directory>.</directory>
</include>
Expand Down
5 changes: 5 additions & 0 deletions src/Doctrine/Common/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
<method>Doctrine\Deprecations\Deprecation::trigger</method>
<method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
5 changes: 5 additions & 0 deletions src/Doctrine/Odm/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
<method>Doctrine\Deprecations\Deprecation::trigger</method>
<method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
5 changes: 5 additions & 0 deletions src/Doctrine/Orm/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
<method>Doctrine\Deprecations\Deprecation::trigger</method>
<method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/Elasticsearch/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQl/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/HttpCache/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/Hydra/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/JsonApi/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
</testsuites>
<coverage/>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/JsonSchema/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/Laravel/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
</testsuites>
<coverage/>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
5 changes: 5 additions & 0 deletions src/Metadata/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
<method>Doctrine\Deprecations\Deprecation::trigger</method>
<method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/OpenApi/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/RamseyUuid/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/Serializer/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/State/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
</testsuites>
<coverage/>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
3 changes: 3 additions & 0 deletions src/Validator/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</testsuite>
</testsuites>
<source>
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>./</directory>
</include>
Expand Down
Loading