bug #26994 [PhpUnitBridge] Add type hints (greg0ire)
This PR was merged into the 3.4 branch.
Discussion
----------
[PhpUnitBridge] Add type hints
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no (only changed classes marked as internal)
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #26931
| License | MIT
| Doc PR | n/a
This makes classes inheriting from phpunit classes compatible with phpunit 7.
Commits
-------
6fbcc51
Add type hints
This commit is contained in:
commit
ea25fec603
@ -16,7 +16,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Command extends \PHPUnit_TextUI_Command
|
||||
class CommandForV5 extends \PHPUnit_TextUI_Command
|
||||
{
|
||||
/**
|
||||
* {@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
|
||||
*/
|
||||
class TestRunner extends \PHPUnit_TextUI_TestRunner
|
||||
class TestRunnerForV5 extends \PHPUnit_TextUI_TestRunner
|
||||
{
|
||||
/**
|
||||
* {@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;
|
||||
|
||||
use PHPUnit\TextUI\Command as BaseCommand;
|
||||
|
||||
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 {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Command extends BaseCommand
|
||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV6', 'Symfony\Bridge\PhpUnit\TextUI\Command');
|
||||
}
|
||||
|
||||
if (false) {
|
||||
class Command
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createRunner()
|
||||
{
|
||||
return new TestRunner($this->arguments['loader']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,45 +11,14 @@
|
||||
|
||||
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', '<')) {
|
||||
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 {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TestRunner extends BaseRunner
|
||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV6', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
|
||||
}
|
||||
|
||||
if (false) {
|
||||
class TestRunner
|
||||
{
|
||||
/**
|
||||
* {@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