Merge branch '4.4' into 5.2

* 4.4:
  [PhpUnitBridge] Fix deprecation handler with PHPUnit 10
  Revert CI workaround for masterminds/html5
This commit is contained in:
Alexander M. Turek 2021-07-02 08:24:34 +02:00
commit c296159beb
3 changed files with 18 additions and 8 deletions

View File

@ -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

View File

@ -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;
@ -38,7 +39,7 @@ class DeprecationErrorHandler
private $deprecationGroups = [];
private static $isRegistered = false;
private static $isAtLeastPhpUnit83;
private static $errorHandler;
public function __construct()
{
@ -341,16 +342,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(),

View File

@ -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;
@ -201,12 +203,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);
}
/**