diff --git a/composer.json b/composer.json index ca973496b3d..3b23f9c2d77 100644 --- a/composer.json +++ b/composer.json @@ -45,18 +45,18 @@ "symfony/process": "^6.0", "symfony/string": "^6.0", "symfony/yaml": "^5.4|^6.0", - "symplify/astral": "^10.0.2", - "symplify/autowire-array-parameter": "^10.0.2", - "symplify/composer-json-manipulator": "^10.0.2", - "symplify/console-color-diff": "^10.0.2", - "symplify/easy-parallel": "^10.0.2", - "symplify/package-builder": "^10.0.2", - "symplify/rule-doc-generator-contracts": "^10.0.2", - "symplify/simple-php-doc-parser": "^10.0.2", - "symplify/skipper": "^10.0.2", - "symplify/smart-file-system": "^10.0.2", - "symplify/symfony-php-config": "^10.0.2", - "symplify/vendor-patches": "^10.0.2", + "symplify/astral": "^10.0.9", + "symplify/autowire-array-parameter": "^10.0.9", + "symplify/composer-json-manipulator": "^10.0.9", + "symplify/console-color-diff": "^10.0.9", + "symplify/easy-parallel": "^10.0.9", + "symplify/package-builder": "^10.0.9", + "symplify/rule-doc-generator-contracts": "^10.0.9", + "symplify/simple-php-doc-parser": "^10.0.9", + "symplify/skipper": "^10.0.9", + "symplify/smart-file-system": "^10.0.9", + "symplify/symfony-php-config": "^10.0.9", + "symplify/vendor-patches": "^10.0.9", "tracy/tracy": "^2.8", "webmozart/assert": "^1.10", "helmich/typo3-typoscript-parser": "dev-master#0ccb3a6" @@ -73,14 +73,14 @@ "phpunit/phpunit": "^9.5", "rector/phpstan-rules": "^0.4.15", "spatie/enum": "^3.10", - "symplify/coding-standard": "^10.0.2", - "symplify/easy-ci": "^10.0.2", - "symplify/easy-coding-standard": "^10.0.2", - "symplify/easy-testing": "^10.0.2", - "symplify/monorepo-builder": "^10.0.2", - "symplify/phpstan-extensions": "^10.0.2", - "symplify/phpstan-rules": "^10.0.2", - "symplify/rule-doc-generator": "^10.0.2", + "symplify/coding-standard": "^10.0.9", + "symplify/easy-ci": "^10.0.9", + "symplify/easy-coding-standard": "^10.0.9", + "symplify/easy-testing": "^10.0.9", + "symplify/monorepo-builder": "^10.0.9", + "symplify/phpstan-extensions": "^10.0.9", + "symplify/phpstan-rules": "^10.0.9", + "symplify/rule-doc-generator": "^10.0.9", "timeweb/phpstan-enum": "dev-22-upgrade-phpstan-to-1.0" }, "replace": { diff --git a/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 4c52ddb7c3b..4c5cc315021 100644 --- a/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -13,10 +13,13 @@ use PHPStan\AnalysedCodeException; use PHPStan\Analyser\MutatingScope; use PHPStan\Analyser\NodeScopeResolver; +use PHPStan\Analyser\ScopeContext; +use PHPStan\BetterReflection\Reflector\Reflector; 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\ClassReflection; use PHPStan\Reflection\ReflectionProvider; use Rector\Caching\Detector\ChangedFilesDetector; use Rector\Caching\FileSystem\DependencyResolver; @@ -78,10 +81,26 @@ public function processNodes(array $stmts, SmartFileInfo $smartFileInfo): array $traitScope = clone $scope; - $scopeContext = $this->privatesAccessor->getPrivateProperty($traitScope, self::CONTEXT); + $scopeContext = $this->privatesAccessor->getPrivatePropertyOfClass( + $traitScope, + self::CONTEXT, + ScopeContext::class + ); + $traitContext = clone $scopeContext; - $this->privatesAccessor->setPrivateProperty($traitContext, 'classReflection', $traitReflectionClass); - $this->privatesAccessor->setPrivateProperty($traitScope, self::CONTEXT, $traitContext); + + $this->privatesAccessor->setPrivatePropertyOfClass( + $traitContext, + 'classReflection', + $traitReflectionClass, + ClassReflection::class + ); + $this->privatesAccessor->setPrivatePropertyOfClass( + $traitScope, + self::CONTEXT, + $traitContext, + ScopeContext::class + ); $this->nodeScopeResolver->processNodes($node->stmts, $traitScope, $nodeCallback); return; @@ -199,12 +218,24 @@ private function decoratePHPStanNodeScopeResolverWithRenamedClassSourceLocator( ): void { // 1. get PHPStan locator /** @var MemoizingReflector $classReflector */ - $classReflector = $this->privatesAccessor->getPrivateProperty($nodeScopeResolver, 'reflector'); - - $reflector = $this->privatesAccessor->getPrivateProperty($classReflector, 'reflector'); + $classReflector = $this->privatesAccessor->getPrivatePropertyOfClass( + $nodeScopeResolver, + 'reflector', + Reflector::class + ); + + $reflector = $this->privatesAccessor->getPrivatePropertyOfClass( + $classReflector, + 'reflector', + Reflector::class + ); /** @var SourceLocator $sourceLocator */ - $sourceLocator = $this->privatesAccessor->getPrivateProperty($reflector, 'sourceLocator'); + $sourceLocator = $this->privatesAccessor->getPrivatePropertyOfClass( + $reflector, + 'sourceLocator', + SourceLocator::class + ); // 2. get Rector locator $aggregateSourceLocator = new AggregateSourceLocator([ @@ -212,6 +243,11 @@ private function decoratePHPStanNodeScopeResolverWithRenamedClassSourceLocator( $this->renamedClassesSourceLocator, $this->parentAttributeSourceLocator, ]); - $this->privatesAccessor->setPrivateProperty($reflector, 'sourceLocator', $aggregateSourceLocator); + $this->privatesAccessor->setPrivatePropertyOfClass( + $reflector, + 'sourceLocator', + $aggregateSourceLocator, + AggregateSourceLocator::class + ); } } diff --git a/rules/TypeDeclaration/TypeNormalizer.php b/rules/TypeDeclaration/TypeNormalizer.php index a51af1b2ee1..8fb010fac93 100644 --- a/rules/TypeDeclaration/TypeNormalizer.php +++ b/rules/TypeDeclaration/TypeNormalizer.php @@ -98,9 +98,21 @@ public function normalizeArrayTypeAndArrayNever(Type $type): Type { return TypeTraverser::map($type, function (Type $traversedType, callable $traverserCallable): Type { if ($this->isConstantArrayNever($traversedType)) { + assert($traversedType instanceof ConstantArrayType); + // not sure why, but with direct new node everything gets nulled to MixedType - $this->privatesAccessor->setPrivateProperty($traversedType, 'keyType', new MixedType()); - $this->privatesAccessor->setPrivateProperty($traversedType, 'itemType', new MixedType()); + $this->privatesAccessor->setPrivatePropertyOfClass( + $traversedType, + 'keyType', + new MixedType(), + Type::class + ); + $this->privatesAccessor->setPrivatePropertyOfClass( + $traversedType, + 'itemType', + new MixedType(), + Type::class + ); return $traversedType; }