Updated Rector to commit 93add0f6c9

93add0f6c9 [TypeDeclaration] Return null when  is null on AllAssignNodePropertyTypeInferer::inferProperty() (#504)
This commit is contained in:
Tomas Votruba 2021-07-25 11:00:04 +00:00
parent dcbf54a15b
commit 8f07228ff7
10 changed files with 38 additions and 33 deletions

View File

@ -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 @@ CODE_SAMPLE
if ($classMethod->params === []) {
return \true;
}
if ($this->autowiredClassMethodAnalyzer->detect($classMethod)) {
if ($this->autowiredClassMethodOrPropertyAnalyzer->detect($classMethod)) {
return \true;
}
foreach ($classMethod->params as $param) {

View File

@ -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 @@ final class ConstructorAssignDetector
}
}
foreach ($classLike->getMethods() as $classMethod) {
if (!$this->autowiredClassMethodAnalyzer->detect($classMethod)) {
if (!$this->autowiredClassMethodOrPropertyAnalyzer->detect($classMethod)) {
continue;
}
$initializingClassMethods[] = $classMethod;

View File

@ -5,7 +5,6 @@ namespace Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
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 @@ final class AllAssignNodePropertyTypeInferer implements \Rector\TypeDeclaration\
$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);

View File

@ -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__);

View File

@ -23,7 +23,10 @@ final class ExtensionConfigResolver
}
$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);

View File

@ -197,10 +197,13 @@ final class ClassDependencyManipulator
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());
}
return $this->isParamInConstructor($class, $propertyMetadata->getName());
if (!$this->autowiredClassMethodOrPropertyAnalyzer->detect($property)) {
return $this->isParamInConstructor($class, $propertyMetadata->getName());
}
return \true;
}
private function hasMethodParameter(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $name) : bool
{

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25
class ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25
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 @@ class ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25
$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;

View File

@ -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);
}

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('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 @@ if (!function_exists('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')) {