mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit e913b612219671cd12678f99b767504e801dca45
e913b61221
[TypeDeclaration] Skip ArrayShapeFromConstantArrayReturnRector on key has colon (#1962)
This commit is contained in:
parent
0b156d61ee
commit
a410a85c48
@ -9,7 +9,10 @@ use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
|
||||
use PHPStan\Type\Constant\ConstantArrayType;
|
||||
use PHPStan\Type\Constant\ConstantStringType;
|
||||
use PHPStan\Type\NeverType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
@ -23,6 +26,10 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
*/
|
||||
final class ArrayShapeFromConstantArrayReturnRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private const SKIPPED_CHARS = [':', '@'];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\Astral\TypeAnalyzer\ClassMethodReturnTypeResolver
|
||||
@ -89,8 +96,8 @@ CODE_SAMPLE
|
||||
if (!$returnExprType instanceof \PHPStan\Type\Constant\ConstantArrayType) {
|
||||
return null;
|
||||
}
|
||||
// empty array
|
||||
if ($returnExprType->getKeyType() instanceof \PHPStan\Type\NeverType) {
|
||||
$keyType = $returnExprType->getKeyType();
|
||||
if ($this->shouldSkipKeyType($keyType)) {
|
||||
return null;
|
||||
}
|
||||
$returnType = $this->classMethodReturnTypeResolver->resolve($node, $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE));
|
||||
@ -111,4 +118,23 @@ CODE_SAMPLE
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
private function shouldSkipKeyType(\PHPStan\Type\Type $keyType) : bool
|
||||
{
|
||||
// empty array
|
||||
if ($keyType instanceof \PHPStan\Type\NeverType) {
|
||||
return \true;
|
||||
}
|
||||
$types = $keyType instanceof \PHPStan\Type\UnionType ? $keyType->getTypes() : [$keyType];
|
||||
foreach ($types as $type) {
|
||||
if (!$type instanceof \PHPStan\Type\Constant\ConstantStringType) {
|
||||
continue;
|
||||
}
|
||||
foreach (self::SKIPPED_CHARS as $skippedChar) {
|
||||
if (\strpos($type->getValue(), $skippedChar) !== \false) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'dfa6312dd575abf8aa17f4b4da49b7bc0fa892fb';
|
||||
public const PACKAGE_VERSION = 'e913b612219671cd12678f99b767504e801dca45';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-03-26 20:24:37';
|
||||
public const RELEASE_DATE = '2022-03-26 23:18:17';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220326\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 ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80::getLoader();
|
||||
return ComposerAutoloaderInit59f75c44a65a63c1e31c8defa62a8d15::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 ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80
|
||||
class ComposerAutoloaderInit59f75c44a65a63c1e31c8defa62a8d15
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit59f75c44a65a63c1e31c8defa62a8d15', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit59f75c44a65a63c1e31c8defa62a8d15', '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\ComposerStaticInit5e7b705bb9d4c9f153c0529320bf2c80::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit59f75c44a65a63c1e31c8defa62a8d15::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,12 +42,12 @@ class ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit5e7b705bb9d4c9f153c0529320bf2c80::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit59f75c44a65a63c1e31c8defa62a8d15::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire5e7b705bb9d4c9f153c0529320bf2c80($fileIdentifier, $file);
|
||||
composerRequire59f75c44a65a63c1e31c8defa62a8d15($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -59,7 +59,7 @@ class ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire5e7b705bb9d4c9f153c0529320bf2c80($fileIdentifier, $file)
|
||||
function composerRequire59f75c44a65a63c1e31c8defa62a8d15($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 ComposerStaticInit5e7b705bb9d4c9f153c0529320bf2c80
|
||||
class ComposerStaticInit59f75c44a65a63c1e31c8defa62a8d15
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
@ -3837,9 +3837,9 @@ class ComposerStaticInit5e7b705bb9d4c9f153c0529320bf2c80
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit5e7b705bb9d4c9f153c0529320bf2c80::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit5e7b705bb9d4c9f153c0529320bf2c80::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit5e7b705bb9d4c9f153c0529320bf2c80::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit59f75c44a65a63c1e31c8defa62a8d15::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit59f75c44a65a63c1e31c8defa62a8d15::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit59f75c44a65a63c1e31c8defa62a8d15::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
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('RectorPrefix20220326\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80', false) && !interface_exists('ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80', false) && !trait_exists('ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80', false)) {
|
||||
spl_autoload_call('RectorPrefix20220326\ComposerAutoloaderInit5e7b705bb9d4c9f153c0529320bf2c80');
|
||||
if (!class_exists('ComposerAutoloaderInit59f75c44a65a63c1e31c8defa62a8d15', false) && !interface_exists('ComposerAutoloaderInit59f75c44a65a63c1e31c8defa62a8d15', false) && !trait_exists('ComposerAutoloaderInit59f75c44a65a63c1e31c8defa62a8d15', false)) {
|
||||
spl_autoload_call('RectorPrefix20220326\ComposerAutoloaderInit59f75c44a65a63c1e31c8defa62a8d15');
|
||||
}
|
||||
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('RectorPrefix20220326\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220326\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire5e7b705bb9d4c9f153c0529320bf2c80')) {
|
||||
function composerRequire5e7b705bb9d4c9f153c0529320bf2c80() {
|
||||
return \RectorPrefix20220326\composerRequire5e7b705bb9d4c9f153c0529320bf2c80(...func_get_args());
|
||||
if (!function_exists('composerRequire59f75c44a65a63c1e31c8defa62a8d15')) {
|
||||
function composerRequire59f75c44a65a63c1e31c8defa62a8d15() {
|
||||
return \RectorPrefix20220326\composerRequire59f75c44a65a63c1e31c8defa62a8d15(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user