From 8f07228ff71eeb28cbf43849c83ae5255beb0db3 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 25 Jul 2021 11:00:04 +0000 Subject: [PATCH] Updated Rector to commit 93add0f6c9aef0d30a46c16be1ac1ad013b6d3e4 https://github.com/rectorphp/rector-src/commit/93add0f6c9aef0d30a46c16be1ac1ad013b6d3e4 [TypeDeclaration] Return null when is null on AllAssignNodePropertyTypeInferer::inferProperty() (#504) --- .../DowngradeParameterTypeWideningRector.php | 8 ++++---- .../ConstructorAssignDetector.php | 8 ++++---- .../AllAssignNodePropertyTypeInferer.php | 3 +-- src/Application/VersionResolver.php | 4 ++-- src/Bootstrap/ExtensionConfigResolver.php | 5 ++++- src/NodeManipulator/ClassDependencyManipulator.php | 9 ++++++--- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 +++++++------- vendor/composer/autoload_static.php | 8 ++++---- vendor/scoper-autoload.php | 10 +++++----- 10 files changed, 38 insertions(+), 33 deletions(-) diff --git a/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php b/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php index cdac4b28bf9f..9997d64ee41a 100644 --- a/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php +++ b/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php @@ -51,12 +51,12 @@ final class DowngradeParameterTypeWideningRector extends \Rector\Core\Rector\Abs /** * @var \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer */ - private $autowiredClassMethodAnalyzer; - public function __construct(\Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator $nativeParamToPhpDocDecorator, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodAnalyzer) + private $autowiredClassMethodOrPropertyAnalyzer; + public function __construct(\Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator $nativeParamToPhpDocDecorator, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer) { $this->nativeParamToPhpDocDecorator = $nativeParamToPhpDocDecorator; $this->reflectionProvider = $reflectionProvider; - $this->autowiredClassMethodAnalyzer = $autowiredClassMethodAnalyzer; + $this->autowiredClassMethodOrPropertyAnalyzer = $autowiredClassMethodOrPropertyAnalyzer; } public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition { @@ -171,7 +171,7 @@ private function skipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) if ($classMethod->params === []) { return \true; } - if ($this->autowiredClassMethodAnalyzer->detect($classMethod)) { + if ($this->autowiredClassMethodOrPropertyAnalyzer->detect($classMethod)) { return \true; } foreach ($classMethod->params as $param) { diff --git a/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php b/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php index 1ed853bc1aab..ac240efbc3b7 100644 --- a/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php +++ b/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php @@ -37,13 +37,13 @@ final class ConstructorAssignDetector /** * @var \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer */ - private $autowiredClassMethodAnalyzer; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\TypeDeclaration\Matcher\PropertyAssignMatcher $propertyAssignMatcher, \RectorPrefix20210725\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodAnalyzer) + private $autowiredClassMethodOrPropertyAnalyzer; + public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\TypeDeclaration\Matcher\PropertyAssignMatcher $propertyAssignMatcher, \RectorPrefix20210725\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer) { $this->nodeTypeResolver = $nodeTypeResolver; $this->propertyAssignMatcher = $propertyAssignMatcher; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; - $this->autowiredClassMethodAnalyzer = $autowiredClassMethodAnalyzer; + $this->autowiredClassMethodOrPropertyAnalyzer = $autowiredClassMethodOrPropertyAnalyzer; } public function isPropertyAssigned(\PhpParser\Node\Stmt\ClassLike $classLike, string $propertyName) : bool { @@ -115,7 +115,7 @@ private function matchInitializeClassMethod(\PhpParser\Node\Stmt\ClassLike $clas } } foreach ($classLike->getMethods() as $classMethod) { - if (!$this->autowiredClassMethodAnalyzer->detect($classMethod)) { + if (!$this->autowiredClassMethodOrPropertyAnalyzer->detect($classMethod)) { continue; } $initializingClassMethods[] = $classMethod; diff --git a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php index b23f5c7e1b99..0604e93de2ed 100644 --- a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php @@ -5,7 +5,6 @@ use PhpParser\Node\Stmt\Property; use PHPStan\Type\Type; -use Rector\Core\Exception\NotImplementedYetException; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface; @@ -33,7 +32,7 @@ public function inferProperty($property) : ?\PHPStan\Type\Type $classLike = $property->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE); if ($classLike === null) { // anonymous class possibly? - throw new \Rector\Core\Exception\NotImplementedYetException(); + return null; } $propertyName = $this->nodeNameResolver->getName($property); return $this->assignToPropertyTypeInferer->inferPropertyInClassLike($propertyName, $classLike); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 06965602fa8e..230c4d6a52af 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = 'a4f8a77418a01e06e79ab23219e7702d0c9c93ea'; + public const PACKAGE_VERSION = '93add0f6c9aef0d30a46c16be1ac1ad013b6d3e4'; /** * @var string */ - public const RELEASE_DATE = '2021-07-25 09:41:00'; + public const RELEASE_DATE = '2021-07-25 12:48:53'; public static function resolvePackageVersion() : string { $process = new \RectorPrefix20210725\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__); diff --git a/src/Bootstrap/ExtensionConfigResolver.php b/src/Bootstrap/ExtensionConfigResolver.php index 031de77285fd..c343b44e81e5 100644 --- a/src/Bootstrap/ExtensionConfigResolver.php +++ b/src/Bootstrap/ExtensionConfigResolver.php @@ -23,7 +23,10 @@ public function provide() : array } $generatedConfigDirectory = \dirname($generatedConfigReflectionClass->getFileName()); foreach (\Rector\RectorInstaller\GeneratedConfig::EXTENSIONS as $extensionConfig) { - foreach ($extensionConfig['extra']['includes'] ?? [] as $includedFile) { + if (!isset($extensionConfig['extra']['includes'])) { + continue; + } + foreach ($extensionConfig['extra']['includes'] as $includedFile) { $includedFilePath = $this->resolveIncludeFilePath($extensionConfig, $generatedConfigDirectory, $includedFile); if ($includedFilePath === null) { $includedFilePath = \sprintf('%s/%s', $extensionConfig['install_path'], $includedFile); diff --git a/src/NodeManipulator/ClassDependencyManipulator.php b/src/NodeManipulator/ClassDependencyManipulator.php index 3574630f08e5..684887f893f1 100644 --- a/src/NodeManipulator/ClassDependencyManipulator.php +++ b/src/NodeManipulator/ClassDependencyManipulator.php @@ -197,10 +197,13 @@ private function hasClassPropertyAndDependency(\PhpParser\Node\Stmt\Class_ $clas return \false; } $property = $class->getProperty($propertyMetadata->getName()); - if ($property instanceof \PhpParser\Node\Stmt\Property && $this->autowiredClassMethodOrPropertyAnalyzer->detect($property)) { - return \true; + if (!$property instanceof \PhpParser\Node\Stmt\Property) { + return $this->isParamInConstructor($class, $propertyMetadata->getName()); + } + if (!$this->autowiredClassMethodOrPropertyAnalyzer->detect($property)) { + return $this->isParamInConstructor($class, $propertyMetadata->getName()); } - return $this->isParamInConstructor($class, $propertyMetadata->getName()); + return \true; } private function hasMethodParameter(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $name) : bool { diff --git a/vendor/autoload.php b/vendor/autoload.php index 37092f9699b2..809a09380064 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25::getLoader(); +return ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 1dab20d72c5d..deee9b63b3ef 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25 +class ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d { private static $loader; @@ -22,15 +22,15 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d', '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\ComposerStaticInit18f3d3a2f2ff8b8fd480d4d20c1a3b25::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit19d435887d274957c40d7329f56e8f2d::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -42,19 +42,19 @@ public static function getLoader() $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit18f3d3a2f2ff8b8fd480d4d20c1a3b25::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit19d435887d274957c40d7329f56e8f2d::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire18f3d3a2f2ff8b8fd480d4d20c1a3b25($fileIdentifier, $file); + composerRequire19d435887d274957c40d7329f56e8f2d($fileIdentifier, $file); } return $loader; } } -function composerRequire18f3d3a2f2ff8b8fd480d4d20c1a3b25($fileIdentifier, $file) +function composerRequire19d435887d274957c40d7329f56e8f2d($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index faecb303ea96..34f4f3cbb773 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit18f3d3a2f2ff8b8fd480d4d20c1a3b25 +class ComposerStaticInit19d435887d274957c40d7329f56e8f2d { public static $files = array ( 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', @@ -3850,9 +3850,9 @@ class ComposerStaticInit18f3d3a2f2ff8b8fd480d4d20c1a3b25 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit18f3d3a2f2ff8b8fd480d4d20c1a3b25::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit18f3d3a2f2ff8b8fd480d4d20c1a3b25::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit18f3d3a2f2ff8b8fd480d4d20c1a3b25::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit19d435887d274957c40d7329f56e8f2d::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit19d435887d274957c40d7329f56e8f2d::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit19d435887d274957c40d7329f56e8f2d::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 6d49c86085ac..cfa4a36bd27b 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -9,8 +9,8 @@ if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { spl_autoload_call('RectorPrefix20210725\AutoloadIncluder'); } -if (!class_exists('ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25', false) && !interface_exists('ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25', false) && !trait_exists('ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25', false)) { - spl_autoload_call('RectorPrefix20210725\ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25'); +if (!class_exists('ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d', false) && !interface_exists('ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d', false) && !trait_exists('ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d', false)) { + spl_autoload_call('RectorPrefix20210725\ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d'); } if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) { spl_autoload_call('RectorPrefix20210725\Doctrine\Inflector\Inflector'); @@ -3308,9 +3308,9 @@ function print_node() { return \RectorPrefix20210725\print_node(...func_get_args()); } } -if (!function_exists('composerRequire18f3d3a2f2ff8b8fd480d4d20c1a3b25')) { - function composerRequire18f3d3a2f2ff8b8fd480d4d20c1a3b25() { - return \RectorPrefix20210725\composerRequire18f3d3a2f2ff8b8fd480d4d20c1a3b25(...func_get_args()); +if (!function_exists('composerRequire19d435887d274957c40d7329f56e8f2d')) { + function composerRequire19d435887d274957c40d7329f56e8f2d() { + return \RectorPrefix20210725\composerRequire19d435887d274957c40d7329f56e8f2d(...func_get_args()); } } if (!function_exists('parseArgs')) {