Skip to content

Commit ee9819a

Browse files
committed
Testdata *scanf(format) bad scan conversion cases
Additional by-catch fix of a variable misnomer in 023fa08 ("Fix printf parameters rule", 2017-04-02) spotted during review.
1 parent aa6f4af commit ee9819a

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

tests/PHPStan/Rules/Functions/PrintfParametersRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ public function testFile(): void
8484
'Call to sprintf contains 2 placeholders, 1 value given.',
8585
29,
8686
],
87+
[
88+
'Call to sscanf contains an invalid placeholder.',
89+
38,
90+
],
91+
[
92+
'Call to fscanf contains an invalid placeholder.',
93+
39,
94+
],
8795
[
8896
'Call to sprintf contains 2 placeholders, 1 value given.',
8997
45,

tests/PHPStan/Rules/Functions/data/printf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
sscanf($str, "%20[^abcde]a%d", $string, $number); // ok
3636
printf("%.E", 3.14159); // ok
3737
sprintf("%.E", 3.14159); // ok
38-
sscanf($str, '%.E', $number); // ok
39-
fscanf($str, '%.E', $number); // ok
38+
sscanf($str, '%.E', $number); // bad scan conversion character '.'
39+
fscanf($resource, '%.E', $number); // bad scan conversion character '.'
4040
sscanf($str, '%[A-Z]%d', $char, $number); // ok
4141
sprintf('%s %s %s', ...[1]); // do not detect unpacked arguments
4242
sprintf('%s %s %s', ...[1, 2, 3]); // ok

0 commit comments

Comments
 (0)