mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit f09e54b79cdc481f2033482fd206f6308642b2e0
f09e54b79c
Skip already correct param type (#1688)
This commit is contained in:
parent
165b238ab7
commit
d5aa796890
@ -4,9 +4,12 @@ declare (strict_types=1);
|
||||
namespace Rector\Php80\Rector\FunctionLike;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\Expr\ArrowFunction;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
@ -152,10 +155,7 @@ CODE_SAMPLE
|
||||
continue;
|
||||
}
|
||||
$phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedParamType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
if (!$phpParserUnionType instanceof \PhpParser\Node\UnionType) {
|
||||
continue;
|
||||
}
|
||||
if ($param->type instanceof \PhpParser\Node\UnionType) {
|
||||
if ($this->shouldSkipParamTypeRefactor($param->type, $phpParserUnionType)) {
|
||||
continue;
|
||||
}
|
||||
$param->type = $phpParserUnionType;
|
||||
@ -222,4 +222,28 @@ CODE_SAMPLE
|
||||
}
|
||||
return $this->typeFactory->createMixedPassedOrUnionType($singleArrayTypes);
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name|null $type
|
||||
* @param \PhpParser\Node|\PhpParser\Node\ComplexType|\PhpParser\Node\Name|null $phpParserUnionType
|
||||
*/
|
||||
private function shouldSkipParamTypeRefactor($type, $phpParserUnionType) : bool
|
||||
{
|
||||
if (!$phpParserUnionType instanceof \PhpParser\Node\UnionType) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof \PhpParser\Node\UnionType) {
|
||||
return \true;
|
||||
}
|
||||
if (\count($phpParserUnionType->types) > 1) {
|
||||
return \false;
|
||||
}
|
||||
$firstType = $phpParserUnionType->types[0];
|
||||
if (!$firstType instanceof \PhpParser\Node\Name\FullyQualified) {
|
||||
return \false;
|
||||
}
|
||||
if (!$type instanceof \PhpParser\Node\Name\FullyQualified) {
|
||||
return \false;
|
||||
}
|
||||
return $type->toString() === $firstType->toString();
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '94e7ac8ef85be89b0ae97e3b12d023be32cc2014';
|
||||
public const PACKAGE_VERSION = 'f09e54b79cdc481f2033482fd206f6308642b2e0';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-01-17 00:05:22';
|
||||
public const RELEASE_DATE = '2022-01-17 10:01:28';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220117\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c::getLoader();
|
||||
return ComposerAutoloaderInit4abf1288b7de123e7edd680b6b96d175::getLoader();
|
||||
|
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 ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c
|
||||
class ComposerAutoloaderInit4abf1288b7de123e7edd680b6b96d175
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4abf1288b7de123e7edd680b6b96d175', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4abf1288b7de123e7edd680b6b96d175', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd18f80bd652820eebeb58fdc799b3b4c::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4abf1288b7de123e7edd680b6b96d175::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,12 +42,12 @@ class ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitd18f80bd652820eebeb58fdc799b3b4c::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit4abf1288b7de123e7edd680b6b96d175::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequired18f80bd652820eebeb58fdc799b3b4c($fileIdentifier, $file);
|
||||
composerRequire4abf1288b7de123e7edd680b6b96d175($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -59,7 +59,7 @@ class ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequired18f80bd652820eebeb58fdc799b3b4c($fileIdentifier, $file)
|
||||
function composerRequire4abf1288b7de123e7edd680b6b96d175($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitd18f80bd652820eebeb58fdc799b3b4c
|
||||
class ComposerStaticInit4abf1288b7de123e7edd680b6b96d175
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -3865,9 +3865,9 @@ class ComposerStaticInitd18f80bd652820eebeb58fdc799b3b4c
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd18f80bd652820eebeb58fdc799b3b4c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd18f80bd652820eebeb58fdc799b3b4c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd18f80bd652820eebeb58fdc799b3b4c::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4abf1288b7de123e7edd680b6b96d175::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4abf1288b7de123e7edd680b6b96d175::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4abf1288b7de123e7edd680b6b96d175::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -2590,12 +2590,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "5c3c503bf3792f3934bcee5c1e868e7d36e1881f"
|
||||
"reference": "e477354e17373bbb79ac30e9407e84044b7cef1b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/5c3c503bf3792f3934bcee5c1e868e7d36e1881f",
|
||||
"reference": "5c3c503bf3792f3934bcee5c1e868e7d36e1881f",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/e477354e17373bbb79ac30e9407e84044b7cef1b",
|
||||
"reference": "e477354e17373bbb79ac30e9407e84044b7cef1b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2623,7 +2623,7 @@
|
||||
"symplify\/rule-doc-generator": "^10.0",
|
||||
"symplify\/vendor-patches": "^10.0"
|
||||
},
|
||||
"time": "2022-01-06T14:18:51+00:00",
|
||||
"time": "2022-01-17T00:40:43+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
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-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 f601f07'), '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 e8de3b0'), '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 df58e86'), '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 96d50d4'), '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 eb859a5'), '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 3f56f3b'), '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 cd2eb3d'), '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 5c3c503'), '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 d4a362b'));
|
||||
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 f601f07'), '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 e8de3b0'), '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 df58e86'), '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 96d50d4'), '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 eb859a5'), '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 3f56f3b'), '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 cd2eb3d'), '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 e477354'), '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 d4a362b'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -4,8 +4,10 @@ declare (strict_types=1);
|
||||
namespace Rector\Symfony\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\ThisType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||
use Rector\Symfony\NodeAnalyzer\DependencyInjectionMethodCallAnalyzer;
|
||||
@ -76,7 +78,7 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\DependencyInjection\\ContainerInterface'))) {
|
||||
if (!$this->isContainerObjectType($node->var)) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'get')) {
|
||||
@ -87,4 +89,15 @@ CODE_SAMPLE
|
||||
}
|
||||
return $this->dependencyInjectionMethodCallAnalyzer->replaceMethodCallWithPropertyFetchAndDependency($node);
|
||||
}
|
||||
private function isContainerObjectType(\PhpParser\Node\Expr $expr) : bool
|
||||
{
|
||||
$callerType = $this->getType($expr);
|
||||
if ($callerType instanceof \PHPStan\Type\ThisType) {
|
||||
$callerType = $callerType->getStaticObjectType();
|
||||
}
|
||||
if (!$callerType instanceof \PHPStan\Type\ObjectType) {
|
||||
return \false;
|
||||
}
|
||||
return $callerType->isInstanceOf('Symfony\\Component\\DependencyInjection\\ContainerInterface')->yes();
|
||||
}
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -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('RectorPrefix20220117\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c', false) && !interface_exists('ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c', false) && !trait_exists('ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c', false)) {
|
||||
spl_autoload_call('RectorPrefix20220117\ComposerAutoloaderInitd18f80bd652820eebeb58fdc799b3b4c');
|
||||
if (!class_exists('ComposerAutoloaderInit4abf1288b7de123e7edd680b6b96d175', false) && !interface_exists('ComposerAutoloaderInit4abf1288b7de123e7edd680b6b96d175', false) && !trait_exists('ComposerAutoloaderInit4abf1288b7de123e7edd680b6b96d175', false)) {
|
||||
spl_autoload_call('RectorPrefix20220117\ComposerAutoloaderInit4abf1288b7de123e7edd680b6b96d175');
|
||||
}
|
||||
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('RectorPrefix20220117\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -71,9 +71,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220117\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequired18f80bd652820eebeb58fdc799b3b4c')) {
|
||||
function composerRequired18f80bd652820eebeb58fdc799b3b4c() {
|
||||
return \RectorPrefix20220117\composerRequired18f80bd652820eebeb58fdc799b3b4c(...func_get_args());
|
||||
if (!function_exists('composerRequire4abf1288b7de123e7edd680b6b96d175')) {
|
||||
function composerRequire4abf1288b7de123e7edd680b6b96d175() {
|
||||
return \RectorPrefix20220117\composerRequire4abf1288b7de123e7edd680b6b96d175(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user