Updated Rector to commit 13d73b380d5adedbccbe37afb0aff2e2319a7e27

13d73b380d [DeadCode] Handle typed and non-typed param on RecastingRemovalRector (#675)
This commit is contained in:
Tomas Votruba 2021-08-14 13:12:49 +00:00
parent 2ddd79edde
commit 17c50e80ed
6 changed files with 36 additions and 20 deletions

View File

@ -14,6 +14,7 @@ use PhpParser\Node\Expr\Cast\Object_;
use PhpParser\Node\Expr\Cast\String_;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\FunctionLike;
use PHPStan\Reflection\Php\PhpPropertyReflection;
use PHPStan\Type\ArrayType;
use PHPStan\Type\BooleanType;
@ -100,7 +101,7 @@ CODE_SAMPLE
private function shouldSkip(\PhpParser\Node\Expr $expr) : bool
{
if (!$this->propertyFetchAnalyzer->isPropertyFetch($expr)) {
return \false;
return $this->isNonTypedFromParam($expr);
}
/** @var PropertyFetch|StaticPropertyFetch $expr */
$phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($expr);
@ -110,4 +111,19 @@ CODE_SAMPLE
$nativeType = $phpPropertyReflection->getNativeType();
return $nativeType instanceof \PHPStan\Type\MixedType;
}
private function isNonTypedFromParam(\PhpParser\Node\Expr $expr) : bool
{
$functionLike = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\FunctionLike::class);
if (!$functionLike instanceof \PhpParser\Node\FunctionLike) {
return \false;
}
$params = $functionLike->getParams();
foreach ($params as $param) {
if (!$this->nodeComparator->areNodesEqual($param->var, $expr)) {
continue;
}
return $param->type === null;
}
return \false;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'ab02ce4b58d1d83437aae557d8ee616ac0bbe936';
public const PACKAGE_VERSION = '13d73b380d5adedbccbe37afb0aff2e2319a7e27';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-14 14:51:34';
public const RELEASE_DATE = '2021-08-14 15:01:18';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210814\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27::getLoader();
return ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27
class ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', '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\ComposerStaticInit34867005c9e967bcd65b42e0e6b74e27::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit34867005c9e967bcd65b42e0e6b74e27::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire34867005c9e967bcd65b42e0e6b74e27($fileIdentifier, $file);
composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire34867005c9e967bcd65b42e0e6b74e27($fileIdentifier, $file)
function composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit34867005c9e967bcd65b42e0e6b74e27
class ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3850,9 +3850,9 @@ class ComposerStaticInit34867005c9e967bcd65b42e0e6b74e27
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit34867005c9e967bcd65b42e0e6b74e27::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit34867005c9e967bcd65b42e0e6b74e27::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit34867005c9e967bcd65b42e0e6b74e27::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::$classMap;
}, null, ClassLoader::class);
}

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('RectorPrefix20210814\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27', false) && !interface_exists('ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27', false) && !trait_exists('ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27', false)) {
spl_autoload_call('RectorPrefix20210814\ComposerAutoloaderInit34867005c9e967bcd65b42e0e6b74e27');
if (!class_exists('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', false) && !interface_exists('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', false) && !trait_exists('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', false)) {
spl_autoload_call('RectorPrefix20210814\ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb');
}
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('RectorPrefix20210814\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210814\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire34867005c9e967bcd65b42e0e6b74e27')) {
function composerRequire34867005c9e967bcd65b42e0e6b74e27() {
return \RectorPrefix20210814\composerRequire34867005c9e967bcd65b42e0e6b74e27(...func_get_args());
if (!function_exists('composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb')) {
function composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb() {
return \RectorPrefix20210814\composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb(...func_get_args());
}
}
if (!function_exists('parseArgs')) {