mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-04 02:10:51 +00:00
Updated Rector to commit bbd9d4fa2c6811c9c68984549d2c0dfb68232219
bbd9d4fa2c
[CodeQuality] Skip non typed property no default value never assigned on SimplifyEmptyCheckOnEmptyArrayRector (#3171)
This commit is contained in:
parent
7e4cd5dfba
commit
4bc9094047
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit79248adaa56d100c6027d1f1e9835a31::getLoader();
|
||||
return ComposerAutoloaderInit0a75c686bee35d8a18937bc2ee382502::getLoader();
|
||||
|
|
7
vendor/composer/autoload_classmap.php
vendored
7
vendor/composer/autoload_classmap.php
vendored
|
@ -1990,7 +1990,6 @@ return array(
|
|||
'Rector\\PHPStanStaticTypeMapper\\Utils\\TypeUnwrapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\ValueObject\\UnionTypeAnalysis' => $baseDir . '/packages/PHPStanStaticTypeMapper/ValueObject/UnionTypeAnalysis.php',
|
||||
'Rector\\PHPUnit\\Naming\\TestClassNameResolver' => $vendorDir . '/rector/rector-phpunit/src/Naming/TestClassNameResolver.php',
|
||||
'Rector\\PHPUnit\\Naming\\TestClassNameResolverInterface' => $vendorDir . '/rector/rector-phpunit/src/Naming/TestClassNameResolverInterface.php',
|
||||
'Rector\\PHPUnit\\NodeAnalyzer\\AssertCallAnalyzer' => $vendorDir . '/rector/rector-phpunit/src/NodeAnalyzer/AssertCallAnalyzer.php',
|
||||
'Rector\\PHPUnit\\NodeAnalyzer\\IdentifierManipulator' => $vendorDir . '/rector/rector-phpunit/src/NodeAnalyzer/IdentifierManipulator.php',
|
||||
'Rector\\PHPUnit\\NodeAnalyzer\\MockedVariableAnalyzer' => $vendorDir . '/rector/rector-phpunit/src/NodeAnalyzer/MockedVariableAnalyzer.php',
|
||||
|
@ -2004,8 +2003,10 @@ return array(
|
|||
'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\\NodeManipulator\\ArgumentMover' => $vendorDir . '/rector/rector-phpunit/src/NodeManipulator/ArgumentMover.php',
|
||||
'Rector\\PHPUnit\\NodeManipulator\\ParamAndArgFromArrayResolver' => $vendorDir . '/rector/rector-phpunit/src/NodeManipulator/ParamAndArgFromArrayResolver.php',
|
||||
'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\\AddDoesNotPerformAssertionToNonAssertingTestRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\CreateMockToAnonymousClassRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php',
|
||||
|
@ -2015,10 +2016,13 @@ return array(
|
|||
'Rector\\PHPUnit\\Rector\\ClassMethod\\TryCatchToExpectExceptionRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\AddProphecyTraitRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/AddProphecyTraitRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\AddSeeTestAnnotationRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.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_\\ConstructClassMethodToSetUpTestCaseRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\CoversAnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\ProphecyPHPDocRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/ProphecyPHPDocRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\RemoveDataProviderTestPrefixRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\StaticDataProviderClassMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/StaticDataProviderClassMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\TestListenerToHooksRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\AssertCompareToSpecificMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/AssertCompareToSpecificMethodRector.php',
|
||||
|
@ -2051,6 +2055,7 @@ return array(
|
|||
'Rector\\PHPUnit\\Rector\\StaticCall\\GetMockRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/StaticCall/GetMockRector.php',
|
||||
'Rector\\PHPUnit\\Set\\PHPUnitLevelSetList' => $vendorDir . '/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php',
|
||||
'Rector\\PHPUnit\\Set\\PHPUnitSetList' => $vendorDir . '/rector/rector-phpunit/src/Set/PHPUnitSetList.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\AnnotationWithValueToAttribute' => $vendorDir . '/rector/rector-phpunit/src/ValueObject/AnnotationWithValueToAttribute.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\ArrayArgumentToDataProvider' => $vendorDir . '/rector/rector-phpunit/src/ValueObject/ArrayArgumentToDataProvider.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\BinaryOpWithAssertMethod' => $vendorDir . '/rector/rector-phpunit/src/ValueObject/BinaryOpWithAssertMethod.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\ConstantWithAssertMethods' => $vendorDir . '/rector/rector-phpunit/src/ValueObject/ConstantWithAssertMethods.php',
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit79248adaa56d100c6027d1f1e9835a31
|
||||
class ComposerAutoloaderInit0a75c686bee35d8a18937bc2ee382502
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit79248adaa56d100c6027d1f1e9835a31
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit79248adaa56d100c6027d1f1e9835a31', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit0a75c686bee35d8a18937bc2ee382502', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit79248adaa56d100c6027d1f1e9835a31', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit0a75c686bee35d8a18937bc2ee382502', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit79248adaa56d100c6027d1f1e9835a31::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit0a75c686bee35d8a18937bc2ee382502::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit79248adaa56d100c6027d1f1e9835a31::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit0a75c686bee35d8a18937bc2ee382502::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire79248adaa56d100c6027d1f1e9835a31($fileIdentifier, $file);
|
||||
composerRequire0a75c686bee35d8a18937bc2ee382502($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit79248adaa56d100c6027d1f1e9835a31
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire79248adaa56d100c6027d1f1e9835a31($fileIdentifier, $file)
|
||||
function composerRequire0a75c686bee35d8a18937bc2ee382502($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
15
vendor/composer/autoload_static.php
vendored
15
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit79248adaa56d100c6027d1f1e9835a31
|
||||
class ComposerStaticInit0a75c686bee35d8a18937bc2ee382502
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -2230,7 +2230,6 @@ class ComposerStaticInit79248adaa56d100c6027d1f1e9835a31
|
|||
'Rector\\PHPStanStaticTypeMapper\\Utils\\TypeUnwrapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\ValueObject\\UnionTypeAnalysis' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/ValueObject/UnionTypeAnalysis.php',
|
||||
'Rector\\PHPUnit\\Naming\\TestClassNameResolver' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Naming/TestClassNameResolver.php',
|
||||
'Rector\\PHPUnit\\Naming\\TestClassNameResolverInterface' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Naming/TestClassNameResolverInterface.php',
|
||||
'Rector\\PHPUnit\\NodeAnalyzer\\AssertCallAnalyzer' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeAnalyzer/AssertCallAnalyzer.php',
|
||||
'Rector\\PHPUnit\\NodeAnalyzer\\IdentifierManipulator' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeAnalyzer/IdentifierManipulator.php',
|
||||
'Rector\\PHPUnit\\NodeAnalyzer\\MockedVariableAnalyzer' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeAnalyzer/MockedVariableAnalyzer.php',
|
||||
|
@ -2244,8 +2243,10 @@ class ComposerStaticInit79248adaa56d100c6027d1f1e9835a31
|
|||
'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\\NodeManipulator\\ArgumentMover' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeManipulator/ArgumentMover.php',
|
||||
'Rector\\PHPUnit\\NodeManipulator\\ParamAndArgFromArrayResolver' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeManipulator/ParamAndArgFromArrayResolver.php',
|
||||
'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\\AddDoesNotPerformAssertionToNonAssertingTestRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\CreateMockToAnonymousClassRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php',
|
||||
|
@ -2255,10 +2256,13 @@ class ComposerStaticInit79248adaa56d100c6027d1f1e9835a31
|
|||
'Rector\\PHPUnit\\Rector\\ClassMethod\\TryCatchToExpectExceptionRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\AddProphecyTraitRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/AddProphecyTraitRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\AddSeeTestAnnotationRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.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_\\ConstructClassMethodToSetUpTestCaseRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\CoversAnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\ProphecyPHPDocRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/ProphecyPHPDocRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\RemoveDataProviderTestPrefixRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\StaticDataProviderClassMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/StaticDataProviderClassMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\TestListenerToHooksRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\AssertCompareToSpecificMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/AssertCompareToSpecificMethodRector.php',
|
||||
|
@ -2291,6 +2295,7 @@ class ComposerStaticInit79248adaa56d100c6027d1f1e9835a31
|
|||
'Rector\\PHPUnit\\Rector\\StaticCall\\GetMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/StaticCall/GetMockRector.php',
|
||||
'Rector\\PHPUnit\\Set\\PHPUnitLevelSetList' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php',
|
||||
'Rector\\PHPUnit\\Set\\PHPUnitSetList' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Set/PHPUnitSetList.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\AnnotationWithValueToAttribute' => __DIR__ . '/..' . '/rector/rector-phpunit/src/ValueObject/AnnotationWithValueToAttribute.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\ArrayArgumentToDataProvider' => __DIR__ . '/..' . '/rector/rector-phpunit/src/ValueObject/ArrayArgumentToDataProvider.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\BinaryOpWithAssertMethod' => __DIR__ . '/..' . '/rector/rector-phpunit/src/ValueObject/BinaryOpWithAssertMethod.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\ConstantWithAssertMethods' => __DIR__ . '/..' . '/rector/rector-phpunit/src/ValueObject/ConstantWithAssertMethods.php',
|
||||
|
@ -3020,9 +3025,9 @@ class ComposerStaticInit79248adaa56d100c6027d1f1e9835a31
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit79248adaa56d100c6027d1f1e9835a31::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit79248adaa56d100c6027d1f1e9835a31::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit79248adaa56d100c6027d1f1e9835a31::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit0a75c686bee35d8a18937bc2ee382502::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit0a75c686bee35d8a18937bc2ee382502::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit0a75c686bee35d8a18937bc2ee382502::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
12
vendor/composer/installed.json
vendored
12
vendor/composer/installed.json
vendored
|
@ -1989,12 +1989,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "3d0d84d78aed4aa4ca9a8e3eae3f51dcb833beb7"
|
||||
"reference": "7ea9a12bb2ea605e6793fd0e12d82fea47ae4589"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/3d0d84d78aed4aa4ca9a8e3eae3f51dcb833beb7",
|
||||
"reference": "3d0d84d78aed4aa4ca9a8e3eae3f51dcb833beb7",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/7ea9a12bb2ea605e6793fd0e12d82fea47ae4589",
|
||||
"reference": "7ea9a12bb2ea605e6793fd0e12d82fea47ae4589",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2005,7 +2005,7 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.1",
|
||||
"phpstan\/phpstan": "^1.8",
|
||||
"phpstan\/phpstan": "^1.9.2",
|
||||
"phpstan\/phpstan-strict-rules": "^1.2",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.1",
|
||||
"phpunit\/phpunit": "^9.5",
|
||||
|
@ -2020,7 +2020,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-12-03T10:43:12+00:00",
|
||||
"time": "2022-12-08T21:25:49+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -2047,7 +2047,7 @@
|
|||
"description": "Rector upgrades rules for PHPUnit",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/rectorphp\/rector-phpunit\/issues",
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-phpunit\/tree\/0.14.1"
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-phpunit\/tree\/main"
|
||||
},
|
||||
"install-path": "..\/rector\/rector-phpunit"
|
||||
},
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -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 bf394ee'), '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 b1ca6d7'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 3d0d84d'), '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 f77e493'));
|
||||
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 bf394ee'), '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 b1ca6d7'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 7ea9a12'), '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 f77e493'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
2
vendor/rector/rector-phpunit/composer.json
vendored
2
vendor/rector/rector-phpunit/composer.json
vendored
|
@ -9,7 +9,7 @@
|
|||
"require-dev": {
|
||||
"rector\/rector-src": "dev-main",
|
||||
"phpunit\/phpunit": "^9.5",
|
||||
"phpstan\/phpstan": "^1.8",
|
||||
"phpstan\/phpstan": "^1.9.2",
|
||||
"symplify\/phpstan-rules": "^11.1",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
"symplify\/easy-coding-standard": "^11.1",
|
||||
|
|
|
@ -6,48 +6,25 @@ namespace RectorPrefix202212;
|
|||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\ValueObject\AnnotationToAttribute;
|
||||
use Rector\PHPUnit\Rector\Class_\AnnotationWithValueToAttributeRector;
|
||||
use Rector\PHPUnit\Rector\Class_\CoversAnnotationWithValueToAttributeRector;
|
||||
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rules([CoversAnnotationWithValueToAttributeRector::class]);
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationWithValueToAttributeRector::class, [new AnnotationWithValueToAttribute('backupGlobals', 'PHPUnit\\Framework\\Attributes\\BackupGlobals', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('backupStaticAttributes', 'PHPUnit\\Framework\\Attributes\\BackupStaticProperties', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('preserveGlobalState', 'PHPUnit\\Framework\\Attributes\\PreserveGlobalState', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('dataProvider', 'PHPUnit\\Framework\\Attributes\\DataProvider'), new AnnotationWithValueToAttribute('depends', 'PHPUnit\\Framework\\Attributes\\Depends'), new AnnotationWithValueToAttribute('group', 'PHPUnit\\Framework\\Attributes\\Group'), new AnnotationWithValueToAttribute('ticket', 'PHPUnit\\Framework\\Attributes\\Ticket'), new AnnotationWithValueToAttribute('uses', 'PHPUnit\\Framework\\Attributes\\UsesClass'), new AnnotationWithValueToAttribute('testWith', 'PHPUnit\\Framework\\Attributes\\TestWith'), new AnnotationWithValueToAttribute('testDox', 'PHPUnit\\Framework\\Attributes\\TestDox')]);
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
|
||||
// @see https://github.com/sebastianbergmann/phpunit/issues/4502
|
||||
new AnnotationToAttribute('after', 'PHPUnit\\Framework\\Attributes\\After'),
|
||||
new AnnotationToAttribute('afterClass', 'PHPUnit\\Framework\\Attributes\\AfterClass'),
|
||||
// new AnnotationToAttribute('backupGlobals', 'PHPUnit\Framework\Attributes\BackupGlobals'),
|
||||
// new AnnotationToAttribute('backupStaticAttributes', 'PHPUnit\Framework\Attributes\BackupStaticProperties'),
|
||||
new AnnotationToAttribute('before', 'PHPUnit\\Framework\\Attributes\\Before'),
|
||||
new AnnotationToAttribute('beforeClass', 'PHPUnit\\Framework\\Attributes\\BeforeClass'),
|
||||
new AnnotationToAttribute('codeCoverageIgnore', 'PHPUnit\\Framework\\Attributes\\CodeCoverageIgnore'),
|
||||
// new AnnotationToAttribute('covers', 'PHPUnit\Framework\Attributes\CoversClass'),
|
||||
// new AnnotationToAttribute('covers', 'PHPUnit\Framework\Attributes\CoversFunction'),
|
||||
new AnnotationToAttribute('coversNothing', 'PHPUnit\\Framework\\Attributes\\CoversNothing'),
|
||||
// new AnnotationToAttribute('dataProvider', 'PHPUnit\Framework\Attributes\DataProvider'),
|
||||
// new AnnotationToAttribute('dataProvider', 'PHPUnit\Framework\Attributes\DataProviderExternal'),
|
||||
// new AnnotationToAttribute('depends', 'PHPUnit\Framework\Attributes\Depends'),
|
||||
// new AnnotationToAttribute('depends', 'PHPUnit\Framework\Attributes\DependsExternal'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\DependsExternalUsingDeepClone'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\DependsExternalUsingShallowClone'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\DependsOnClass'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\DependsOnClassUsingDeepClone'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\DependsOnClassUsingShallowClone'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\DependsUsingDeepClone'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\DependsUsingShallowClone'),
|
||||
new AnnotationToAttribute('doesNotPerformAssertions', 'PHPUnit\\Framework\\Attributes\\DoesNotPerformAssertions'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\ExcludeGlobalVariableFromBackup'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\ExcludeStaticPropertyFromBackup'),
|
||||
// new AnnotationToAttribute('group', 'PHPUnit\Framework\Attributes\Group'),
|
||||
new AnnotationToAttribute('large', 'PHPUnit\\Framework\\Attributes\\Large'),
|
||||
new AnnotationToAttribute('medium', 'PHPUnit\\Framework\\Attributes\\Medium'),
|
||||
new AnnotationToAttribute('preCondition', 'PHPUnit\\Framework\\Attributes\\PostCondition'),
|
||||
new AnnotationToAttribute('postCondition', 'PHPUnit\\Framework\\Attributes\\PreCondition'),
|
||||
new AnnotationToAttribute('preserveGlobalState', 'PHPUnit\\Framework\\Attributes\\PreserveGlobalState'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RequiresFunction'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RequiresMethod'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RequiresOperatingSystem'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RequiresPhp'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RequiresPhpExtension'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RequiresPhpunit'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RequiresSetting'),
|
||||
// new AnnotationToAttribute('PHPUnit\Framework\Attributes\RunClassInSeparateProcess'),
|
||||
new AnnotationToAttribute('runInSeparateProcess', 'PHPUnit\\Framework\\Attributes\\RunInSeparateProcess'),
|
||||
new AnnotationToAttribute('runTestsInSeparateProcesses', 'PHPUnit\\Framework\\Attributes\\RunTestsInSeparateProcesses'),
|
||||
new AnnotationToAttribute('small', 'PHPUnit\\Framework\\Attributes\\Small'),
|
||||
|
|
|
@ -7,6 +7,6 @@ use Rector\Config\RectorConfig;
|
|||
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
|
||||
use Rector\PHPUnit\Set\PHPUnitSetList;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(PHPUnitSetList::PHPUNIT_91);
|
||||
$rectorConfig->import(PHPUnitSetList::PHPUNIT_100);
|
||||
$rectorConfig->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_90);
|
||||
};
|
||||
|
|
11
vendor/rector/rector-phpunit/config/sets/phpunit100.php
vendored
Normal file
11
vendor/rector/rector-phpunit/config/sets/phpunit100.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202212;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\Rector\Class_\StaticDataProviderClassMethodRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/annotations-to-attributes.php');
|
||||
$rectorConfig->rules([StaticDataProviderClassMethodRector::class]);
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
# 42 Rules Overview
|
||||
# 45 Rules Overview
|
||||
|
||||
## AddDoesNotPerformAssertionToNonAssertingTestRector
|
||||
|
||||
|
@ -69,6 +69,47 @@ Add `@see` annotation test of the class for faster jump to test. Make it FQN, so
|
|||
|
||||
<br>
|
||||
|
||||
## AnnotationWithValueToAttributeRector
|
||||
|
||||
Change annotations with value to attribute
|
||||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\PHPUnit\Rector\Class_\AnnotationWithValueToAttributeRector`](../src/Rector/Class_/AnnotationWithValueToAttributeRector.php)
|
||||
|
||||
```php
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\Rector\Class_\AnnotationWithValueToAttributeRector;
|
||||
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(
|
||||
AnnotationWithValueToAttributeRector::class,
|
||||
[new AnnotationWithValueToAttribute('backupGlobals', 'PHPUnit\Framework\Attributes\BackupGlobals', [
|
||||
true,
|
||||
false,
|
||||
])]
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
use PHPUnit\Framework\TestCase;
|
||||
+use PHPUnit\Framework\Attributes\BackupGlobals;
|
||||
|
||||
-/**
|
||||
- * @backupGlobals enabled
|
||||
- */
|
||||
+#[BackupGlobals(true)]
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## ArrayArgumentToDataProviderRector
|
||||
|
||||
Move array argument from tests into data provider [configurable]
|
||||
|
@ -83,7 +124,11 @@ use Rector\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector;
|
|||
use Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(ArrayArgumentToDataProviderRector::class, [Rector\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS: [new ArrayArgumentToDataProvider('PHPUnit\Framework\TestCase', 'doTestMultiple', 'doTestSingle', 'number')]]);
|
||||
$rectorConfig->ruleWithConfiguration(ArrayArgumentToDataProviderRector::class, [
|
||||
ArrayArgumentToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => [
|
||||
new ArrayArgumentToDataProvider('PHPUnit\Framework\TestCase', 'doTestMultiple', 'doTestSingle', 'number'),
|
||||
],
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -129,8 +174,8 @@ Turns vague php-only method in PHPUnit TestCase to more specific
|
|||
<br>
|
||||
|
||||
```diff
|
||||
-$this->assertNotEquals(get_class($value), stdClass::class);
|
||||
+$this->assertNotInstanceOf(stdClass::class, $value);
|
||||
-$this->assertNotEquals(get_class($value), SomeInstance::class);
|
||||
+$this->assertNotInstanceOf(SomeInstance::class, $value);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -191,15 +236,8 @@ Turns `assertEquals()` into stricter `assertSame()` for scalar values in PHPUnit
|
|||
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector`](../src/Rector/MethodCall/AssertEqualsToSameRector.php)
|
||||
|
||||
```diff
|
||||
-$this->assertEquals(2, $result, "message");
|
||||
+$this->assertSame(2, $result, "message");
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
```diff
|
||||
-$this->assertEquals($aString, $result, "message");
|
||||
+$this->assertSame($aString, $result, "message");
|
||||
-$this->assertEquals(2, $result);
|
||||
+$this->assertSame(2, $result);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -217,13 +255,6 @@ Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUni
|
|||
|
||||
<br>
|
||||
|
||||
```diff
|
||||
-$this->assertNotFalse(stripos($anything, "foo"), "message");
|
||||
+$this->assertContains("foo", $anything, "message");
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## AssertInstanceOfComparisonRector
|
||||
|
||||
Turns instanceof comparisons to their method name alternatives in PHPUnit TestCase
|
||||
|
@ -291,15 +322,10 @@ Turns `property_exists` comparisons to their method name alternatives in PHPUnit
|
|||
- class: [`Rector\PHPUnit\Rector\MethodCall\AssertPropertyExistsRector`](../src/Rector/MethodCall/AssertPropertyExistsRector.php)
|
||||
|
||||
```diff
|
||||
-$this->assertTrue(property_exists(new Class, "property"), "message");
|
||||
+$this->assertClassHasAttribute("property", "Class", "message");
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
```diff
|
||||
-$this->assertFalse(property_exists(new Class, "property"), "message");
|
||||
+$this->assertClassNotHasAttribute("property", "Class", "message");
|
||||
-$this->assertFalse(property_exists(new Class, "property"));
|
||||
-$this->assertTrue(property_exists(new Class, "property"));
|
||||
+$this->assertClassHasAttribute("property", "Class");
|
||||
+$this->assertClassNotHasAttribute("property", "Class");
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -438,31 +464,60 @@ Change `__construct()` method in tests of `PHPUnit\Framework\TestCase` to `setUp
|
|||
|
||||
<br>
|
||||
|
||||
## CoversAnnotationWithValueToAttributeRector
|
||||
|
||||
Change covers annotations with value to attribute
|
||||
|
||||
- class: [`Rector\PHPUnit\Rector\Class_\CoversAnnotationWithValueToAttributeRector`](../src/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php)
|
||||
|
||||
```diff
|
||||
use PHPUnit\Framework\TestCase;
|
||||
+use PHPUnit\Framework\Attributes\CoversClass;
|
||||
+use PHPUnit\Framework\Attributes\CoversFunction;
|
||||
|
||||
-/**
|
||||
- * @covers SomeClass
|
||||
- */
|
||||
+#[CoversClass(SomeClass::class)]
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
- /**
|
||||
- * @covers ::someFunction
|
||||
- */
|
||||
+ #[CoversFunction('someFunction')]
|
||||
public function test()
|
||||
{
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## CreateMockToAnonymousClassRector
|
||||
|
||||
Change `$this->createMock()` with methods to direct anonymous class.
|
||||
Change `$this->createMock()` with methods to direct anonymous class
|
||||
|
||||
- class: [`Rector\PHPUnit\Rector\ClassMethod\CreateMockToAnonymousClassRector`](../src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php)
|
||||
|
||||
```diff
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
- $someMockObject = $this->createMock(SomeClass::class);
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
- $someMockObject = $this->createMock(SomeClass::class);
|
||||
-
|
||||
- $someMockObject->method('someMethod')
|
||||
- ->willReturn(100);
|
||||
+ $someMockObject = new class extends SomeClass {
|
||||
+ public function someMethod()
|
||||
+ {
|
||||
+ return 100;
|
||||
+ }
|
||||
};
|
||||
}
|
||||
}
|
||||
- $someMockObject->method('someMethod')
|
||||
- ->willReturn(100);
|
||||
+ $someMockObject = new class extends SomeClass {
|
||||
+ public function someMethod()
|
||||
+ {
|
||||
+ return 100;
|
||||
+ }
|
||||
+ };
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -505,8 +560,8 @@ Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.
|
|||
- class: [`Rector\PHPUnit\Rector\MethodCall\DelegateExceptionArgumentsRector`](../src/Rector/MethodCall/DelegateExceptionArgumentsRector.php)
|
||||
|
||||
```diff
|
||||
-$this->setExpectedException(Exception::class, "Message", "CODE");
|
||||
+$this->setExpectedException(Exception::class);
|
||||
-$this->setExpectedException(SomeException::class, "Message", "CODE");
|
||||
+$this->setExpectedException(SomeException::class);
|
||||
+$this->expectExceptionMessage('Message');
|
||||
+$this->expectExceptionCode('CODE');
|
||||
```
|
||||
|
@ -566,7 +621,9 @@ Remove `getMockBuilder()` to `createMock()`
|
|||
- class: [`Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector`](../src/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php)
|
||||
|
||||
```diff
|
||||
class SomeTest extends \PHPUnit\Framework\TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
|
@ -587,39 +644,40 @@ Turns getMock*() methods to `createMock()`
|
|||
- class: [`Rector\PHPUnit\Rector\StaticCall\GetMockRector`](../src/Rector/StaticCall/GetMockRector.php)
|
||||
|
||||
```diff
|
||||
-$this->getMock("Class");
|
||||
+$this->createMock("Class");
|
||||
```
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
<br>
|
||||
|
||||
```diff
|
||||
-$this->getMockWithoutInvokingTheOriginalConstructor("Class");
|
||||
+$this->createMock("Class");
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
- $classMock = $this->getMock("Class");
|
||||
+ $classMock = $this->createMock("Class");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## ProphecyPHPDocRector
|
||||
|
||||
Add correct `@var` to ObjectProphecy instances based on `$this->prophesize()` call.`
|
||||
Add correct `@var` to ObjectProphecy instances based on `$this->prophesize()` call.
|
||||
|
||||
- class: [`Rector\PHPUnit\Rector\Class_\ProphecyPHPDocRector`](../src/Rector/Class_/ProphecyPHPDocRector.php)
|
||||
|
||||
```diff
|
||||
class HelloTest extends TestCase
|
||||
{
|
||||
/**
|
||||
- * @var SomeClass
|
||||
+ * @var ObjectProphecy<SomeClass>
|
||||
*/
|
||||
private $propesizedObject;
|
||||
class HelloTest extends TestCase
|
||||
{
|
||||
/**
|
||||
- * @var SomeClass
|
||||
+ * @var ObjectProphecy<SomeClass>
|
||||
*/
|
||||
private $propesizedObject;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->propesizedObject = $this->prophesize(SomeClass::class);
|
||||
}
|
||||
}
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->propesizedObject = $this->prophesize(SomeClass::class);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -847,6 +905,34 @@ Change `assertInternalType()/assertNotInternalType()` method to new specific alt
|
|||
|
||||
<br>
|
||||
|
||||
## StaticDataProviderClassMethodRector
|
||||
|
||||
Change data provider methods to static
|
||||
|
||||
- class: [`Rector\PHPUnit\Rector\Class_\StaticDataProviderClassMethodRector`](../src/Rector/Class_/StaticDataProviderClassMethodRector.php)
|
||||
|
||||
```diff
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
}
|
||||
|
||||
- public function provideData()
|
||||
+ public static function provideData()
|
||||
{
|
||||
yield [1];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## TestListenerToHooksRector
|
||||
|
||||
Refactor "*TestListener.php" to particular "*Hook.php" files
|
||||
|
@ -931,7 +1017,7 @@ Turns try/catch to `expectException()` call
|
|||
|
||||
## UseSpecificWillMethodRector
|
||||
|
||||
Changes `->will($this->xxx())` to one specific method
|
||||
Changes `$mock->will()` call to more specific method
|
||||
|
||||
- class: [`Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector`](../src/Rector/MethodCall/UseSpecificWillMethodRector.php)
|
||||
|
||||
|
@ -940,12 +1026,10 @@ Changes `->will($this->xxx())` to one specific method
|
|||
{
|
||||
public function test()
|
||||
{
|
||||
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
|
||||
$translator = $this->createMock('SomeClass');
|
||||
$translator->expects($this->any())
|
||||
->method('trans')
|
||||
- ->with($this->equalTo('old max {{ max }}!'))
|
||||
- ->will($this->returnValue('translated max {{ max }}!'));
|
||||
+ ->with('old max {{ max }}!')
|
||||
+ ->willReturnValue('translated max {{ max }}!');
|
||||
}
|
||||
}
|
||||
|
@ -960,18 +1044,18 @@ Changes `->with()` to more specific method
|
|||
- class: [`Rector\PHPUnit\Rector\MethodCall\UseSpecificWithMethodRector`](../src/Rector/MethodCall/UseSpecificWithMethodRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$translator = $this->createMock('SomeClass');
|
||||
class SomeClass extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$translator = $this->createMock('SomeClass');
|
||||
|
||||
$translator->expects($this->any())
|
||||
->method('trans')
|
||||
- ->with($this->equalTo('old max {{ max }}!'));
|
||||
+ ->with('old max {{ max }}!');
|
||||
}
|
||||
}
|
||||
$translator->expects($this->any())
|
||||
->method('trans')
|
||||
- ->with($this->equalTo('old max {{ max }}!'));
|
||||
+ ->with('old max {{ max }}!');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
|
9
vendor/rector/rector-phpunit/easy-ci.php
vendored
9
vendor/rector/rector-phpunit/easy-ci.php
vendored
|
@ -4,11 +4,8 @@ declare (strict_types=1);
|
|||
namespace RectorPrefix202212;
|
||||
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\PHPUnit\Naming\TestClassNameResolverInterface;
|
||||
use Rector\Set\Contract\SetListInterface;
|
||||
use RectorPrefix202212\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix202212\Symplify\EasyCI\ValueObject\Option;
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::TYPES_TO_SKIP, [TestClassNameResolverInterface::class, RectorInterface::class, SetListInterface::class]);
|
||||
use RectorPrefix202212\Symplify\EasyCI\Config\EasyCIConfig;
|
||||
return static function (EasyCIConfig $easyCIConfig) : void {
|
||||
$easyCIConfig->typesToSkip([RectorInterface::class, SetListInterface::class]);
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Naming;
|
||||
|
||||
final class TestClassNameResolver implements \Rector\PHPUnit\Naming\TestClassNameResolverInterface
|
||||
final class TestClassNameResolver
|
||||
{
|
||||
/**
|
||||
* @return string[]
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Naming;
|
||||
|
||||
interface TestClassNameResolverInterface
|
||||
{
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function resolve(string $className) : array;
|
||||
}
|
64
vendor/rector/rector-phpunit/src/NodeFinder/DataProviderClassMethodFinder.php
vendored
Normal file
64
vendor/rector/rector-phpunit/src/NodeFinder/DataProviderClassMethodFinder.php
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\NodeFinder;
|
||||
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
final class DataProviderClassMethodFinder
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
}
|
||||
/**
|
||||
* @return ClassMethod[]
|
||||
*/
|
||||
public function find(Class_ $class) : array
|
||||
{
|
||||
$dataProviderMethodNames = $this->resolverDataProviderClassMethodNames($class);
|
||||
$dataProviderClassMethods = [];
|
||||
foreach ($dataProviderMethodNames as $dataProviderMethodName) {
|
||||
$dataProviderClassMethod = $class->getMethod($dataProviderMethodName);
|
||||
if (!$dataProviderClassMethod instanceof ClassMethod) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
$dataProviderClassMethods[] = $dataProviderClassMethod;
|
||||
}
|
||||
return $dataProviderClassMethods;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolverDataProviderClassMethodNames(Class_ $class) : array
|
||||
{
|
||||
$dataProviderMethodNames = [];
|
||||
foreach ($class->getMethods() as $classMethod) {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
|
||||
$dataProviderTagValueNodes = $phpDocInfo->getTagsByName('dataProvider');
|
||||
if ($dataProviderTagValueNodes === []) {
|
||||
continue;
|
||||
}
|
||||
foreach ($dataProviderTagValueNodes as $dataProviderTagValueNode) {
|
||||
if (!$dataProviderTagValueNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$dataProviderMethodNames[] = $this->resolveMethodName($dataProviderTagValueNode->value);
|
||||
}
|
||||
}
|
||||
return $dataProviderMethodNames;
|
||||
}
|
||||
private function resolveMethodName(GenericTagValueNode $genericTagValueNode) : string
|
||||
{
|
||||
$rawValue = $genericTagValueNode->value;
|
||||
return \trim($rawValue, '()');
|
||||
}
|
||||
}
|
47
vendor/rector/rector-phpunit/src/PhpDoc/DataProviderMethodRenamer.php
vendored
Normal file
47
vendor/rector/rector-phpunit/src/PhpDoc/DataProviderMethodRenamer.php
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\PhpDoc;
|
||||
|
||||
use RectorPrefix202212\Nette\Utils\Strings;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
final class DataProviderMethodRenamer
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
}
|
||||
public function removeTestPrefix(Class_ $class) : void
|
||||
{
|
||||
foreach ($class->getMethods() as $classMethod) {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
|
||||
foreach ($phpDocInfo->getTagsByName('dataProvider') as $phpDocTagNode) {
|
||||
if (!$phpDocTagNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$oldMethodName = $phpDocTagNode->value->value;
|
||||
if (\strncmp($oldMethodName, 'test', \strlen('test')) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$newMethodName = $this->createMethodNameWithoutPrefix($oldMethodName, 'test');
|
||||
$phpDocTagNode->value->value = Strings::replace($oldMethodName, '#' . \preg_quote($oldMethodName, '#') . '#', $newMethodName);
|
||||
// invoke reprint
|
||||
$phpDocTagNode->setAttribute(PhpDocAttributeKey::START_AND_END, null);
|
||||
$phpDocInfo->markAsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private function createMethodNameWithoutPrefix(string $methodName, string $prefix) : string
|
||||
{
|
||||
$newMethodName = Strings::substring($methodName, \strlen($prefix));
|
||||
return \lcfirst($newMethodName);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ use PHPStan\Reflection\ReflectionProvider;
|
|||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPUnit\Naming\TestClassNameResolverInterface;
|
||||
use Rector\PHPUnit\Naming\TestClassNameResolver;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
|
@ -35,10 +35,10 @@ final class AddSeeTestAnnotationRector extends AbstractRector
|
|||
private $phpDocTagRemover;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PHPUnit\Naming\TestClassNameResolverInterface
|
||||
* @var \Rector\PHPUnit\Naming\TestClassNameResolver
|
||||
*/
|
||||
private $testClassNameResolver;
|
||||
public function __construct(ReflectionProvider $reflectionProvider, PhpDocTagRemover $phpDocTagRemover, TestClassNameResolverInterface $testClassNameResolver)
|
||||
public function __construct(ReflectionProvider $reflectionProvider, PhpDocTagRemover $phpDocTagRemover, TestClassNameResolver $testClassNameResolver)
|
||||
{
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
$this->phpDocTagRemover = $phpDocTagRemover;
|
||||
|
|
125
vendor/rector/rector-phpunit/src/Rector/Class_/AnnotationWithValueToAttributeRector.php
vendored
Normal file
125
vendor/rector/rector-phpunit/src/Rector/Class_/AnnotationWithValueToAttributeRector.php
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\Class_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
|
||||
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202212\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\PHPUnit\Tests\Rector\Class_\AnnotationWithValueToAttributeRector\AnnotationWithValueToAttributeRectorTest
|
||||
*/
|
||||
final class AnnotationWithValueToAttributeRector extends AbstractRector implements ConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @var AnnotationWithValueToAttribute[]
|
||||
*/
|
||||
private $annotationWithValueToAttributes = [];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover
|
||||
*/
|
||||
private $phpDocTagRemover;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory
|
||||
*/
|
||||
private $phpAttributeGroupFactory;
|
||||
public function __construct(PhpDocTagRemover $phpDocTagRemover, PhpAttributeGroupFactory $phpAttributeGroupFactory)
|
||||
{
|
||||
$this->phpDocTagRemover = $phpDocTagRemover;
|
||||
$this->phpAttributeGroupFactory = $phpAttributeGroupFactory;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change annotations with value to attribute', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\BackupGlobals;
|
||||
|
||||
#[BackupGlobals(true)]
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, [new AnnotationWithValueToAttribute('backupGlobals', 'PHPUnit\\Framework\\Attributes\\BackupGlobals', ['enabled' => \true, 'disabled' => \false])])]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Class_::class, ClassMethod::class];
|
||||
}
|
||||
/**
|
||||
* @param Class_|ClassMethod $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||
if (!$phpDocInfo instanceof PhpDocInfo) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \false;
|
||||
foreach ($this->annotationWithValueToAttributes as $annotationWithValueToAttribute) {
|
||||
/** @var PhpDocTagNode[] $desiredTagValueNodes */
|
||||
$desiredTagValueNodes = $phpDocInfo->getTagsByName($annotationWithValueToAttribute->getAnnotationName());
|
||||
foreach ($desiredTagValueNodes as $desiredTagValueNode) {
|
||||
if (!$desiredTagValueNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$attributeValue = $this->resolveAttributeValue($desiredTagValueNode->value, $annotationWithValueToAttribute);
|
||||
$attributeGroup = $this->phpAttributeGroupFactory->createFromClassWithItems($annotationWithValueToAttribute->getAttributeClass(), [$attributeValue]);
|
||||
$node->attrGroups[] = $attributeGroup;
|
||||
// cleanup
|
||||
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode);
|
||||
$hasChanged = \true;
|
||||
}
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
Assert::allIsInstanceOf($configuration, AnnotationWithValueToAttribute::class);
|
||||
$this->annotationWithValueToAttributes = $configuration;
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
private function resolveAttributeValue(GenericTagValueNode $genericTagValueNode, AnnotationWithValueToAttribute $annotationWithValueToAttribute)
|
||||
{
|
||||
$valueMap = $annotationWithValueToAttribute->getValueMap();
|
||||
if ($valueMap === []) {
|
||||
// no map? convert value as it is
|
||||
return $genericTagValueNode->value;
|
||||
}
|
||||
$originalValue = \strtolower($genericTagValueNode->value);
|
||||
return $valueMap[$originalValue];
|
||||
}
|
||||
}
|
113
vendor/rector/rector-phpunit/src/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php
vendored
Normal file
113
vendor/rector/rector-phpunit/src/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\Class_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\PHPUnit\Tests\Rector\Class_\CoversAnnotationWithValueToAttributeRector\CoversAnnotationWithValueToAttributeRectorTest
|
||||
*/
|
||||
final class CoversAnnotationWithValueToAttributeRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover
|
||||
*/
|
||||
private $phpDocTagRemover;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory
|
||||
*/
|
||||
private $phpAttributeGroupFactory;
|
||||
public function __construct(PhpDocTagRemover $phpDocTagRemover, PhpAttributeGroupFactory $phpAttributeGroupFactory)
|
||||
{
|
||||
$this->phpDocTagRemover = $phpDocTagRemover;
|
||||
$this->phpAttributeGroupFactory = $phpAttributeGroupFactory;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change covers annotations with value to attribute', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SomeClass
|
||||
*/
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::someFunction
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\CoversFunction;
|
||||
|
||||
#[CoversClass(SomeClass::class)]
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
#[CoversFunction('someFunction')]
|
||||
public function test()
|
||||
{
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Class_::class, ClassMethod::class];
|
||||
}
|
||||
/**
|
||||
* @param Class_|ClassMethod $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||
if (!$phpDocInfo instanceof PhpDocInfo) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \false;
|
||||
/** @var PhpDocTagNode[] $desiredTagValueNodes */
|
||||
$desiredTagValueNodes = $phpDocInfo->getTagsByName('covers');
|
||||
foreach ($desiredTagValueNodes as $desiredTagValueNode) {
|
||||
if (!$desiredTagValueNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$annotationValue = $desiredTagValueNode->value->value;
|
||||
if (\strncmp($annotationValue, '::', \strlen('::')) === 0) {
|
||||
$attributeClass = 'PHPUnit\\Framework\\Attributes\\CoversFunction';
|
||||
$attributeValue = \trim($annotationValue, ':()');
|
||||
} else {
|
||||
$attributeClass = 'PHPUnit\\Framework\\Attributes\\CoversClass';
|
||||
$attributeValue = \trim($annotationValue) . '::class';
|
||||
}
|
||||
$hasChanged = \true;
|
||||
$attributeGroup = $this->phpAttributeGroupFactory->createFromClassWithItems($attributeClass, [$attributeValue]);
|
||||
$node->attrGroups[] = $attributeGroup;
|
||||
// cleanup
|
||||
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode);
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -7,10 +7,10 @@ use RectorPrefix202212\Nette\Utils\Strings;
|
|||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||
use Rector\PHPUnit\NodeFinder\DataProviderClassMethodFinder;
|
||||
use Rector\PHPUnit\PhpDoc\DataProviderMethodRenamer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
|
@ -25,9 +25,21 @@ final class RemoveDataProviderTestPrefixRector extends AbstractRector
|
|||
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
|
||||
*/
|
||||
private $testsNodeAnalyzer;
|
||||
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PHPUnit\NodeFinder\DataProviderClassMethodFinder
|
||||
*/
|
||||
private $dataProviderClassMethodFinder;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PHPUnit\PhpDoc\DataProviderMethodRenamer
|
||||
*/
|
||||
private $dataProviderMethodRenamer;
|
||||
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, DataProviderClassMethodFinder $dataProviderClassMethodFinder, DataProviderMethodRenamer $dataProviderMethodRenamer)
|
||||
{
|
||||
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
|
||||
$this->dataProviderClassMethodFinder = $dataProviderClassMethodFinder;
|
||||
$this->dataProviderMethodRenamer = $dataProviderMethodRenamer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
|
@ -82,62 +94,21 @@ CODE_SAMPLE
|
|||
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
|
||||
return null;
|
||||
}
|
||||
$providerMethodNamesToNewNames = $this->renameDataProviderAnnotationsAndCollectRenamedMethods($node);
|
||||
if ($providerMethodNamesToNewNames === []) {
|
||||
return null;
|
||||
}
|
||||
$this->renameProviderMethods($node, $providerMethodNamesToNewNames);
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function renameDataProviderAnnotationsAndCollectRenamedMethods(Class_ $class) : array
|
||||
{
|
||||
$oldToNewMethodNames = [];
|
||||
foreach ($class->getMethods() as $classMethod) {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
|
||||
$dataProviderTagValueNodes = $phpDocInfo->getTagsByName('dataProvider');
|
||||
if ($dataProviderTagValueNodes === []) {
|
||||
$hasChanged = \false;
|
||||
$dataProviderClassMethods = $this->dataProviderClassMethodFinder->find($node);
|
||||
foreach ($dataProviderClassMethods as $dataProviderClassMethod) {
|
||||
if (!$this->isName($dataProviderClassMethod, 'test*')) {
|
||||
continue;
|
||||
}
|
||||
foreach ($dataProviderTagValueNodes as $dataProviderTagValueNode) {
|
||||
if (!$dataProviderTagValueNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$oldMethodName = $dataProviderTagValueNode->value->value;
|
||||
if (\strncmp($oldMethodName, 'test', \strlen('test')) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$newMethodName = $this->createNewMethodName($oldMethodName);
|
||||
$dataProviderTagValueNode->value->value = Strings::replace($oldMethodName, '#' . \preg_quote($oldMethodName, '#') . '#', $newMethodName);
|
||||
// invoke reprint
|
||||
$dataProviderTagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, null);
|
||||
$phpDocInfo->markAsChanged();
|
||||
$oldMethodNameWithoutBrackets = \rtrim($oldMethodName, '()');
|
||||
$newMethodWithoutBrackets = $this->createNewMethodName($oldMethodNameWithoutBrackets);
|
||||
$oldToNewMethodNames[$oldMethodNameWithoutBrackets] = $newMethodWithoutBrackets;
|
||||
}
|
||||
$shortMethodName = Strings::substring($dataProviderClassMethod->name->toString(), 4);
|
||||
$shortMethodName = \lcfirst($shortMethodName);
|
||||
$dataProviderClassMethod->name = new Identifier($shortMethodName);
|
||||
$hasChanged = \true;
|
||||
}
|
||||
return $oldToNewMethodNames;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewMethodsNames
|
||||
*/
|
||||
private function renameProviderMethods(Class_ $class, array $oldToNewMethodsNames) : void
|
||||
{
|
||||
foreach ($class->getMethods() as $classMethod) {
|
||||
foreach ($oldToNewMethodsNames as $oldName => $newName) {
|
||||
if (!$this->isName($classMethod, $oldName)) {
|
||||
continue;
|
||||
}
|
||||
$classMethod->name = new Identifier($newName);
|
||||
}
|
||||
$this->dataProviderMethodRenamer->removeTestPrefix($node);
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
private function createNewMethodName(string $oldMethodName) : string
|
||||
{
|
||||
$newMethodName = Strings::substring($oldMethodName, \strlen('test'));
|
||||
return \lcfirst($newMethodName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
110
vendor/rector/rector-phpunit/src/Rector/Class_/StaticDataProviderClassMethodRector.php
vendored
Normal file
110
vendor/rector/rector-phpunit/src/Rector/Class_/StaticDataProviderClassMethodRector.php
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\Class_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||
use Rector\PHPUnit\NodeFinder\DataProviderClassMethodFinder;
|
||||
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\PHPUnit\Tests\Rector\Class_\StaticDataProviderClassMethodRector\StaticDataProviderClassMethodRectorTest
|
||||
*/
|
||||
final class StaticDataProviderClassMethodRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
|
||||
*/
|
||||
private $testsNodeAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PHPUnit\NodeFinder\DataProviderClassMethodFinder
|
||||
*/
|
||||
private $dataProviderClassMethodFinder;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Privatization\NodeManipulator\VisibilityManipulator
|
||||
*/
|
||||
private $visibilityManipulator;
|
||||
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, DataProviderClassMethodFinder $dataProviderClassMethodFinder, VisibilityManipulator $visibilityManipulator)
|
||||
{
|
||||
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
|
||||
$this->dataProviderClassMethodFinder = $dataProviderClassMethodFinder;
|
||||
$this->visibilityManipulator = $visibilityManipulator;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change data provider methods to static', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
}
|
||||
|
||||
public function provideData()
|
||||
{
|
||||
yield [1];
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
}
|
||||
|
||||
public static function provideData()
|
||||
{
|
||||
yield [1];
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Class_::class];
|
||||
}
|
||||
/**
|
||||
* @param Class_ $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
|
||||
return null;
|
||||
}
|
||||
// 1. find all data providers
|
||||
$dataProviderClassMethods = $this->dataProviderClassMethodFinder->find($node);
|
||||
$hasChanged = \false;
|
||||
foreach ($dataProviderClassMethods as $dataProviderClassMethod) {
|
||||
if ($dataProviderClassMethod->isStatic()) {
|
||||
continue;
|
||||
}
|
||||
$this->visibilityManipulator->makeStatic($dataProviderClassMethod);
|
||||
$hasChanged = \true;
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,10 @@ final class PHPUnitSetList implements SetListInterface
|
|||
* @var string
|
||||
*/
|
||||
public const PHPUNIT_91 = __DIR__ . '/../../config/sets/phpunit91.php';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PHPUNIT_100 = __DIR__ . '/../../config/sets/phpunit100.php';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
47
vendor/rector/rector-phpunit/src/ValueObject/AnnotationWithValueToAttribute.php
vendored
Normal file
47
vendor/rector/rector-phpunit/src/ValueObject/AnnotationWithValueToAttribute.php
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\ValueObject;
|
||||
|
||||
final class AnnotationWithValueToAttribute
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $annotationName;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $attributeClass;
|
||||
/**
|
||||
* @var array<mixed, mixed>
|
||||
* @readonly
|
||||
*/
|
||||
private $valueMap = [];
|
||||
/**
|
||||
* @param array<mixed, mixed> $valueMap
|
||||
*/
|
||||
public function __construct(string $annotationName, string $attributeClass, array $valueMap = [])
|
||||
{
|
||||
$this->annotationName = $annotationName;
|
||||
$this->attributeClass = $attributeClass;
|
||||
$this->valueMap = $valueMap;
|
||||
}
|
||||
public function getAnnotationName() : string
|
||||
{
|
||||
return $this->annotationName;
|
||||
}
|
||||
public function getAttributeClass() : string
|
||||
{
|
||||
return $this->attributeClass;
|
||||
}
|
||||
/**
|
||||
* @return array<mixed, mixed>
|
||||
*/
|
||||
public function getValueMap() : array
|
||||
{
|
||||
return $this->valueMap;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user