Skip to content

Commit f1169f5

Browse files
committed
Updated Rector to commit 01406fbaceb72e815e6caafc31f174d434389fd5
rectorphp/rector-src@01406fb Bump to PHPStan 2.1.34 and fix compatible code (#7844)
1 parent c8c7358 commit f1169f5

File tree

11 files changed

+30
-25
lines changed

11 files changed

+30
-25
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"require": {
1111
"php": "^7.4|^8.0",
12-
"phpstan/phpstan": "^2.1.33"
12+
"phpstan/phpstan": "^2.1.34"
1313
},
1414
"autoload": {
1515
"files": [

rules/Php81/NodeManipulator/NullToStrictStringIntConverter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare (strict_types=1);
44
namespace Rector\Php81\NodeManipulator;
55

6+
use PHPStan\Analyser\Fiber\FiberScope;
67
use PhpParser\Node\Arg;
78
use PhpParser\Node\Expr;
89
use PhpParser\Node\Expr\Cast\Int_ as CastInt_;
@@ -173,6 +174,9 @@ private function isAnErrorType(Expr $expr, Type $type, Scope $scope): bool
173174
return \true;
174175
}
175176
$parentScope = $scope->getParentScope();
177+
if ($parentScope instanceof FiberScope) {
178+
$parentScope = $parentScope->toMutatingScope();
179+
}
176180
if ($parentScope instanceof Scope) {
177181
return $parentScope->getType($expr) instanceof ErrorType;
178182
}

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '732278ea4e22e696f77e5ffbcf40efd6be6d8a4e';
22+
public const PACKAGE_VERSION = '01406fbaceb72e815e6caafc31f174d434389fd5';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-01-19 11:05:47';
27+
public const RELEASE_DATE = '2026-01-19 22:30:17';
2828
/**
2929
* @var int
3030
*/

src/DependencyInjection/PHPStan/PHPStanContainerMemento.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use PHPStan\Parser\AnonymousClassVisitor;
99
use PHPStan\Parser\ArrayMapArgVisitor;
1010
use PHPStan\Parser\RichParser;
11-
use PHPStan\Parser\VariadicFunctionsVisitor;
12-
use PHPStan\Parser\VariadicMethodsVisitor;
1311
use Rector\Util\Reflection\PrivatesAccessor;
1412
/**
1513
* Helper service to modify PHPStan container
@@ -32,7 +30,7 @@ public static function removeRichVisitors(RichParser $richParser): void
3230
$tags = $privatesAccessor->getPrivateProperty($deeperContainer, 'tags');
3331
// keep visitors that are useful
3432
// remove all the rest, https://github.com/phpstan/phpstan-src/tree/1d86de8bb9371534983a8dbcd879e057d2ff028f/src/Parser
35-
$nodeVisitorsToKeep = [$container->findServiceNamesByType(AnonymousClassVisitor::class)[0] => \true, $container->findServiceNamesByType(VariadicFunctionsVisitor::class)[0] => \true, $container->findServiceNamesByType(VariadicMethodsVisitor::class)[0] => \true, $container->findServiceNamesByType(ArrayMapArgVisitor::class)[0] => \true];
33+
$nodeVisitorsToKeep = [$container->findServiceNamesByType(AnonymousClassVisitor::class)[0] => \true, $container->findServiceNamesByType(ArrayMapArgVisitor::class)[0] => \true];
3634
$tags[RichParser::VISITOR_SERVICE_TAG] = $nodeVisitorsToKeep;
3735
$privatesAccessor->setPrivateProperty($deeperContainer, 'tags', $tags);
3836
}

src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare (strict_types=1);
44
namespace Rector\NodeTypeResolver\PHPStan\Scope;
55

6+
use PHPStan\Analyser\Fiber\FiberScope;
67
use Error;
78
use PhpParser\Node;
89
use PhpParser\Node\Arg;
@@ -173,6 +174,9 @@ public function processNodes(array $stmts, string $filePath, ?MutatingScope $for
173174
Assert::allIsInstanceOf($stmts, Stmt::class);
174175
$scope = $formerMutatingScope ?? $this->scopeFactory->createFromFile($filePath);
175176
$nodeCallback = function (Node $node, MutatingScope $mutatingScope) use (&$nodeCallback, $filePath): void {
177+
if ($mutatingScope instanceof FiberScope) {
178+
$mutatingScope = $mutatingScope->toMutatingScope();
179+
}
176180
// the class reflection is resolved AFTER entering to class node
177181
// so we need to get it from the first after this one
178182
if ($node instanceof Class_ || $node instanceof Interface_ || $node instanceof Enum_) {

src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
use PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
77
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
8-
use PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher;
98
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocatorFactory;
10-
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocator;
9+
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocatorRepository;
1110
use Rector\Contract\DependencyInjection\ResettableInterface;
1211
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
1312
/**
@@ -18,11 +17,11 @@ final class DynamicSourceLocatorProvider implements ResettableInterface
1817
/**
1918
* @readonly
2019
*/
21-
private FileNodesFetcher $fileNodesFetcher;
20+
private OptimizedDirectorySourceLocatorFactory $optimizedDirectorySourceLocatorFactory;
2221
/**
2322
* @readonly
2423
*/
25-
private OptimizedDirectorySourceLocatorFactory $optimizedDirectorySourceLocatorFactory;
24+
private OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository;
2625
/**
2726
* @var string[]
2827
*/
@@ -32,10 +31,10 @@ final class DynamicSourceLocatorProvider implements ResettableInterface
3231
*/
3332
private array $directories = [];
3433
private ?AggregateSourceLocator $aggregateSourceLocator = null;
35-
public function __construct(FileNodesFetcher $fileNodesFetcher, OptimizedDirectorySourceLocatorFactory $optimizedDirectorySourceLocatorFactory)
34+
public function __construct(OptimizedDirectorySourceLocatorFactory $optimizedDirectorySourceLocatorFactory, OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository)
3635
{
37-
$this->fileNodesFetcher = $fileNodesFetcher;
3836
$this->optimizedDirectorySourceLocatorFactory = $optimizedDirectorySourceLocatorFactory;
37+
$this->optimizedSingleFileSourceLocatorRepository = $optimizedSingleFileSourceLocatorRepository;
3938
}
4039
public function setFilePath(string $filePath): void
4140
{
@@ -64,7 +63,7 @@ public function provide(): SourceLocator
6463
}
6564
$sourceLocators = [];
6665
foreach ($this->filePaths as $file) {
67-
$sourceLocators[] = new OptimizedSingleFileSourceLocator($this->fileNodesFetcher, $file);
66+
$sourceLocators[] = $this->optimizedSingleFileSourceLocatorRepository->getOrCreate($file);
6867
}
6968
foreach ($this->directories as $directory) {
7069
$sourceLocators[] = $this->optimizedDirectorySourceLocatorFactory->createByDirectory($directory);

vendor/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

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

22-
return ComposerAutoloaderInit95a1adf206b6315b2c18296429c15002::getLoader();
22+
return ComposerAutoloaderInit7955fffd214f172412f8f9f29266aeae::getLoader();

vendor/composer/autoload_real.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit95a1adf206b6315b2c18296429c15002
5+
class ComposerAutoloaderInit7955fffd214f172412f8f9f29266aeae
66
{
77
private static $loader;
88

@@ -22,17 +22,17 @@ public static function getLoader()
2222
return self::$loader;
2323
}
2424

25-
spl_autoload_register(array('ComposerAutoloaderInit95a1adf206b6315b2c18296429c15002', 'loadClassLoader'), true, true);
25+
spl_autoload_register(array('ComposerAutoloaderInit7955fffd214f172412f8f9f29266aeae', 'loadClassLoader'), true, true);
2626
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27-
spl_autoload_unregister(array('ComposerAutoloaderInit95a1adf206b6315b2c18296429c15002', 'loadClassLoader'));
27+
spl_autoload_unregister(array('ComposerAutoloaderInit7955fffd214f172412f8f9f29266aeae', 'loadClassLoader'));
2828

2929
require __DIR__ . '/autoload_static.php';
30-
call_user_func(\Composer\Autoload\ComposerStaticInit95a1adf206b6315b2c18296429c15002::getInitializer($loader));
30+
call_user_func(\Composer\Autoload\ComposerStaticInit7955fffd214f172412f8f9f29266aeae::getInitializer($loader));
3131

3232
$loader->setClassMapAuthoritative(true);
3333
$loader->register(true);
3434

35-
$filesToLoad = \Composer\Autoload\ComposerStaticInit95a1adf206b6315b2c18296429c15002::$files;
35+
$filesToLoad = \Composer\Autoload\ComposerStaticInit7955fffd214f172412f8f9f29266aeae::$files;
3636
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
3737
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
3838
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

vendor/composer/autoload_static.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Composer\Autoload;
66

7-
class ComposerStaticInit95a1adf206b6315b2c18296429c15002
7+
class ComposerStaticInit7955fffd214f172412f8f9f29266aeae
88
{
99
public static $files = array (
1010
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
@@ -3221,9 +3221,9 @@ class ComposerStaticInit95a1adf206b6315b2c18296429c15002
32213221
public static function getInitializer(ClassLoader $loader)
32223222
{
32233223
return \Closure::bind(function () use ($loader) {
3224-
$loader->prefixLengthsPsr4 = ComposerStaticInit95a1adf206b6315b2c18296429c15002::$prefixLengthsPsr4;
3225-
$loader->prefixDirsPsr4 = ComposerStaticInit95a1adf206b6315b2c18296429c15002::$prefixDirsPsr4;
3226-
$loader->classMap = ComposerStaticInit95a1adf206b6315b2c18296429c15002::$classMap;
3224+
$loader->prefixLengthsPsr4 = ComposerStaticInit7955fffd214f172412f8f9f29266aeae::$prefixLengthsPsr4;
3225+
$loader->prefixDirsPsr4 = ComposerStaticInit7955fffd214f172412f8f9f29266aeae::$prefixDirsPsr4;
3226+
$loader->classMap = ComposerStaticInit7955fffd214f172412f8f9f29266aeae::$classMap;
32273227

32283228
}, null, ClassLoader::class);
32293229
}

0 commit comments

Comments
 (0)