mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit 3ddac18c51a77b07caae35d538b88bad0004166a
3ddac18c51
[Php74] Add class-string not filled by __construct to be to nullable string on TypedPropertyRector (#2123)
This commit is contained in:
parent
af205b10a4
commit
7e10a637a2
@ -23,6 +23,7 @@ use PHPStan\Type\UnionType;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\NodeTypeResolver\PHPStan\TypeHasher;
|
||||
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
|
||||
use Rector\TypeDeclaration\TypeNormalizer;
|
||||
@ -58,7 +59,12 @@ final class TypeComparator
|
||||
* @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory
|
||||
*/
|
||||
private $typeFactory;
|
||||
public function __construct(\Rector\NodeTypeResolver\PHPStan\TypeHasher $typeHasher, \Rector\TypeDeclaration\TypeNormalizer $typeNormalizer, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\ArrayTypeComparator $arrayTypeComparator, \Rector\NodeTypeResolver\TypeComparator\ScalarTypeComparator $scalarTypeComparator, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer
|
||||
*/
|
||||
private $unionTypeAnalyzer;
|
||||
public function __construct(\Rector\NodeTypeResolver\PHPStan\TypeHasher $typeHasher, \Rector\TypeDeclaration\TypeNormalizer $typeNormalizer, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\ArrayTypeComparator $arrayTypeComparator, \Rector\NodeTypeResolver\TypeComparator\ScalarTypeComparator $scalarTypeComparator, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer)
|
||||
{
|
||||
$this->typeHasher = $typeHasher;
|
||||
$this->typeNormalizer = $typeNormalizer;
|
||||
@ -66,6 +72,7 @@ final class TypeComparator
|
||||
$this->arrayTypeComparator = $arrayTypeComparator;
|
||||
$this->scalarTypeComparator = $scalarTypeComparator;
|
||||
$this->typeFactory = $typeFactory;
|
||||
$this->unionTypeAnalyzer = $unionTypeAnalyzer;
|
||||
}
|
||||
public function areTypesEqual(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool
|
||||
{
|
||||
@ -142,9 +149,13 @@ final class TypeComparator
|
||||
if (!$exactType instanceof \PHPStan\Type\UnionType) {
|
||||
return \true;
|
||||
}
|
||||
$assumpionTypeTypes = $assumptionType->getTypes();
|
||||
$exactTypeTypes = $exactType->getTypes();
|
||||
return \count($assumpionTypeTypes) > \count($exactTypeTypes);
|
||||
$countAssumpionTypeTypes = \count($assumptionType->getTypes());
|
||||
$countExactTypeTypes = \count($exactType->getTypes());
|
||||
if ($countAssumpionTypeTypes === $countExactTypeTypes) {
|
||||
$unionType = $this->unionTypeAnalyzer->mapGenericToClassStringType($exactType);
|
||||
return $this->areTypesEqual($assumptionType, $unionType);
|
||||
}
|
||||
return $countAssumpionTypeTypes > $countExactTypeTypes;
|
||||
}
|
||||
private function areAliasedObjectMatchingFqnObject(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool
|
||||
{
|
||||
@ -198,13 +209,14 @@ final class TypeComparator
|
||||
}
|
||||
private function normalizeSingleUnionType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type
|
||||
{
|
||||
if ($type instanceof \PHPStan\Type\UnionType) {
|
||||
$uniqueTypes = $this->typeFactory->uniquateTypes($type->getTypes());
|
||||
if (\count($uniqueTypes) === 1) {
|
||||
return $uniqueTypes[0];
|
||||
}
|
||||
if (!$type instanceof \PHPStan\Type\UnionType) {
|
||||
return $type;
|
||||
}
|
||||
return $type;
|
||||
$uniqueTypes = $this->typeFactory->uniquateTypes($type->getTypes());
|
||||
if (\count($uniqueTypes) !== 1) {
|
||||
return $type;
|
||||
}
|
||||
return $uniqueTypes[0];
|
||||
}
|
||||
private function areArrayUnionConstantEqualTypes(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool
|
||||
{
|
||||
|
@ -5,8 +5,10 @@ namespace Rector\PHPStanStaticTypeMapper\TypeAnalyzer;
|
||||
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\BooleanType;
|
||||
use PHPStan\Type\ClassStringType;
|
||||
use PHPStan\Type\Constant\ConstantStringType;
|
||||
use PHPStan\Type\FloatType;
|
||||
use PHPStan\Type\Generic\GenericClassStringType;
|
||||
use PHPStan\Type\IntegerType;
|
||||
use PHPStan\Type\IterableType;
|
||||
use PHPStan\Type\NullType;
|
||||
@ -119,4 +121,14 @@ final class UnionTypeAnalyzer
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
public function mapGenericToClassStringType(\PHPStan\Type\UnionType $unionType) : \PHPStan\Type\UnionType
|
||||
{
|
||||
$types = $unionType->getTypes();
|
||||
foreach ($types as $key => $type) {
|
||||
if ($type instanceof \PHPStan\Type\Generic\GenericClassStringType) {
|
||||
$types[$key] = new \PHPStan\Type\ClassStringType();
|
||||
}
|
||||
}
|
||||
return new \PHPStan\Type\UnionType($types);
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '75fccc5d5838eb37ba35266848bacd13a0e5b58c';
|
||||
public const PACKAGE_VERSION = '3ddac18c51a77b07caae35d538b88bad0004166a';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-04-22 02:43:25';
|
||||
public const RELEASE_DATE = '2022-04-22 16:22:21';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391::getLoader();
|
||||
return ComposerAutoloaderInitf559d986824a8d346f6f1a2ea2b93fe6::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 ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391
|
||||
class ComposerAutoloaderInitf559d986824a8d346f6f1a2ea2b93fe6
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitf559d986824a8d346f6f1a2ea2b93fe6', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitf559d986824a8d346f6f1a2ea2b93fe6', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4f414cb86b5a3518b108325cfc1fe391::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitf559d986824a8d346f6f1a2ea2b93fe6::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit4f414cb86b5a3518b108325cfc1fe391::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitf559d986824a8d346f6f1a2ea2b93fe6::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire4f414cb86b5a3518b108325cfc1fe391($fileIdentifier, $file);
|
||||
composerRequiref559d986824a8d346f6f1a2ea2b93fe6($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire4f414cb86b5a3518b108325cfc1fe391($fileIdentifier, $file)
|
||||
function composerRequiref559d986824a8d346f6f1a2ea2b93fe6($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 ComposerStaticInit4f414cb86b5a3518b108325cfc1fe391
|
||||
class ComposerStaticInitf559d986824a8d346f6f1a2ea2b93fe6
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
@ -3869,9 +3869,9 @@ class ComposerStaticInit4f414cb86b5a3518b108325cfc1fe391
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4f414cb86b5a3518b108325cfc1fe391::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4f414cb86b5a3518b108325cfc1fe391::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4f414cb86b5a3518b108325cfc1fe391::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitf559d986824a8d346f6f1a2ea2b93fe6::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitf559d986824a8d346f6f1a2ea2b93fe6::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitf559d986824a8d346f6f1a2ea2b93fe6::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
14
vendor/composer/installed.json
vendored
14
vendor/composer/installed.json
vendored
@ -1036,17 +1036,17 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan\/phpdoc-parser",
|
||||
"version": "1.4.4",
|
||||
"version_normalized": "1.4.4.0",
|
||||
"version": "1.4.5",
|
||||
"version_normalized": "1.4.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/phpstan\/phpdoc-parser.git",
|
||||
"reference": "d8e9fd97ca11f2f24fc1aafbcfb1f78bce762267"
|
||||
"reference": "129a63b3bc7caeb593c224c41f420675e63cfefc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/d8e9fd97ca11f2f24fc1aafbcfb1f78bce762267",
|
||||
"reference": "d8e9fd97ca11f2f24fc1aafbcfb1f78bce762267",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/129a63b3bc7caeb593c224c41f420675e63cfefc",
|
||||
"reference": "129a63b3bc7caeb593c224c41f420675e63cfefc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1060,7 +1060,7 @@
|
||||
"phpunit\/phpunit": "^9.5",
|
||||
"symfony\/process": "^5.2"
|
||||
},
|
||||
"time": "2022-04-14T12:24:06+00:00",
|
||||
"time": "2022-04-22T11:11:01+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
@ -1077,7 +1077,7 @@
|
||||
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/phpstan\/phpdoc-parser\/issues",
|
||||
"source": "https:\/\/github.com\/phpstan\/phpdoc-parser\/tree\/1.4.4"
|
||||
"source": "https:\/\/github.com\/phpstan\/phpdoc-parser\/tree\/1.4.5"
|
||||
},
|
||||
"install-path": "..\/phpstan\/phpdoc-parser"
|
||||
},
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -195,11 +195,15 @@ class TypeParser
|
||||
$negated = \true;
|
||||
$tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER);
|
||||
}
|
||||
$targetType = $this->parseAtomic($tokens);
|
||||
$targetType = $this->parse($tokens);
|
||||
$tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE);
|
||||
$ifType = $this->parseAtomic($tokens);
|
||||
$tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$ifType = $this->parse($tokens);
|
||||
$tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON);
|
||||
$elseType = $this->parseAtomic($tokens);
|
||||
$tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$elseType = $this->parse($tokens);
|
||||
return new \PHPStan\PhpDocParser\Ast\Type\ConditionalTypeForParameterNode($parameterName, $targetType, $ifType, $elseType, $negated);
|
||||
}
|
||||
/** @phpstan-impure */
|
||||
|
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('RectorPrefix20220422\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391', false) && !interface_exists('ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391', false) && !trait_exists('ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391', false)) {
|
||||
spl_autoload_call('RectorPrefix20220422\ComposerAutoloaderInit4f414cb86b5a3518b108325cfc1fe391');
|
||||
if (!class_exists('ComposerAutoloaderInitf559d986824a8d346f6f1a2ea2b93fe6', false) && !interface_exists('ComposerAutoloaderInitf559d986824a8d346f6f1a2ea2b93fe6', false) && !trait_exists('ComposerAutoloaderInitf559d986824a8d346f6f1a2ea2b93fe6', false)) {
|
||||
spl_autoload_call('RectorPrefix20220422\ComposerAutoloaderInitf559d986824a8d346f6f1a2ea2b93fe6');
|
||||
}
|
||||
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('RectorPrefix20220422\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220422\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire4f414cb86b5a3518b108325cfc1fe391')) {
|
||||
function composerRequire4f414cb86b5a3518b108325cfc1fe391() {
|
||||
return \RectorPrefix20220422\composerRequire4f414cb86b5a3518b108325cfc1fe391(...func_get_args());
|
||||
if (!function_exists('composerRequiref559d986824a8d346f6f1a2ea2b93fe6')) {
|
||||
function composerRequiref559d986824a8d346f6f1a2ea2b93fe6() {
|
||||
return \RectorPrefix20220422\composerRequiref559d986824a8d346f6f1a2ea2b93fe6(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user