Updated Rector to commit e978256f4d98b6c8bc8ab55cd3c590420a1d4216

e978256f4d [TypeDeclaration] Skip array key with null coalescing return mixed on ReturnAnnotationIncorrectNullableRector (#2224)
This commit is contained in:
Tomas Votruba 2022-05-04 06:58:03 +00:00
parent b4902f9b94
commit f9a908d40c
6 changed files with 32 additions and 37 deletions

View File

@ -9,13 +9,14 @@ use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection;
use Rector\CodingStyle\NodeAnalyzer\SpreadVariablesCollector;
use Rector\CodingStyle\Reflection\VendorLocationDetector;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -38,17 +39,11 @@ final class UnSpreadOperatorRector extends \Rector\Core\Rector\AbstractRector
* @var \Rector\CodingStyle\Reflection\VendorLocationDetector
*/
private $vendorLocationDetector;
/**
* @readonly
* @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer
*/
private $classChildAnalyzer;
public function __construct(\Rector\CodingStyle\NodeAnalyzer\SpreadVariablesCollector $spreadVariablesCollector, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\CodingStyle\Reflection\VendorLocationDetector $vendorLocationDetector, \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer)
public function __construct(\Rector\CodingStyle\NodeAnalyzer\SpreadVariablesCollector $spreadVariablesCollector, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\CodingStyle\Reflection\VendorLocationDetector $vendorLocationDetector)
{
$this->spreadVariablesCollector = $spreadVariablesCollector;
$this->reflectionResolver = $reflectionResolver;
$this->vendorLocationDetector = $vendorLocationDetector;
$this->classChildAnalyzer = $classChildAnalyzer;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
@ -99,15 +94,7 @@ CODE_SAMPLE
}
private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod
{
$classReflection = $this->reflectionResolver->resolveClassReflection($classMethod);
if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) {
return null;
}
if ($this->isInPHPUnitTestCase($classReflection, $classMethod)) {
return null;
}
$methodName = $this->nodeNameResolver->getName($classMethod);
if ($this->classChildAnalyzer->hasParentClassMethod($classReflection, $methodName)) {
if ($this->isInPHPUnitTestCase($classMethod)) {
return null;
}
$spreadParams = $this->spreadVariablesCollector->resolveFromClassMethod($classMethod);
@ -206,11 +193,19 @@ CODE_SAMPLE
}
return \false;
}
private function isInPHPUnitTestCase(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool
private function isInPHPUnitTestCase(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool
{
$scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
if (!$scope instanceof \PHPStan\Analyser\Scope) {
return \false;
}
if (!$classMethod->isPublic()) {
return \false;
}
$classReflection = $scope->getClassReflection();
if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) {
return \false;
}
return $classReflection->isSubclassOf('PHPUnit\\Framework\\TestCase');
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '6327904617df939cbc81793cdbaab5cc726d3688';
public const PACKAGE_VERSION = 'e978256f4d98b6c8bc8ab55cd3c590420a1d4216';
/**
* @var string
*/
public const RELEASE_DATE = '2022-05-04 08:51:17';
public const RELEASE_DATE = '2022-05-04 08:51:03';
/**
* @var string
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4
class ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiref8f5ffb0bbab6536d43def1c30de86f4($fileIdentifier, $file);
composerRequired18718f34b9e5fa882f1bb073800feee($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4
* @param string $file
* @return void
*/
function composerRequiref8f5ffb0bbab6536d43def1c30de86f4($fileIdentifier, $file)
function composerRequired18718f34b9e5fa882f1bb073800feee($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 ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4
class ComposerStaticInitd18718f34b9e5fa882f1bb073800feee
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -3880,9 +3880,9 @@ class ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::$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('RectorPrefix20220504\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', false) && !interface_exists('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', false) && !trait_exists('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', false)) {
spl_autoload_call('RectorPrefix20220504\ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4');
if (!class_exists('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', false) && !interface_exists('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', false) && !trait_exists('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', false)) {
spl_autoload_call('RectorPrefix20220504\ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee');
}
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('RectorPrefix20220504\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220504\print_node(...func_get_args());
}
}
if (!function_exists('composerRequiref8f5ffb0bbab6536d43def1c30de86f4')) {
function composerRequiref8f5ffb0bbab6536d43def1c30de86f4() {
return \RectorPrefix20220504\composerRequiref8f5ffb0bbab6536d43def1c30de86f4(...func_get_args());
if (!function_exists('composerRequired18718f34b9e5fa882f1bb073800feee')) {
function composerRequired18718f34b9e5fa882f1bb073800feee() {
return \RectorPrefix20220504\composerRequired18718f34b9e5fa882f1bb073800feee(...func_get_args());
}
}
if (!function_exists('scanPath')) {