Skip to content

Commit

Permalink
PHPStan fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 21, 2024
1 parent 328fcb9 commit cf3fc13
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions src/Testing/TypeInferenceTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
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;
Expand Down Expand Up @@ -304,9 +302,6 @@ private static function isFileLintSkipped(string $file): bool
@fclose($f);

if (preg_match('~<?php\\s*\\/\\/\s*lint\s*([^\d\s]+)\s*([^\s]+)\s*~i', $firstLine, $m) === 1) {
if (!array_key_exists(1, $m) || !array_key_exists(2, $m)) {
throw new ShouldNotHappenException();
}
return version_compare(PHP_VERSION, $m[2], $m[1]) === false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Php/SprintfFunctionDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getTypeFromFunctionCall(
foreach ($formatType->getConstantStrings() as $constantString) {
// The printf format is %[argnum$][flags][width][.precision]
if (preg_match('/^%([0-9]*\$)?[0-9]*\.?[0-9]*([sbdeEfFgGhHouxX])$/', $constantString->getValue(), $matches) === 1) {
if (array_key_exists(1, $matches) && ($matches[1] !== '')) {
if ($matches[1] !== '') {
// invalid positional argument
if ($matches[1] === '0$') {
return null;
Expand Down

0 comments on commit cf3fc13

Please sign in to comment.