2020-07-18 18:57:24 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-07-29 01:41:20 +02:00
|
|
|
use Rector\Generic\Rector\ClassMethod\AddReturnTypeDeclarationRector;
|
2020-09-12 23:19:08 +02:00
|
|
|
use Rector\Generic\ValueObject\AddReturnTypeDeclaration;
|
2020-07-18 18:57:24 +02:00
|
|
|
use Rector\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector;
|
|
|
|
use Rector\PHPUnit\Rector\MethodCall\ReplaceAssertArraySubsetRector;
|
|
|
|
use Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsRector;
|
|
|
|
use Rector\PHPUnit\Rector\MethodCall\SpecificAssertInternalTypeRector;
|
2020-08-18 17:57:30 +02:00
|
|
|
use Rector\Renaming\Rector\Name\RenameClassRector;
|
2020-08-25 02:21:00 +02:00
|
|
|
use function Rector\SymfonyPhpConfig\inline_value_objects;
|
2020-07-18 18:57:24 +02:00
|
|
|
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
|
2020-09-12 23:19:08 +02:00
|
|
|
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
|
2020-07-18 18:57:24 +02:00
|
|
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
|
|
|
|
|
|
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
|
|
$containerConfigurator->import(__DIR__ . '/phpunit-exception.php');
|
|
|
|
|
|
|
|
$services = $containerConfigurator->services();
|
|
|
|
|
|
|
|
$services->set(AddParamTypeDeclarationRector::class)
|
2020-07-30 00:43:06 +02:00
|
|
|
->call('configure', [[
|
2020-08-25 02:21:00 +02:00
|
|
|
AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => inline_value_objects([
|
|
|
|
// https://github.com/rectorphp/rector/issues/1024 - no type, $dataName
|
2020-09-12 23:19:08 +02:00
|
|
|
new AddParamTypeDeclaration('PHPUnit\Framework\TestCase', '__construct', 2, ''),
|
2020-08-25 02:21:00 +02:00
|
|
|
]),
|
2020-07-30 00:43:06 +02:00
|
|
|
]]);
|
2020-07-18 18:57:24 +02:00
|
|
|
|
|
|
|
$services->set(SpecificAssertContainsRector::class);
|
|
|
|
|
|
|
|
$services->set(SpecificAssertInternalTypeRector::class);
|
|
|
|
|
|
|
|
$services->set(RenameClassRector::class)
|
2020-07-30 00:43:06 +02:00
|
|
|
->call('configure', [[
|
2020-07-30 01:39:41 +02:00
|
|
|
RenameClassRector::OLD_TO_NEW_CLASSES => [
|
2020-07-30 00:43:06 +02:00
|
|
|
# https://github.com/sebastianbergmann/phpunit/issues/3123
|
|
|
|
'PHPUnit_Framework_MockObject_MockObject' => 'PHPUnit\Framework\MockObject\MockObject',
|
|
|
|
],
|
|
|
|
]]);
|
2020-07-18 18:57:24 +02:00
|
|
|
|
|
|
|
$services->set(AssertEqualsParameterToSpecificMethodsTypeRector::class);
|
|
|
|
|
|
|
|
$services->set(AddReturnTypeDeclarationRector::class)
|
2020-07-30 00:43:06 +02:00
|
|
|
->call('configure', [[
|
2020-08-25 20:34:49 +02:00
|
|
|
AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => inline_value_objects(
|
|
|
|
[
|
2020-09-12 23:19:08 +02:00
|
|
|
new AddReturnTypeDeclaration('PHPUnit\Framework\TestCase', 'setUpBeforeClass', 'void'),
|
|
|
|
new AddReturnTypeDeclaration('PHPUnit\Framework\TestCase', 'setUp', 'void'),
|
|
|
|
new AddReturnTypeDeclaration('PHPUnit\Framework\TestCase', 'assertPreConditions', 'void'),
|
|
|
|
new AddReturnTypeDeclaration('PHPUnit\Framework\TestCase', 'assertPostConditions', 'void'),
|
|
|
|
new AddReturnTypeDeclaration('PHPUnit\Framework\TestCase', 'tearDown', 'void'),
|
|
|
|
new AddReturnTypeDeclaration('PHPUnit\Framework\TestCase', 'tearDownAfterClass', 'void'),
|
|
|
|
new AddReturnTypeDeclaration('PHPUnit\Framework\TestCase', 'onNotSuccessfulTest', 'void'), ]
|
2020-08-25 20:34:49 +02:00
|
|
|
),
|
2020-07-30 00:43:06 +02:00
|
|
|
]]);
|
2020-07-18 18:57:24 +02:00
|
|
|
|
|
|
|
$services->set(ReplaceAssertArraySubsetRector::class);
|
|
|
|
};
|