Skip to content

Commit

Permalink
cs
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jun 5, 2024
1 parent 7660d0a commit dfea0a5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Rules/Functions/PrintfArrayParametersRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PHPStan\Rules\Functions;

use Hoa\Stream\Test\Unit\IStream\In;
use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use PHPStan\Analyser\Scope;
Expand All @@ -15,6 +14,8 @@
use PHPStan\Type\TypeCombinator;
use function count;
use function in_array;
use function max;
use function min;
use function sprintf;

/**
Expand Down Expand Up @@ -77,7 +78,6 @@ public function processNode(Node $node, Scope $scope): array
$placeHoldersCount = IntegerRangeType::fromInterval($minCount, $maxCount);
}


$formatArgsCounts = [];
if (isset($args[1])) {
$formatArgsType = $scope->getType($args[1]->value);
Expand Down Expand Up @@ -153,29 +153,31 @@ private function placeholdersMatchesArgsCount(IntegerRangeType|ConstantIntegerTy

Check failure on line 153 in src/Rules/Functions/PrintfArrayParametersRule.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Instanceof between PHPStan\Type\IntegerRangeType and PHPStan\Type\IntegerRangeType will always evaluate to true.

Check failure on line 153 in src/Rules/Functions/PrintfArrayParametersRule.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Instanceof between PHPStan\Type\IntegerRangeType and PHPStan\Type\IntegerRangeType will always evaluate to true.
if ($placeHoldersCount instanceof IntegerRangeType
&& $formatArgsCount instanceof IntegerRangeType
&& IntegerRangeType::fromInterval(1, null)->isSuperTypeOf($placeHoldersCount)->yes()
&& IntegerRangeType::fromInterval(1, null)->isSuperTypeOf($placeHoldersCount)->yes()
) {
if ($formatArgsCount->getMin() !== null && $formatArgsCount->getMax() !== null) {
// constant array

Check failure on line 159 in src/Rules/Functions/PrintfArrayParametersRule.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Instanceof between PHPStan\Type\IntegerRangeType and PHPStan\Type\IntegerRangeType will always evaluate to true.

Check failure on line 159 in src/Rules/Functions/PrintfArrayParametersRule.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Instanceof between PHPStan\Type\IntegerRangeType and PHPStan\Type\IntegerRangeType will always evaluate to true.
return $placeHoldersCount->isSuperTypeOf($formatArgsCount)->yes();
}

// general array
return IntegerRangeType::fromInterval(1, null)->isSuperTypeOf($formatArgsCount)->yes();
}

return false;
}

private function getIntegerRangeAsString(IntegerRangeType $range): string {
private function getIntegerRangeAsString(IntegerRangeType $range): string
{
if ($range->getMin() !== null && $range->getMax() !== null) {
return $range->getMin() . '-' . $range->getMax();
} elseif ($range->getMin() !== null) {
return $range->getMin() . ' or more';
} elseif ($range->getMax() !== null) {
return $range->getMax() . ' or less';
} else {
throw new ShouldNotHappenException();
}

throw new ShouldNotHappenException();
}

}

0 comments on commit dfea0a5

Please sign in to comment.