Skip to content

Commit

Permalink
Updated Rector to commit 93add0f
Browse files Browse the repository at this point in the history
rectorphp/rector-src@93add0f [TypeDeclaration] Return null when  is null on AllAssignNodePropertyTypeInferer::inferProperty() (#504)
  • Loading branch information
TomasVotruba committed Jul 25, 2021
1 parent dcbf54a commit 8f07228
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand Down
5 changes: 4 additions & 1 deletion src/Bootstrap/ExtensionConfigResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/NodeManipulator/ClassDependencyManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25::getLoader();
return ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d::getLoader();
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit18f3d3a2f2ff8b8fd480d4d20c1a3b25
class ComposerAutoloaderInit19d435887d274957c40d7329f56e8f2d
{
private static $loader;

Expand All @@ -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) {
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit18f3d3a2f2ff8b8fd480d4d20c1a3b25
class ComposerStaticInit19d435887d274957c40d7329f56e8f2d
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/scoper-autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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')) {
Expand Down

0 comments on commit 8f07228

Please sign in to comment.