Skip to content

Commit

Permalink
Merge branch refs/heads/1.11.x into 1.12.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot authored Jul 23, 2024
2 parents 7d1bde4 + 101467d commit d24c545
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/Rules/Functions/PrintfArrayParametersRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PHPStan\ShouldNotHappenException;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\IntegerRangeType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\TypeCombinator;
use function count;
use function in_array;
Expand Down Expand Up @@ -87,13 +88,12 @@ public function processNode(Node $node, Scope $scope): array
$formatArgsType = $scope->getType($args[1]->value);

$constantArrays = $formatArgsType->getConstantArrays();
if ($constantArrays === []) {
$formatArgsCounts[] = new IntegerType();
}
foreach ($constantArrays as $constantArray) {
$formatArgsCounts[] = $constantArray->getArraySize();
}

if ($constantArrays === []) {
$formatArgsCounts[] = $formatArgsType->getArraySize();
}
}

if ($formatArgsCounts === []) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ public function testFile(): void
'Call to vprintf contains 2 placeholders, 1 value given.',
34,
],
[
'Call to vsprintf contains 1-2 placeholders, 0 or more values given.',
53,
],
]);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/vprintf.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function doFoo($message, array $arr) {
} else {
$format = '%s%s';
}
vsprintf($format, $arr); // need at least non-empty-array
vsprintf($format, $arr); // do not report on general array, annoying in practice

if (rand(0,1)) {
$format = '%s';
Expand Down

0 comments on commit d24c545

Please sign in to comment.