Add type hints
This makes classes inheriting from phpunit classes compatible with phpunit 7. Fixes #26931
This commit is contained in:
parent
82a95dfb22
commit
6fbcc51566
@ -16,7 +16,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy;
|
|||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class Command extends \PHPUnit_TextUI_Command
|
class CommandForV5 extends \PHPUnit_TextUI_Command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
32
src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php
Normal file
32
src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||||
|
|
||||||
|
use PHPUnit\TextUI\Command as BaseCommand;
|
||||||
|
use PHPUnit\TextUI\TestRunner as BaseRunner;
|
||||||
|
use Symfony\Bridge\PhpUnit\TextUI\TestRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
class CommandForV6 extends BaseCommand
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function createRunner(): BaseRunner
|
||||||
|
{
|
||||||
|
return new TestRunner($this->arguments['loader']);
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy;
|
|||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class TestRunner extends \PHPUnit_TextUI_TestRunner
|
class TestRunnerForV5 extends \PHPUnit_TextUI_TestRunner
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
49
src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php
Normal file
49
src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||||
|
|
||||||
|
use PHPUnit\TextUI\TestRunner as BaseRunner;
|
||||||
|
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
class TestRunnerForV6 extends BaseRunner
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function handleConfiguration(array &$arguments): void
|
||||||
|
{
|
||||||
|
$listener = new SymfonyTestsListener();
|
||||||
|
|
||||||
|
parent::handleConfiguration($arguments);
|
||||||
|
|
||||||
|
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
|
||||||
|
|
||||||
|
$registeredLocally = false;
|
||||||
|
|
||||||
|
foreach ($arguments['listeners'] as $registeredListener) {
|
||||||
|
if ($registeredListener instanceof SymfonyTestsListener) {
|
||||||
|
$registeredListener->globalListenerDisabled();
|
||||||
|
$registeredLocally = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$registeredLocally) {
|
||||||
|
$arguments['listeners'][] = $listener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,24 +11,14 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\TextUI;
|
namespace Symfony\Bridge\PhpUnit\TextUI;
|
||||||
|
|
||||||
use PHPUnit\TextUI\Command as BaseCommand;
|
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\Command', 'Symfony\Bridge\PhpUnit\TextUI\Command');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV5', 'Symfony\Bridge\PhpUnit\TextUI\Command');
|
||||||
} else {
|
} else {
|
||||||
/**
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV6', 'Symfony\Bridge\PhpUnit\TextUI\Command');
|
||||||
* {@inheritdoc}
|
}
|
||||||
*
|
|
||||||
* @internal
|
if (false) {
|
||||||
*/
|
class Command
|
||||||
class Command extends BaseCommand
|
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function createRunner()
|
|
||||||
{
|
|
||||||
return new TestRunner($this->arguments['loader']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,45 +11,14 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\TextUI;
|
namespace Symfony\Bridge\PhpUnit\TextUI;
|
||||||
|
|
||||||
use PHPUnit\TextUI\TestRunner as BaseRunner;
|
|
||||||
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
|
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunner', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV5', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
|
||||||
} else {
|
} else {
|
||||||
/**
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV6', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
|
||||||
* {@inheritdoc}
|
}
|
||||||
*
|
|
||||||
* @internal
|
if (false) {
|
||||||
*/
|
class TestRunner
|
||||||
class TestRunner extends BaseRunner
|
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function handleConfiguration(array &$arguments)
|
|
||||||
{
|
|
||||||
$listener = new SymfonyTestsListener();
|
|
||||||
|
|
||||||
$result = parent::handleConfiguration($arguments);
|
|
||||||
|
|
||||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
|
|
||||||
|
|
||||||
$registeredLocally = false;
|
|
||||||
|
|
||||||
foreach ($arguments['listeners'] as $registeredListener) {
|
|
||||||
if ($registeredListener instanceof SymfonyTestsListener) {
|
|
||||||
$registeredListener->globalListenerDisabled();
|
|
||||||
$registeredLocally = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$registeredLocally) {
|
|
||||||
$arguments['listeners'][] = $listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user