Skip to content

Commit d497c57

Browse files
committed
Update NodeScopeResolver.php
1 parent 51e622f commit d497c57

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@
166166
use PHPStan\Type\Constant\ConstantArrayTypeBuilder;
167167
use PHPStan\Type\Constant\ConstantBooleanType;
168168
use PHPStan\Type\Constant\ConstantIntegerType;
169+
use PHPStan\Type\Constant\ConstantStringType;
170+
use PHPStan\Type\ConstantTypeHelper;
169171
use PHPStan\Type\ErrorType;
170172
use PHPStan\Type\FileTypeMapper;
171173
use PHPStan\Type\GeneralizePrecision;
@@ -5496,13 +5498,10 @@ private function processAssignVar(
54965498
}
54975499

54985500
if ($originalVar->dim instanceof Variable || $originalVar->dim instanceof Node\Scalar) {
5499-
$type = $this->treatPhpDocTypesAsCertain
5500-
? $scope->getType($originalVar->var)
5501-
: $scope->getNativeType($originalVar->var);
5502-
$dimType = $this->treatPhpDocTypesAsCertain
5503-
? $scope->getType($originalVar->dim)
5504-
: $scope->getNativeType($originalVar->dim);
5505-
if (!$type->hasOffsetValueType($dimType)->yes()) {
5501+
$currentVarType = $scope->getNativeType($originalVar);
5502+
if (
5503+
!$originalNativeValueToWrite->isSuperTypeOf($currentVarType)->yes()
5504+
) {
55065505
$scope = $scope->assignExpression(
55075506
$originalVar,
55085507
$originalValueToWrite,

0 commit comments

Comments
 (0)