From be25bbfa2b180516532cce4b7cd4feafb06802ee Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 2 Apr 2026 15:27:52 +0200 Subject: [PATCH 1/2] TypeCombinator: Remove always true condition --- src/Type/TypeCombinator.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index 4a98edb58b2..b4544a86627 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -793,10 +793,7 @@ private static function processArrayAccessoryTypes(array $arrayTypes): array continue; } if ($innerType instanceof HasOffsetType) { - $offset = $innerType->getOffsetType(); - if ($offset instanceof ConstantStringType || $offset instanceof ConstantIntegerType) { - $innerType = new HasOffsetValueType($offset, $arrayType->getIterableValueType()); - } + $innerType = new HasOffsetValueType($innerType->getOffsetType(), $arrayType->getIterableValueType()); } if ($innerType instanceof HasOffsetValueType) { $accessoryTypes[sprintf('hasOffsetValue(%s)', $innerType->getOffsetType()->describe(VerbosityLevel::cache()))][$i] = $innerType; From 7beb39a0281e966438d79231816e3e3f3e6fe513 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 2 Apr 2026 15:28:28 +0200 Subject: [PATCH 2/2] Update phpstan-baseline.neon --- phpstan-baseline.neon | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 564df2bc20d..43a17e853e1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1710,7 +1710,7 @@ parameters: - rawMessage: 'Doing instanceof PHPStan\Type\Constant\ConstantStringType is error-prone and deprecated. Use Type::getConstantStrings() instead.' identifier: phpstanApi.instanceofType - count: 3 + count: 2 path: src/Type/TypeCombinator.php - @@ -1743,18 +1743,6 @@ parameters: count: 2 path: src/Type/TypeCombinator.php - - - rawMessage: Instanceof between PHPStan\Type\Constant\ConstantIntegerType and PHPStan\Type\Constant\ConstantIntegerType will always evaluate to true. - identifier: instanceof.alwaysTrue - count: 1 - path: src/Type/TypeCombinator.php - - - - rawMessage: Result of || is always true. - identifier: booleanOr.alwaysTrue - count: 1 - path: src/Type/TypeCombinator.php - - rawMessage: Doing instanceof PHPStan\Type\IntersectionType is error-prone and deprecated. identifier: phpstanApi.instanceofType