-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnitBridge] Add type hints #26994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
{ | ||
/** | ||
* {@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; | ||
} | ||
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV6', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have create a TestRunnerForV7 as well. The TestRunnerForV6 should be the same as the previous defined class (i.e without return typehint) and the TestRunnerForV7 with the return typehint There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather have fewer files since adding the type hints even if they are not required is possible, but maybe the naming could be improved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know the Symfony standards regarding naming. I'll let others answer :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for the suffix: let use the lowest number |
||
} | ||
|
||
return $result; | ||
} | ||
if (false) { | ||
class TestRunner | ||
{ | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have create CommandForV7 as well