Skip to content

Commit

Permalink
Update to PHPStan ^1.3 (#1589)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
samsonasik and actions-user committed Dec 29, 2021
1 parent 29838d0 commit 5181bf9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build/target-repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"require": {
"php": "^7.1|^8.0",
"phpstan/phpstan": "^1.2"
"phpstan/phpstan": "^1.3"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"nette/utils": "^3.2",
"nikic/php-parser": "^4.13.2",
"phpstan/phpdoc-parser": "^1.2",
"phpstan/phpstan": "^1.2",
"phpstan/phpstan": "^1.3",
"phpstan/phpstan-phpunit": "^1.0",
"psr/log": "^2.0",
"react/child-process": "^0.6.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
use PHPStan\AnalysedCodeException;
use PHPStan\Analyser\MutatingScope;
use PHPStan\Analyser\NodeScopeResolver;
use PHPStan\BetterReflection\Reflector\ClassReflector;
use PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
use PHPStan\Node\UnreachableStatementNode;
use PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\Caching\FileSystem\DependencyResolver;
Expand Down Expand Up @@ -198,18 +198,20 @@ private function decoratePHPStanNodeScopeResolverWithRenamedClassSourceLocator(
NodeScopeResolver $nodeScopeResolver
): void {
// 1. get PHPStan locator
/** @var ClassReflector $classReflector */
$classReflector = $this->privatesAccessor->getPrivateProperty($nodeScopeResolver, 'classReflector');
/** @var MemoizingReflector $classReflector */
$classReflector = $this->privatesAccessor->getPrivateProperty($nodeScopeResolver, 'reflector');

$reflector = $this->privatesAccessor->getPrivateProperty($classReflector, 'reflector');

/** @var SourceLocator $sourceLocator */
$sourceLocator = $this->privatesAccessor->getPrivateProperty($classReflector, 'sourceLocator');
$sourceLocator = $this->privatesAccessor->getPrivateProperty($reflector, 'sourceLocator');

// 2. get Rector locator
$aggregateSourceLocator = new AggregateSourceLocator([
$sourceLocator,
$this->renamedClassesSourceLocator,
$this->parentAttributeSourceLocator,
]);
$this->privatesAccessor->setPrivateProperty($classReflector, 'sourceLocator', $aggregateSourceLocator);
$this->privatesAccessor->setPrivateProperty($reflector, 'sourceLocator', $aggregateSourceLocator);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):

/**
* Find all identifiers of a type
* @return Reflection[]
* @return array<int, Reflection>
*/
public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
}

/**
* @return Reflection[]
* @return array<int, Reflection>
*/
public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
}

/**
* @return Reflection[]
* @return array<int, Reflection>
*/
public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType): array
{
Expand Down

0 comments on commit 5181bf9

Please sign in to comment.