Updated Rector to commit a10ddea5d14f8fbdf21366dbfd20defef01f64db

a10ddea5d1 let phpunit handle its own empty method rule
This commit is contained in:
Tomas Votruba 2023-07-13 10:52:04 +00:00
parent af5d6b0384
commit 98ae4430e1
21 changed files with 62 additions and 549 deletions

View File

@ -45,7 +45,6 @@ use Rector\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchForAssignR
use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([
UnwrapFutureCompatibleIfPhpVersionRector::class,
@ -71,7 +70,6 @@ return static function (RectorConfig $rectorConfig) : void {
RemoveUnreachableStatementRector::class,
SimplifyIfElseWithSameContentRector::class,
TernaryToBooleanOrFalseToBooleanAndRector::class,
RemoveEmptyTestMethodRector::class,
RemoveDeadTryCatchRector::class,
RemoveUnusedVariableAssignRector::class,
RemoveUnusedNonEmptyArrayBeforeForeachRector::class,

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '05c9d9a6bcfbf2d28bb301aa8c3f64709a8e2395';
public const PACKAGE_VERSION = 'a10ddea5d14f8fbdf21366dbfd20defef01f64db';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-13 10:23:50';
public const RELEASE_DATE = '2023-07-13 12:47:08';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit7fb1258a1a3e36eb852c159165a1255f::getLoader();
return ComposerAutoloaderInit23ef1dd03a9ef5d16ccce68534cb806c::getLoader();

View File

@ -2090,13 +2090,15 @@ return array(
'Rector\\PHPStanStaticTypeMapper\\Utils\\TypeUnwrapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php',
'Rector\\PHPStanStaticTypeMapper\\ValueObject\\UnionTypeAnalysis' => $baseDir . '/packages/PHPStanStaticTypeMapper/ValueObject/UnionTypeAnalysis.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\ClassMethod\\DataProviderAnnotationToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\ClassMethod\\DependsAnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\ClassMethod\\TestWithAnnotationToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\AnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\CoversAnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\AddSeeTestAnnotationRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/AddSeeTestAnnotationRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\ConstructClassMethodToSetUpTestCaseRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\PreferPHPUnitThisCallRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/PreferPHPUnitThisCallRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\YieldDataProviderRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/YieldDataProviderRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => $vendorDir . '/rector/rector-phpunit/src/CodeQuality/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\MethodCall\\AssertCompareToSpecificMethodRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\MethodCall\\AssertComparisonToSpecificMethodRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\MethodCall\\AssertEqualsToSameRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector.php',
@ -2121,13 +2123,8 @@ return array(
'Rector\\PHPUnit\\NodeAnalyzer\\ParamAndArgFromArrayResolver' => $vendorDir . '/rector/rector-phpunit/src/NodeAnalyzer/ParamAndArgFromArrayResolver.php',
'Rector\\PHPUnit\\NodeAnalyzer\\SetUpMethodDecorator' => $vendorDir . '/rector/rector-phpunit/src/NodeAnalyzer/SetUpMethodDecorator.php',
'Rector\\PHPUnit\\NodeAnalyzer\\TestsNodeAnalyzer' => $vendorDir . '/rector/rector-phpunit/src/NodeAnalyzer/TestsNodeAnalyzer.php',
'Rector\\PHPUnit\\NodeFactory\\ArgumentShiftingFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ArgumentShiftingFactory.php',
'Rector\\PHPUnit\\NodeFactory\\AssertCallFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/AssertCallFactory.php',
'Rector\\PHPUnit\\NodeFactory\\DataProviderClassMethodFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/DataProviderClassMethodFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionCodeFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionCodeFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMessageFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMessageRegExpFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageRegExpFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMethodCallFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php',
'Rector\\PHPUnit\\NodeFinder\\DataProviderClassMethodFinder' => $vendorDir . '/rector/rector-phpunit/src/NodeFinder/DataProviderClassMethodFinder.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\Class_\\AddProphecyTraitRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit100/Rector/Class_/AddProphecyTraitRector.php',
@ -2148,11 +2145,8 @@ return array(
'Rector\\PHPUnit\\PhpDoc\\DataProviderMethodRenamer' => $vendorDir . '/rector/rector-phpunit/src/PhpDoc/DataProviderMethodRenamer.php',
'Rector\\PHPUnit\\PhpDoc\\PhpDocValueToNodeMapper' => $vendorDir . '/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\CreateMockToAnonymousClassRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\DependsAnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\RemoveEmptyTestMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/RemoveEmptyTestMethodRector.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\ReplaceTestAnnotationWithPrefixedFunctionRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\TryCatchToExpectExceptionRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\AnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/AnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ArrayArgumentToDataProviderRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitSelfCallRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/PreferPHPUnitSelfCallRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ProphecyPHPDocRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/ProphecyPHPDocRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit7fb1258a1a3e36eb852c159165a1255f
class ComposerAutoloaderInit23ef1dd03a9ef5d16ccce68534cb806c
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit7fb1258a1a3e36eb852c159165a1255f
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit7fb1258a1a3e36eb852c159165a1255f', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit23ef1dd03a9ef5d16ccce68534cb806c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit7fb1258a1a3e36eb852c159165a1255f', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit23ef1dd03a9ef5d16ccce68534cb806c', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit23ef1dd03a9ef5d16ccce68534cb806c::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit23ef1dd03a9ef5d16ccce68534cb806c::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f
class ComposerStaticInit23ef1dd03a9ef5d16ccce68534cb806c
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2343,13 +2343,15 @@ class ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f
'Rector\\PHPStanStaticTypeMapper\\Utils\\TypeUnwrapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php',
'Rector\\PHPStanStaticTypeMapper\\ValueObject\\UnionTypeAnalysis' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/ValueObject/UnionTypeAnalysis.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\ClassMethod\\DataProviderAnnotationToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\ClassMethod\\DependsAnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\ClassMethod\\TestWithAnnotationToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\AnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\CoversAnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\AddSeeTestAnnotationRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/AddSeeTestAnnotationRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\ConstructClassMethodToSetUpTestCaseRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\PreferPHPUnitThisCallRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/PreferPHPUnitThisCallRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\YieldDataProviderRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/YieldDataProviderRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/CodeQuality/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\MethodCall\\AssertCompareToSpecificMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\MethodCall\\AssertComparisonToSpecificMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php',
'Rector\\PHPUnit\\CodeQuality\\Rector\\MethodCall\\AssertEqualsToSameRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector.php',
@ -2374,13 +2376,8 @@ class ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f
'Rector\\PHPUnit\\NodeAnalyzer\\ParamAndArgFromArrayResolver' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeAnalyzer/ParamAndArgFromArrayResolver.php',
'Rector\\PHPUnit\\NodeAnalyzer\\SetUpMethodDecorator' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeAnalyzer/SetUpMethodDecorator.php',
'Rector\\PHPUnit\\NodeAnalyzer\\TestsNodeAnalyzer' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeAnalyzer/TestsNodeAnalyzer.php',
'Rector\\PHPUnit\\NodeFactory\\ArgumentShiftingFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ArgumentShiftingFactory.php',
'Rector\\PHPUnit\\NodeFactory\\AssertCallFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/AssertCallFactory.php',
'Rector\\PHPUnit\\NodeFactory\\DataProviderClassMethodFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/DataProviderClassMethodFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionCodeFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionCodeFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMessageFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMessageRegExpFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageRegExpFactory.php',
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMethodCallFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php',
'Rector\\PHPUnit\\NodeFinder\\DataProviderClassMethodFinder' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFinder/DataProviderClassMethodFinder.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\Class_\\AddProphecyTraitRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit100/Rector/Class_/AddProphecyTraitRector.php',
@ -2401,11 +2398,8 @@ class ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f
'Rector\\PHPUnit\\PhpDoc\\DataProviderMethodRenamer' => __DIR__ . '/..' . '/rector/rector-phpunit/src/PhpDoc/DataProviderMethodRenamer.php',
'Rector\\PHPUnit\\PhpDoc\\PhpDocValueToNodeMapper' => __DIR__ . '/..' . '/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\CreateMockToAnonymousClassRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\DependsAnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\RemoveEmptyTestMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/RemoveEmptyTestMethodRector.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\ReplaceTestAnnotationWithPrefixedFunctionRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php',
'Rector\\PHPUnit\\Rector\\ClassMethod\\TryCatchToExpectExceptionRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\AnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/AnnotationWithValueToAttributeRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ArrayArgumentToDataProviderRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitSelfCallRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/PreferPHPUnitSelfCallRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ProphecyPHPDocRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/ProphecyPHPDocRector.php',
@ -3066,9 +3060,9 @@ class ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7fb1258a1a3e36eb852c159165a1255f::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit23ef1dd03a9ef5d16ccce68534cb806c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit23ef1dd03a9ef5d16ccce68534cb806c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit23ef1dd03a9ef5d16ccce68534cb806c::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2049,12 +2049,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "ef309ff307ea750f6b0d4f798cf1c43b58cebe38"
"reference": "290e3d1653738162fdb2a50396d2c5d729829ff3"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/ef309ff307ea750f6b0d4f798cf1c43b58cebe38",
"reference": "ef309ff307ea750f6b0d4f798cf1c43b58cebe38",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/290e3d1653738162fdb2a50396d2c5d729829ff3",
"reference": "290e3d1653738162fdb2a50396d2c5d729829ff3",
"shasum": ""
},
"require": {
@ -2082,7 +2082,7 @@
"tomasvotruba\/type-coverage": "^0.1",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-07-13T10:18:28+00:00",
"time": "2023-07-13T10:41:58+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3482059'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 734960f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main ef309ff'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e788554'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3482059'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 734960f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 290e3d1'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e788554'));
private function __construct()
{
}

View File

@ -6,11 +6,11 @@ namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\TestWithAnnotationToAttributeRector;
use Rector\PHPUnit\Rector\Class_\AnnotationWithValueToAttributeRector;
use Rector\PHPUnit\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector;
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([

View File

@ -1,4 +1,4 @@
# 50 Rules Overview
# 48 Rules Overview
## AddDoesNotPerformAssertionToNonAssertingTestRector
@ -27,7 +27,7 @@ Tests without assertion will have `@doesNotPerformAssertion`
Add Prophecy trait for method using `$this->prophesize()`
- class: [`Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector`](../src/Rector/Class_/AddProphecyTraitRector.php)
- class: [`Rector\PHPUnit\PHPUnit100\Rector\Class_\AddProphecyTraitRector`](../rules/PHPUnit100/Rector/Class_/AddProphecyTraitRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -50,7 +50,7 @@ Add Prophecy trait for method using `$this->prophesize()`
Add `@see` annotation test of the class for faster jump to test. Make it FQN, so it stays in the annotation, not in the PHP source code.
- class: [`Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector`](../src/Rector/Class_/AddSeeTestAnnotationRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector`](../rules/CodeQuality/Rector/Class_/AddSeeTestAnnotationRector.php)
```diff
+/**
@ -171,7 +171,7 @@ return static function (RectorConfig $rectorConfig): void {
Turns vague php-only method in PHPUnit TestCase to more specific
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector`](../src/Rector/MethodCall/AssertCompareToSpecificMethodRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertCompareToSpecificMethodRector`](../rules/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector.php)
```diff
-$this->assertSame(10, count($anything), "message");
@ -191,7 +191,7 @@ Turns vague php-only method in PHPUnit TestCase to more specific
Turns comparison operations to their method name alternatives in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector`](../src/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector`](../rules/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php)
```diff
-$this->assertTrue($foo === $bar, "message");
@ -240,7 +240,7 @@ Change `assertEquals()/assertNotEquals()` method parameters to new specific alte
Turns `assertEquals()` into stricter `assertSame()` for scalar values in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector`](../src/Rector/MethodCall/AssertEqualsToSameRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector`](../rules/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector.php)
```diff
-$this->assertEquals(2, $result);
@ -253,7 +253,7 @@ Turns `assertEquals()` into stricter `assertSame()` for scalar values in PHPUnit
Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector`](../src/Rector/MethodCall/AssertFalseStrposToContainsRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertFalseStrposToContainsRector`](../rules/CodeQuality/Rector/MethodCall/AssertFalseStrposToContainsRector.php)
```diff
-$this->assertFalse(strpos($anything, "foo"), "message");
@ -266,7 +266,7 @@ Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUni
Turns instanceof comparisons to their method name alternatives in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertInstanceOfComparisonRector`](../src/Rector/MethodCall/AssertInstanceOfComparisonRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertInstanceOfComparisonRector`](../rules/CodeQuality/Rector/MethodCall/AssertInstanceOfComparisonRector.php)
```diff
-$this->assertTrue($foo instanceof Foo, "message");
@ -286,7 +286,7 @@ Turns instanceof comparisons to their method name alternatives in PHPUnit TestCa
Turns isset comparisons to their method name alternatives in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector`](../src/Rector/MethodCall/AssertIssetToSpecificMethodRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertIssetToSpecificMethodRector`](../rules/CodeQuality/Rector/MethodCall/AssertIssetToSpecificMethodRector.php)
```diff
-$this->assertTrue(isset($anything->foo));
@ -306,7 +306,7 @@ Turns isset comparisons to their method name alternatives in PHPUnit TestCase
Turns not-operator comparisons to their method name alternatives in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertNotOperatorRector`](../src/Rector/MethodCall/AssertNotOperatorRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertNotOperatorRector`](../rules/CodeQuality/Rector/MethodCall/AssertNotOperatorRector.php)
```diff
-$this->assertTrue(!$foo, "message");
@ -326,7 +326,7 @@ Turns not-operator comparisons to their method name alternatives in PHPUnit Test
Turns `property_exists` comparisons to their method name alternatives in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertPropertyExistsRector`](../src/Rector/MethodCall/AssertPropertyExistsRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertPropertyExistsRector`](../rules/CodeQuality/Rector/MethodCall/AssertPropertyExistsRector.php)
```diff
-$this->assertFalse(property_exists(new Class, "property"));
@ -341,7 +341,7 @@ Turns `property_exists` comparisons to their method name alternatives in PHPUnit
Turns `preg_match` comparisons to their method name alternatives in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertRegExpRector`](../src/Rector/MethodCall/AssertRegExpRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertRegExpRector`](../rules/CodeQuality/Rector/MethodCall/AssertRegExpRector.php)
```diff
-$this->assertSame(1, preg_match("/^Message for ".*"\.$/", $string), $message);
@ -374,7 +374,7 @@ Turns `assertIsNotResource()` into stricter `assertIsClosedResource()` for resou
Turns same bool and null comparisons to their method name alternatives in PHPUnit TestCase
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector`](../src/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector`](../rules/CodeQuality/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php)
```diff
-$this->assertSame(null, $anything);
@ -394,7 +394,7 @@ Turns same bool and null comparisons to their method name alternatives in PHPUni
Change `$this->assertSame(true,` ...) to `assertTrue()`
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector`](../src/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector`](../rules/CodeQuality/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -416,7 +416,7 @@ Change `$this->assertSame(true,` ...) to `assertTrue()`
Turns true/false comparisons to their method name alternatives in PHPUnit TestCase when possible
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector`](../src/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector`](../rules/CodeQuality/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php)
```diff
-$this->assertTrue(is_readable($readmeFile), "message");
@ -429,7 +429,7 @@ Turns true/false comparisons to their method name alternatives in PHPUnit TestCa
Change `__construct()` method in tests of `PHPUnit\Framework\TestCase` to `setUp()`, to prevent dangerous override
- class: [`Rector\PHPUnit\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector`](../src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector`](../rules/CodeQuality/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -455,7 +455,7 @@ Change `__construct()` method in tests of `PHPUnit\Framework\TestCase` to `setUp
Change covers annotations with value to attribute
- class: [`Rector\PHPUnit\Rector\Class_\CoversAnnotationWithValueToAttributeRector`](../src/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php)
- class: [`Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector`](../rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -513,7 +513,7 @@ Change `$this->createMock()` with methods to direct anonymous class
Change dataProvider annotations to attribute
- class: [`Rector\PHPUnit\Rector\ClassMethod\DataProviderAnnotationToAttributeRector`](../src/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php)
- class: [`Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector`](../rules/AnnotationsToAttributes/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -607,7 +607,7 @@ Changes ``@expectedException` annotations to `expectException*()` methods
Use explicit API for expecting PHP errors, warnings, and notices
- class: [`Rector\PHPUnit\Rector\MethodCall\ExplicitPhpErrorApiRector`](../src/Rector/MethodCall/ExplicitPhpErrorApiRector.php)
- class: [`Rector\PHPUnit\PHPUnit90\Rector\MethodCall\ExplicitPhpErrorApiRector`](../rules/PHPUnit90/Rector/MethodCall/ExplicitPhpErrorApiRector.php)
```diff
final class SomeTest extends \PHPUnit\Framework\TestCase
@ -697,7 +697,7 @@ Changes PHPUnit calls from `$this->assert*()` to self::assert*()
Changes PHPUnit calls from self::assert*() to `$this->assert*()`
- class: [`Rector\PHPUnit\Rector\Class_\PreferPHPUnitThisCallRector`](../src/Rector/Class_/PreferPHPUnitThisCallRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector`](../rules/CodeQuality/Rector/Class_/PreferPHPUnitThisCallRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -718,7 +718,7 @@ Changes PHPUnit calls from self::assert*() to `$this->assert*()`
Turns PHPUnit TestCase assertObjectHasAttribute into `property_exists` comparisons
- class: [`Rector\PHPUnit\Rector\MethodCall\PropertyExistsWithoutAssertRector`](../src/Rector/MethodCall/PropertyExistsWithoutAssertRector.php)
- class: [`Rector\PHPUnit\PHPUnit100\Rector\MethodCall\PropertyExistsWithoutAssertRector`](../rules/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector.php)
```diff
-$this->assertClassHasAttribute("property", "Class");
@ -807,7 +807,7 @@ Remove empty test methods
Remove `expect($this->any())` from mocks as it has no added value
- class: [`Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector`](../src/Rector/MethodCall/RemoveExpectAnyFromMockRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\RemoveExpectAnyFromMockRector`](../rules/CodeQuality/Rector/MethodCall/RemoveExpectAnyFromMockRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -831,7 +831,7 @@ Remove `expect($this->any())` from mocks as it has no added value
Remove `"setMethods()"` method as never used
- class: [`Rector\PHPUnit\Rector\MethodCall\RemoveSetMethodsMethodCallRector`](../src/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\RemoveSetMethodsMethodCallRector`](../rules/CodeQuality/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -849,30 +849,6 @@ Remove `"setMethods()"` method as never used
<br>
## ReplaceAssertArraySubsetWithDmsPolyfillRector
Change `assertArraySubset()` to static call of DMS\PHPUnitExtensions\ArraySubset\Assert
- class: [`Rector\PHPUnit\Rector\MethodCall\ReplaceAssertArraySubsetWithDmsPolyfillRector`](../src/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php)
```diff
use PHPUnit\Framework\TestCase;
class SomeClass extends TestCase
{
public function test()
{
- self::assertArraySubset(['bar' => 0], ['bar' => '0'], true);
+ \DMS\PHPUnitExtensions\ArraySubset\Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true);
- $this->assertArraySubset(['bar' => 0], ['bar' => '0'], true);
+ \DMS\PHPUnitExtensions\ArraySubset\Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true);
}
}
```
<br>
## ReplaceTestAnnotationWithPrefixedFunctionRector
Replace `@test` with prefixed function
@ -899,7 +875,7 @@ Replace `@test` with prefixed function
Simplify unnecessary foreach check of instances
- class: [`Rector\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector`](../src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\Foreach_\SimplifyForeachInstanceOfRector`](../src/CodeQuality/Rector/Foreach_/SimplifyForeachInstanceOfRector.php)
```diff
-foreach ($foos as $foo) {
@ -935,7 +911,7 @@ Change `assertContains()/assertNotContains()` method to new string and iterable
Change `assertContains()/assertNotContains()` with non-strict comparison to new specific alternatives
- class: [`Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsWithoutIdentityRector`](../src/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php)
- class: [`Rector\PHPUnit\PHPUnit90\Rector\MethodCall\SpecificAssertContainsWithoutIdentityRector`](../rules/PHPUnit90/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php)
```diff
-final class SomeTest extends \PHPUnit\Framework\TestCase
@ -958,7 +934,7 @@ Change `assertContains()/assertNotContains()` with non-strict comparison to new
Change `assertInternalType()/assertNotInternalType()` method to new specific alternatives
- class: [`Rector\PHPUnit\PHPUnit80\Rector\MethodCall\SpecificAssertInternalTypeRector`](../src/PHPUnit80/Rector/MethodCall/SpecificAssertInternalTypeRector.php)
- class: [`Rector\PHPUnit\PHPUnit80\Rector\MethodCall\SpecificAssertInternalTypeRector`](../rules/PHPUnit80/Rector/MethodCall/SpecificAssertInternalTypeRector.php)
```diff
final class SomeTest extends \PHPUnit\Framework\TestCase
@ -980,7 +956,7 @@ Change `assertInternalType()/assertNotInternalType()` method to new specific alt
Change data provider methods to static
- class: [`Rector\PHPUnit\Rector\Class_\StaticDataProviderClassMethodRector`](../src/Rector/Class_/StaticDataProviderClassMethodRector.php)
- class: [`Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector`](../rules/PHPUnit100/Rector/Class_/StaticDataProviderClassMethodRector.php)
```diff
use PHPUnit\Framework\TestCase;
@ -1008,7 +984,7 @@ Change data provider methods to static
Refactor "*TestListener.php" to particular "*Hook.php" files
- class: [`Rector\PHPUnit\Rector\Class_\TestListenerToHooksRector`](../src/Rector/Class_/TestListenerToHooksRector.php)
- class: [`Rector\PHPUnit\PHPUnit90\Rector\Class_\TestListenerToHooksRector`](../rules/PHPUnit90/Rector/Class_/TestListenerToHooksRector.php)
```diff
namespace App\Tests;
@ -1092,31 +1068,11 @@ Change `@testWith()` annotation to #[TestWith] attribute
<br>
## TryCatchToExpectExceptionRector
Turns try/catch to `expectException()` call
- class: [`Rector\PHPUnit\Rector\ClassMethod\TryCatchToExpectExceptionRector`](../src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php)
```diff
-try {
- $someService->run();
-} catch (Throwable $exception) {
- $this->assertInstanceOf(RuntimeException::class, $e);
- $this->assertContains('There was an error executing the following script', $e->getMessage());
-}
+$this->expectException(RuntimeException::class);
+$this->expectExceptionMessage('There was an error executing the following script');
+$someService->run();
```
<br>
## UseSpecificWillMethodRector
Changes `$mock->will()` call to more specific method
- class: [`Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector`](../src/Rector/MethodCall/UseSpecificWillMethodRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\UseSpecificWillMethodRector`](../rules/CodeQuality/Rector/MethodCall/UseSpecificWillMethodRector.php)
```diff
class SomeClass extends PHPUnit\Framework\TestCase
@ -1138,7 +1094,7 @@ Changes `$mock->will()` call to more specific method
Changes `->with()` to more specific method
- class: [`Rector\PHPUnit\Rector\MethodCall\UseSpecificWithMethodRector`](../src/Rector/MethodCall/UseSpecificWithMethodRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\MethodCall\UseSpecificWithMethodRector`](../rules/CodeQuality/Rector/MethodCall/UseSpecificWithMethodRector.php)
```diff
class SomeClass extends PHPUnit\Framework\TestCase
@ -1161,7 +1117,7 @@ Changes `->with()` to more specific method
Turns array return to yield in data providers
- class: [`Rector\PHPUnit\Rector\Class_\YieldDataProviderRector`](../src/Rector/Class_/YieldDataProviderRector.php)
- class: [`Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector`](../rules/CodeQuality/Rector/Class_/YieldDataProviderRector.php)
```diff
use PHPUnit\Framework\TestCase;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\Rector\ClassMethod;
namespace Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
@ -18,7 +18,7 @@ use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\PHPUnit\Tests\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector\DependsAnnotationWithValueToAttributeRectorTest
* @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector\DependsAnnotationWithValueToAttributeRectorTest
*/
final class DependsAnnotationWithValueToAttributeRector extends AbstractRector implements MinPhpVersionInterface
{

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\Rector\Class_;
namespace Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_;
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
@ -20,7 +20,7 @@ use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202307\Webmozart\Assert\Assert;
/**
* @see \Rector\PHPUnit\Tests\Rector\Class_\AnnotationWithValueToAttributeRector\AnnotationWithValueToAttributeRectorTest
* @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector\AnnotationWithValueToAttributeRectorTest
*/
final class AnnotationWithValueToAttributeRector extends AbstractRector implements ConfigurableRectorInterface, MinPhpVersionInterface
{

View File

@ -13,7 +13,7 @@ use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\PHPUnit\Tests\Rector\Foreach_\SimplifyForeachInstanceOfRector\SimplifyForeachInstanceOfRectorTest
* @see \Rector\PHPUnit\Tests\CodeQuality\Rector\Foreach_\SimplifyForeachInstanceOfRector\SimplifyForeachInstanceOfRectorTest
*/
final class SimplifyForeachInstanceOfRector extends AbstractRector
{

View File

@ -86,14 +86,6 @@ final class TestsNodeAnalyzer
/** @var StaticCall|MethodCall $node */
return $this->nodeNameResolver->isName($node->name, $name);
}
public function isInPHPUnitMethodCallName(Node $node, string $name) : bool
{
if (!$this->isPHPUnitTestCaseCall($node)) {
return \false;
}
/** @var StaticCall|MethodCall $node */
return $this->nodeNameResolver->isName($node->name, $name);
}
/**
* @param string[] $names
*/

View File

@ -1,24 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\NodeFactory;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Identifier;
final class ArgumentShiftingFactory
{
public function removeAllButFirstArgMethodCall(MethodCall $methodCall, string $methodName) : void
{
if ($methodCall->isFirstClassCallable()) {
return;
}
$methodCall->name = new Identifier($methodName);
foreach (\array_keys($methodCall->getArgs()) as $i) {
// keep first arg
if ($i === 0) {
continue;
}
unset($methodCall->args[$i]);
}
}
}

View File

@ -1,55 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\NodeFactory;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
final class ExpectExceptionCodeFactory
{
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory
*/
private $argumentShiftingFactory;
/**
* @readonly
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
*/
private $testsNodeAnalyzer;
public function __construct(NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, TestsNodeAnalyzer $testsNodeAnalyzer)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->argumentShiftingFactory = $argumentShiftingFactory;
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
}
public function create(MethodCall $methodCall, Variable $exceptionVariable) : ?MethodCall
{
if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($methodCall, ['assertSame', 'assertEquals'])) {
return null;
}
if ($methodCall->isFirstClassCallable()) {
return null;
}
$secondArgument = $methodCall->getArgs()[1]->value;
if (!$secondArgument instanceof MethodCall) {
return null;
}
// looking for "$exception->getMessage()"
if (!$this->nodeNameResolver->areNamesEqual($secondArgument->var, $exceptionVariable)) {
return null;
}
if (!$this->nodeNameResolver->isName($secondArgument->name, 'getCode')) {
return null;
}
$this->argumentShiftingFactory->removeAllButFirstArgMethodCall($methodCall, 'expectExceptionCode');
return $methodCall;
}
}

View File

@ -1,45 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\NodeFactory;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
final class ExpectExceptionFactory
{
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
*/
private $testsNodeAnalyzer;
public function __construct(NodeNameResolver $nodeNameResolver, TestsNodeAnalyzer $testsNodeAnalyzer)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
}
public function create(MethodCall $methodCall, Variable $variable) : ?MethodCall
{
if (!$this->testsNodeAnalyzer->isInPHPUnitMethodCallName($methodCall, 'assertInstanceOf')) {
return null;
}
if ($methodCall->isFirstClassCallable()) {
return null;
}
$argumentVariableName = $this->nodeNameResolver->getName($methodCall->getArgs()[1]->value);
if ($argumentVariableName === null) {
return null;
}
// is na exception variable
if (!$this->nodeNameResolver->isName($variable, $argumentVariableName)) {
return null;
}
return new MethodCall($methodCall->var, 'expectException', [$methodCall->getArgs()[0]]);
}
}

View File

@ -1,61 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\NodeFactory;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
final class ExpectExceptionMessageFactory
{
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory
*/
private $argumentShiftingFactory;
/**
* @readonly
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
*/
private $nodeComparator;
/**
* @readonly
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
*/
private $testsNodeAnalyzer;
public function __construct(NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, NodeComparator $nodeComparator, TestsNodeAnalyzer $testsNodeAnalyzer)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->argumentShiftingFactory = $argumentShiftingFactory;
$this->nodeComparator = $nodeComparator;
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
}
public function create(MethodCall $methodCall, Variable $exceptionVariable) : ?MethodCall
{
if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($methodCall, ['assertSame', 'assertEquals'])) {
return null;
}
if ($methodCall->isFirstClassCallable()) {
return null;
}
$secondArgument = $methodCall->getArgs()[1]->value;
if (!$secondArgument instanceof MethodCall) {
return null;
}
if (!$this->nodeComparator->areNodesEqual($secondArgument->var, $exceptionVariable)) {
return null;
}
if (!$this->nodeNameResolver->isName($secondArgument->name, 'getMessage')) {
return null;
}
$this->argumentShiftingFactory->removeAllButFirstArgMethodCall($methodCall, 'expectExceptionMessage');
return $methodCall;
}
}

View File

@ -1,69 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\NodeFactory;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
final class ExpectExceptionMessageRegExpFactory
{
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory
*/
private $argumentShiftingFactory;
/**
* @readonly
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
*/
private $nodeComparator;
/**
* @readonly
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
*/
private $testsNodeAnalyzer;
public function __construct(NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, NodeComparator $nodeComparator, TestsNodeAnalyzer $testsNodeAnalyzer)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->argumentShiftingFactory = $argumentShiftingFactory;
$this->nodeComparator = $nodeComparator;
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
}
public function create(MethodCall $methodCall, Variable $exceptionVariable) : ?MethodCall
{
if (!$this->testsNodeAnalyzer->isInPHPUnitMethodCallName($methodCall, 'assertContains')) {
return null;
}
if ($methodCall->isFirstClassCallable()) {
return null;
}
$secondArgument = $methodCall->getArgs()[1]->value;
if (!$secondArgument instanceof MethodCall) {
return null;
}
// looking for "$exception->getMessage()"
if (!$this->nodeComparator->areNodesEqual($secondArgument->var, $exceptionVariable)) {
return null;
}
if (!$this->nodeNameResolver->isName($secondArgument->name, 'getMessage')) {
return null;
}
$this->argumentShiftingFactory->removeAllButFirstArgMethodCall($methodCall, 'expectExceptionMessageRegExp');
// put regex between "#...#" to create match
$firstArg = $methodCall->getArgs()[0];
if ($firstArg->value instanceof String_) {
$oldString = $firstArg->value;
$firstArg->value = new String_('#' . \preg_quote($oldString->value, '#') . '#');
}
return $methodCall;
}
}

View File

@ -1,167 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\TryCatch;
use Rector\Core\Rector\AbstractRector;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\PHPUnit\NodeFactory\ExpectExceptionCodeFactory;
use Rector\PHPUnit\NodeFactory\ExpectExceptionFactory;
use Rector\PHPUnit\NodeFactory\ExpectExceptionMessageFactory;
use Rector\PHPUnit\NodeFactory\ExpectExceptionMessageRegExpFactory;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\PHPUnit\Tests\Rector\ClassMethod\TryCatchToExpectExceptionRector\TryCatchToExpectExceptionRectorTest
*/
final class TryCatchToExpectExceptionRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
*/
private $testsNodeAnalyzer;
/**
* @readonly
* @var \Rector\PHPUnit\NodeFactory\ExpectExceptionCodeFactory
*/
private $expectExceptionCodeFactory;
/**
* @readonly
* @var \Rector\PHPUnit\NodeFactory\ExpectExceptionMessageRegExpFactory
*/
private $expectExceptionMessageRegExpFactory;
/**
* @readonly
* @var \Rector\PHPUnit\NodeFactory\ExpectExceptionFactory
*/
private $expectExceptionFactory;
/**
* @readonly
* @var \Rector\PHPUnit\NodeFactory\ExpectExceptionMessageFactory
*/
private $expectExceptionMessageFactory;
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, ExpectExceptionCodeFactory $expectExceptionCodeFactory, ExpectExceptionMessageRegExpFactory $expectExceptionMessageRegExpFactory, ExpectExceptionFactory $expectExceptionFactory, ExpectExceptionMessageFactory $expectExceptionMessageFactory)
{
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
$this->expectExceptionCodeFactory = $expectExceptionCodeFactory;
$this->expectExceptionMessageRegExpFactory = $expectExceptionMessageRegExpFactory;
$this->expectExceptionFactory = $expectExceptionFactory;
$this->expectExceptionMessageFactory = $expectExceptionMessageFactory;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Turns try/catch to expectException() call', [new CodeSample(<<<'CODE_SAMPLE'
try {
$someService->run();
} catch (Throwable $exception) {
$this->assertInstanceOf(RuntimeException::class, $e);
$this->assertContains('There was an error executing the following script', $e->getMessage());
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('There was an error executing the following script');
$someService->run();
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [ClassMethod::class];
}
/**
* @param ClassMethod $node
*/
public function refactor(Node $node) : ?Node
{
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
return null;
}
if ($node->stmts === null) {
return null;
}
$proccesed = [];
foreach ($node->stmts as $key => $stmt) {
if (!$stmt instanceof TryCatch) {
continue;
}
$proccesed = $this->processTryCatch($stmt);
if ($proccesed === null) {
continue;
}
unset($node->stmts[$key]);
}
if ($proccesed !== null) {
$node->stmts = \array_merge($node->stmts, $proccesed);
}
return $node;
}
/**
* @return Node\Stmt[]|null
*/
private function processTryCatch(TryCatch $tryCatch) : ?array
{
$exceptionVariable = $this->matchSingleExceptionVariable($tryCatch);
if (!$exceptionVariable instanceof Variable) {
return null;
}
// we look for:
// - instance of $exceptionVariableName
// - assert same string to $exceptionVariableName->getMessage()
// - assert same string to $exceptionVariableName->getCode()
$newMethodCalls = [];
foreach ($tryCatch->catches[0]->stmts as $catchedStmt) {
// not a match
if (!$catchedStmt instanceof Expression) {
return null;
}
if (!$catchedStmt->expr instanceof MethodCall) {
continue;
}
$methodCallNode = $catchedStmt->expr;
$newMethodCalls[] = $this->expectExceptionMessageFactory->create($methodCallNode, $exceptionVariable);
$newMethodCalls[] = $this->expectExceptionFactory->create($methodCallNode, $exceptionVariable);
$newMethodCalls[] = $this->expectExceptionCodeFactory->create($methodCallNode, $exceptionVariable);
$newMethodCalls[] = $this->expectExceptionMessageRegExpFactory->create($methodCallNode, $exceptionVariable);
}
$newMethodCalls = \array_filter($newMethodCalls);
$newExpressions = $this->wrapInExpressions($newMethodCalls);
// return all statements
foreach ($tryCatch->stmts as $stmt) {
if (!$stmt instanceof Expression) {
return null;
}
$newExpressions[] = $stmt;
}
return $newExpressions;
}
private function matchSingleExceptionVariable(TryCatch $tryCatch) : ?Variable
{
if (\count($tryCatch->catches) !== 1) {
return null;
}
return $tryCatch->catches[0]->var;
}
/**
* @param MethodCall[] $methodCalls
* @return Expression[]
*/
private function wrapInExpressions(array $methodCalls) : array
{
$expressions = [];
foreach ($methodCalls as $methodCall) {
$expressions[] = new Expression($methodCall);
}
return $expressions;
}
}