From 44ca13ef409c6248dbbb2faebc895885f81317b1 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 1 Jul 2021 16:52:12 +0200 Subject: [PATCH 1/2] Revert CI workaround for masterminds/html5 Signed-off-by: Alexander M. Turek --- .github/workflows/unit-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index ceffbe3102..6ce52878ac 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -41,7 +41,6 @@ jobs: run: | echo "extensions=mbstring" >> $GITHUB_ENV composer config platform.php 8.0.99 - composer require --dev --no-update masterminds/html5:~2.7.5@dev - name: Setup PHP uses: shivammathur/setup-php@v2 From 5f90fb0fd6b5c5fe7e866f12ae9f617c0a28c578 Mon Sep 17 00:00:00 2001 From: YaFou <33806646+YaFou@users.noreply.github.com> Date: Mon, 28 Jun 2021 18:04:37 +0200 Subject: [PATCH 2/2] [PhpUnitBridge] Fix deprecation handler with PHPUnit 10 --- .../PhpUnit/DeprecationErrorHandler.php | 20 +++++++++++++------ .../DeprecationErrorHandler/Deprecation.php | 5 ++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 19c6691dbe..518a764253 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\PhpUnit; use PHPUnit\Framework\TestResult; +use PHPUnit\Util\Error\Handler; use PHPUnit\Util\ErrorHandler; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation; @@ -51,7 +52,7 @@ class DeprecationErrorHandler ]; private static $isRegistered = false; - private static $isAtLeastPhpUnit83; + private static $errorHandler; /** * Registers and configures the deprecation handler. @@ -335,16 +336,23 @@ class DeprecationErrorHandler private static function getPhpUnitErrorHandler() { - if (!isset(self::$isAtLeastPhpUnit83)) { - self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke'); + if (!$eh = self::$errorHandler) { + if (class_exists(Handler::class)) { + $eh = self::$errorHandler = Handler::class; + } elseif (method_exists(ErrorHandler::class, '__invoke')) { + $eh = self::$errorHandler = ErrorHandler::class; + } else { + return self::$errorHandler = 'PHPUnit\Util\ErrorHandler::handleError'; + } } - if (!self::$isAtLeastPhpUnit83) { - return 'PHPUnit\Util\ErrorHandler::handleError'; + + if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) { + return $eh; } foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) { if (isset($frame['object']) && $frame['object'] instanceof TestResult) { - return new ErrorHandler( + return new $eh( $frame['object']->getConvertDeprecationsToExceptions(), $frame['object']->getConvertErrorsToExceptions(), $frame['object']->getConvertNoticesToExceptions(), diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index fdc898a931..254b84f729 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -13,6 +13,8 @@ namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; +use PHPUnit\Metadata\Api\Groups; +use PHPUnit\Util\Error\Handler; use PHPUnit\Util\Test; use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor; use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader; @@ -192,12 +194,13 @@ class Deprecation } $method = $this->originatingMethod(); + $groups = class_exists(Groups::class) ? [new Groups(), 'groups'] : [Test::class, 'getGroups']; return 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($this->originClass, '\Legacy') - || \in_array('legacy', Test::getGroups($this->originClass, $method), true); + || \in_array('legacy', $groups($this->originClass, $method), true); } /**