From c073c6a27f75bf21004a57d91941389e89588901 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 21 Jun 2024 09:41:48 +0200 Subject: [PATCH] fix phpstan --- src/Testing/TypeInferenceTestCase.php | 5 +++++ src/Type/Php/SprintfFunctionDynamicReturnTypeExtension.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Testing/TypeInferenceTestCase.php b/src/Testing/TypeInferenceTestCase.php index 067612d25b..41da709214 100644 --- a/src/Testing/TypeInferenceTestCase.php +++ b/src/Testing/TypeInferenceTestCase.php @@ -18,12 +18,14 @@ use PHPStan\Reflection\InitializerExprTypeResolver; use PHPStan\Reflection\SignatureMap\SignatureMapProvider; use PHPStan\Rules\Properties\ReadWritePropertiesExtensionProvider; +use PHPStan\ShouldNotHappenException; use PHPStan\TrinaryLogic; use PHPStan\Type\ConstantScalarType; use PHPStan\Type\FileTypeMapper; use PHPStan\Type\Type; use PHPStan\Type\VerbosityLevel; use Symfony\Component\Finder\Finder; +use function array_key_exists; use function array_map; use function array_merge; use function count; @@ -302,6 +304,9 @@ private static function isFileLintSkipped(string $file): bool @fclose($f); if (preg_match('~getType($args[$checkArg]->value); + if (!array_key_exists(2, $matches)) { + throw new ShouldNotHappenException(); + } + if ($matches[2] === 's' && $checkArgType->isString()->yes()) { $singlePlaceholderEarlyReturn = $checkArgType; } elseif ($matches[2] !== 's') {