Updated Rector to commit 5d0138dcef

5d0138dcef Fixture class name fix (#2360)
This commit is contained in:
Tomas Votruba 2022-05-25 08:23:52 +00:00
parent f47835bc59
commit b52fe6d037
9 changed files with 72 additions and 30 deletions

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167
class ComposerAutoloaderInite2df9d91d4faab98bde6ff04234661c4
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInite2df9d91d4faab98bde6ff04234661c4', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInite2df9d91d4faab98bde6ff04234661c4', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitd327a6bd55dffb5543ba74ead9dee167::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInite2df9d91d4faab98bde6ff04234661c4::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitd327a6bd55dffb5543ba74ead9dee167::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInite2df9d91d4faab98bde6ff04234661c4::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequired327a6bd55dffb5543ba74ead9dee167($fileIdentifier, $file);
composerRequiree2df9d91d4faab98bde6ff04234661c4($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167
* @param string $file
* @return void
*/
function composerRequired327a6bd55dffb5543ba74ead9dee167($fileIdentifier, $file)
function composerRequiree2df9d91d4faab98bde6ff04234661c4($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 ComposerStaticInitd327a6bd55dffb5543ba74ead9dee167
class ComposerStaticInite2df9d91d4faab98bde6ff04234661c4
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -3914,9 +3914,9 @@ class ComposerStaticInitd327a6bd55dffb5543ba74ead9dee167
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitd327a6bd55dffb5543ba74ead9dee167::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd327a6bd55dffb5543ba74ead9dee167::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd327a6bd55dffb5543ba74ead9dee167::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInite2df9d91d4faab98bde6ff04234661c4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInite2df9d91d4faab98bde6ff04234661c4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInite2df9d91d4faab98bde6ff04234661c4::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2576,12 +2576,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "5a339401f870b3eeadff135a35bef91f944b3461"
"reference": "cf8effd14ecc484c2e6ac8020afd5234a972fd8b"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/5a339401f870b3eeadff135a35bef91f944b3461",
"reference": "5a339401f870b3eeadff135a35bef91f944b3461",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/cf8effd14ecc484c2e6ac8020afd5234a972fd8b",
"reference": "cf8effd14ecc484c2e6ac8020afd5234a972fd8b",
"shasum": ""
},
"require": {
@ -2606,7 +2606,7 @@
"symplify\/rule-doc-generator": "^10.0",
"symplify\/vendor-patches": "^10.0"
},
"time": "2022-05-12T16:45:32+00:00",
"time": "2022-05-25T08:17:28+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-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43ca394'), '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 4a907ed'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2e0f600'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5f84d90'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), '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 5a33940'), '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 6e0ca50'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c1df6e1'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43ca394'), '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 4a907ed'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2e0f600'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5f84d90'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), '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 cf8effd'), '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 6e0ca50'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c1df6e1'));
private function __construct()
{
}

View File

@ -15,6 +15,10 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*/
final class GetMockBuilderGetMockToCreateMockRector extends \Rector\Core\Rector\AbstractRector
{
/**
* @var string[]
*/
private const USELESS_METHOD_NAMES = ['disableOriginalConstructor', 'onlyMethods', 'setMethods', 'setMethodsExcept'];
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove getMockBuilder() to createMock()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
@ -61,15 +65,19 @@ CODE_SAMPLE
if (!$node->var instanceof \PhpParser\Node\Expr\MethodCall) {
return null;
}
$getMockBuilderMethodCall = $this->isName($node->var->name, 'disableOriginalConstructor') ? $node->var->var : $node->var;
if (!$getMockBuilderMethodCall instanceof \PhpParser\Node\Expr\MethodCall) {
// traverse up over useless methods until we reach the top one
$currentMethodCall = $node->var;
while ($currentMethodCall instanceof \PhpParser\Node\Expr\MethodCall && $this->isNames($currentMethodCall->name, self::USELESS_METHOD_NAMES)) {
$currentMethodCall = $currentMethodCall->var;
}
if (!$currentMethodCall instanceof \PhpParser\Node\Expr\MethodCall) {
return null;
}
if (!$this->isName($getMockBuilderMethodCall->name, 'getMockBuilder')) {
if (!$this->isName($currentMethodCall->name, 'getMockBuilder')) {
return null;
}
$args = $getMockBuilderMethodCall->args;
$thisVariable = $getMockBuilderMethodCall->var;
$args = $currentMethodCall->args;
$thisVariable = $currentMethodCall->var;
return new \PhpParser\Node\Expr\MethodCall($thisVariable, 'createMock', $args);
}
}

View File

@ -7,7 +7,9 @@ use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -24,13 +26,41 @@ final class GetMockRector extends \Rector\Core\Rector\AbstractRector
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
*/
private $testsNodeAnalyzer;
public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer)
/**
* @readonly
* @var \Rector\Core\Reflection\ReflectionResolver
*/
private $reflectionResolver;
public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver)
{
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
$this->reflectionResolver = $reflectionResolver;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns getMock*() methods to createMock()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->getMock("Class");', '$this->createMock("Class");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->getMockWithoutInvokingTheOriginalConstructor("Class");', '$this->createMock("Class");')]);
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns getMock*() methods to createMock()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
public function test()
{
$classMock = $this->getMock("Class");
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
public function test()
{
$classMock = $this->createMock("Class");
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
@ -50,6 +80,10 @@ final class GetMockRector extends \Rector\Core\Rector\AbstractRector
if ($node instanceof \PhpParser\Node\Expr\MethodCall && $node->var instanceof \PhpParser\Node\Expr\MethodCall) {
return null;
}
$classReflection = $this->reflectionResolver->resolveClassReflectionSourceObject($node);
if ($classReflection instanceof \PHPStan\Reflection\ClassReflection && $classReflection->getName() !== 'PHPUnit\\Framework\\TestCase') {
return null;
}
// narrow args to one
if (\count($node->args) > 1) {
$node->args = [$node->args[0]];

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220525\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167', false) && !interface_exists('ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167', false) && !trait_exists('ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167', false)) {
spl_autoload_call('RectorPrefix20220525\ComposerAutoloaderInitd327a6bd55dffb5543ba74ead9dee167');
if (!class_exists('ComposerAutoloaderInite2df9d91d4faab98bde6ff04234661c4', false) && !interface_exists('ComposerAutoloaderInite2df9d91d4faab98bde6ff04234661c4', false) && !trait_exists('ComposerAutoloaderInite2df9d91d4faab98bde6ff04234661c4', false)) {
spl_autoload_call('RectorPrefix20220525\ComposerAutoloaderInite2df9d91d4faab98bde6ff04234661c4');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220525\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220525\print_node(...func_get_args());
}
}
if (!function_exists('composerRequired327a6bd55dffb5543ba74ead9dee167')) {
function composerRequired327a6bd55dffb5543ba74ead9dee167() {
return \RectorPrefix20220525\composerRequired327a6bd55dffb5543ba74ead9dee167(...func_get_args());
if (!function_exists('composerRequiree2df9d91d4faab98bde6ff04234661c4')) {
function composerRequiree2df9d91d4faab98bde6ff04234661c4() {
return \RectorPrefix20220525\composerRequiree2df9d91d4faab98bde6ff04234661c4(...func_get_args());
}
}
if (!function_exists('scanPath')) {