8000 Merge branch '4.4' into 5.2 · symfony/symfony@c296159 · GitHub
[go: up one dir, main page]

Skip to content

Commit c296159

Browse files
committed
Merge branch '4.4' into 5.2
* 4.4: [PhpUnitBridge] Fix deprecation handler with PHPUnit 10 Revert CI workaround for masterminds/html5
2 parents 1c6de51 + 713f73f commit c296159

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 1 deletio 8000 n
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
run: |
4242
echo "extensions=mbstring" >> $GITHUB_ENV
4343
composer config platform.php 8.0.99
44-
composer require --dev --no-update masterminds/html5:~2.7.5@dev
4544
4645
- name: Setup PHP
4746
uses: shivammathur/setup-php@v2

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

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

1414
use PHPUnit\Framework\TestResult;
15+
use PHPUnit\Util\Error\Handler;
1516
use PHPUnit\Util\ErrorHandler;
1617
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
1718
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
@@ -38,7 +39,7 @@ class DeprecationErrorHandler
3839
private $deprecationGroups = [];
3940

4041
private static $isRegistered = false;
41-
private static $isAtLeastPhpUnit83;
42+
private static $errorHandler;
4243

4344
public function __construct()
4445
{
@@ -341,16 +342,23 @@ private function displayDeprecations($groups, $configuration, $isFailing)
341342

342343
private static function getPhpUnitErrorHandler()
343344
{
344-
if (!isset(self::$isAtLeastPhpUnit83)) {
345-
self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke');
345+
if (!$eh = self::$errorHandler) {
346+
if (class_exists(Handler::class)) {
347+
$eh = self::$errorHandler = Handler::class;
348+
} elseif (method_exists(ErrorHandler::class, '__invoke')) {
349+
$eh = self::$errorHandler = ErrorHandler::class;
350+
} else {
351+
return self::$errorHandler = 'PHPUnit\Util\ErrorHandler::handleError';
352+
}
346353
}
347-
if (!self::$isAtLeastPhpUnit83) {
348-
return 'PHPUnit\Util\ErrorHandler::handleError';
354+
355+
if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) {
356+
return $eh;
349357
}
350358

351359
foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
352360
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
353-
return new ErrorHandler(
361+
return new $eh(
354362
$frame['object']->getConvertDeprecationsToExceptions(),
355363
$frame['object']->getConvertErrorsToExceptions(),
356364
$frame['object']->getConvertNoticesToExceptions(),

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use PHPUnit\Framework\TestSuite;
16+
use PHPUnit\Metadata\Api\Groups;
17+
use PHPUnit\Util\Error\Handler;
1618
use PHPUnit\Util\Test;
1719
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
1820
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
@@ -201,12 +203,13 @@ public function isLegacy()
201203
}
202204

203205
$method = $this->originatingMethod();
206+
$groups = class_exists(Groups::class) ? [new Groups(), 'groups'] : [Test::class, 'getGroups'];
204207

205208
return 0 === strpos($method, 'testLegacy')
206209
|| 0 === strpos($method, 'provideLegacy')
207210
|| 0 === strpos($method, 'getLegacy')
208211
|| strpos($this->originClass, '\Legacy')
209-
|| \in_array('legacy', Test::getGroups($this->originClass, $method), true);
212+
|| \in_array('legacy', $groups($this->originClass, $method), true);
210213
}
211214

212215
/**

0 commit comments

Comments
 (0)
0