Skip to content

Commit

Permalink
Updated Rector to commit 774de56c848e9b4c4bbf2a8319cbfaebd16f6ef9
Browse files Browse the repository at this point in the history
rectorphp/rector-src@774de56 Fix AddMethodCallBasedStrictParamTypeRector for invalid generics type (#3281)
  • Loading branch information
TomasVotruba committed Jan 13, 2023
1 parent 827c456 commit f21fb3b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
19 changes: 17 additions & 2 deletions rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
Expand All @@ -28,10 +29,16 @@ final class CallTypesResolver
* @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory
*/
private $typeFactory;
public function __construct(NodeTypeResolver $nodeTypeResolver, TypeFactory $typeFactory)
/**
* @readonly
* @var \PHPStan\Reflection\ReflectionProvider
*/
private $reflectionProvider;
public function __construct(NodeTypeResolver $nodeTypeResolver, TypeFactory $typeFactory, ReflectionProvider $reflectionProvider)
{
$this->nodeTypeResolver = $nodeTypeResolver;
$this->typeFactory = $typeFactory;
$this->reflectionProvider = $reflectionProvider;
}
/**
* @param MethodCall[]|StaticCall[]|ArrayCallable[] $calls
Expand All @@ -58,7 +65,15 @@ private function resolveStrictArgValueType(Arg $arg) : Type
{
$argValueType = $this->nodeTypeResolver->getNativeType($arg->value);
// "self" in another object is not correct, this make it independent
return $this->correctSelfType($argValueType);
$argValueType = $this->correctSelfType($argValueType);
if (!$argValueType instanceof ObjectType) {
return $argValueType;
}
// fix false positive generic type on string
if (!$this->reflectionProvider->hasClass($argValueType->getClassName())) {
return new MixedType();
}
return $argValueType;
}
private function correctSelfType(Type $argValueType) : Type
{
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'fe7ed4fb9a4ed31a13f70ee9e6595552aecb0f58';
public const PACKAGE_VERSION = '774de56c848e9b4c4bbf2a8319cbfaebd16f6ef9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-01-13 19:36:39';
public const RELEASE_DATE = '2023-01-13 19:58:05';
/**
* @var int
*/
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

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

return ComposerAutoloaderInit0d4dc3401e5459c3364d9537d4cca3cf::getLoader();
return ComposerAutoloaderInitf109fb1649a08d1a838d291377b98a7a::getLoader();
10 changes: 5 additions & 5 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 ComposerAutoloaderInit0d4dc3401e5459c3364d9537d4cca3cf
class ComposerAutoloaderInitf109fb1649a08d1a838d291377b98a7a
{
private static $loader;

Expand All @@ -22,17 +22,17 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit0d4dc3401e5459c3364d9537d4cca3cf', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitf109fb1649a08d1a838d291377b98a7a', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit0d4dc3401e5459c3364d9537d4cca3cf', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitf109fb1649a08d1a838d291377b98a7a', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit0d4dc3401e5459c3364d9537d4cca3cf::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitf109fb1649a08d1a838d291377b98a7a::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInit0d4dc3401e5459c3364d9537d4cca3cf::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInitf109fb1649a08d1a838d291377b98a7a::$files;
$requireFile = static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
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 ComposerStaticInit0d4dc3401e5459c3364d9537d4cca3cf
class ComposerStaticInitf109fb1649a08d1a838d291377b98a7a
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -3065,9 +3065,9 @@ class ComposerStaticInit0d4dc3401e5459c3364d9537d4cca3cf
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit0d4dc3401e5459c3364d9537d4cca3cf::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0d4dc3401e5459c3364d9537d4cca3cf::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0d4dc3401e5459c3364d9537d4cca3cf::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf109fb1649a08d1a838d291377b98a7a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf109fb1649a08d1a838d291377b98a7a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf109fb1649a08d1a838d291377b98a7a::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit f21fb3b

Please sign in to comment.