Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/target-repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"require": {
"php": "^7.4|^8.0",
"phpstan/phpstan": "^2.1.33"
"phpstan/phpstan": "^2.1.34"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"nikic/php-parser": "^5.7",
"ondram/ci-detector": "^4.2",
"phpstan/phpdoc-parser": "^2.3",
"phpstan/phpstan": "^2.1.33",
"phpstan/phpstan": "^2.1.34",
"react/event-loop": "^1.6",
"react/promise": "^3.3",
"react/socket": "^1.17",
Expand Down
26 changes: 26 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,29 @@ parameters:
-
identifier: symplify.noMissnamedDocTag
path: rules/TypeDeclarationDocblocks/TypeResolver/ConstantArrayTypeGeneralizer.php

-
identifier: typePerfect.narrowReturnObjectType
path: src/PHPStan/ScopeFetcher.php

-
identifier: varTag.nativeType
path: src/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php

-
identifier: argument.type
paths:
- rules/Privatization/TypeManipulator/TypeNormalizer.php
- rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector.php
- rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector.php
- rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php
- rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php
- rules/TypeDeclarationDocblocks/Rector/Class_/AddVarArrayDocblockFromDimFetchAssignRector.php
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php

-
identifier: argument.templateType
paths:
- rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector.php
- rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php81\NodeManipulator;

use PHPStan\Analyser\Fiber\FiberScope;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Cast\Int_ as CastInt_;
Expand Down Expand Up @@ -213,6 +214,10 @@ private function isAnErrorType(Expr $expr, Type $type, Scope $scope): bool
}

$parentScope = $scope->getParentScope();
if ($parentScope instanceof FiberScope) {
$parentScope = $parentScope->toMutatingScope();
}

if ($parentScope instanceof Scope) {
return $parentScope->getType($expr) instanceof ErrorType;
}
Expand Down
4 changes: 0 additions & 4 deletions src/DependencyInjection/PHPStan/PHPStanContainerMemento.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use PHPStan\Parser\AnonymousClassVisitor;
use PHPStan\Parser\ArrayMapArgVisitor;
use PHPStan\Parser\RichParser;
use PHPStan\Parser\VariadicFunctionsVisitor;
use PHPStan\Parser\VariadicMethodsVisitor;
use Rector\Util\Reflection\PrivatesAccessor;

/**
Expand Down Expand Up @@ -41,8 +39,6 @@ public static function removeRichVisitors(RichParser $richParser): void
// remove all the rest, https://github.com/phpstan/phpstan-src/tree/1d86de8bb9371534983a8dbcd879e057d2ff028f/src/Parser
$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,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\NodeTypeResolver\PHPStan\Scope;

use PHPStan\Analyser\Fiber\FiberScope;
use Error;
use PhpParser\Node;
use PhpParser\Node\Arg;
Expand Down Expand Up @@ -158,6 +159,10 @@ public function processNodes(
&$nodeCallback,
$filePath,
): void {
if ($mutatingScope instanceof FiberScope) {
$mutatingScope = $mutatingScope->toMutatingScope();
}

// the class reflection is resolved AFTER entering to class node
// so we need to get it from the first after this one
if ($node instanceof Class_ || $node instanceof Interface_ || $node instanceof Enum_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

use PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
use PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher;
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocatorFactory;
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocator;
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocatorRepository;
use Rector\Contract\DependencyInjection\ResettableInterface;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;

Expand All @@ -30,8 +29,8 @@ final class DynamicSourceLocatorProvider implements ResettableInterface
private ?AggregateSourceLocator $aggregateSourceLocator = null;

public function __construct(
private readonly FileNodesFetcher $fileNodesFetcher,
private readonly OptimizedDirectorySourceLocatorFactory $optimizedDirectorySourceLocatorFactory
private readonly OptimizedDirectorySourceLocatorFactory $optimizedDirectorySourceLocatorFactory,
private readonly OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository
) {
}

Expand Down Expand Up @@ -68,7 +67,7 @@ public function provide(): SourceLocator
$sourceLocators = [];

foreach ($this->filePaths as $file) {
$sourceLocators[] = new OptimizedSingleFileSourceLocator($this->fileNodesFetcher, $file);
$sourceLocators[] = $this->optimizedSingleFileSourceLocatorRepository->getOrCreate($file);
}

foreach ($this->directories as $directory) {
Expand Down
Loading