Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fde174f

Browse files
authored
Declare @param-out on fscanf
1 parent e6d9df2 commit fde174f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎stubs/core.stub‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ function sodium_memzero(string &$string): void
144144
{
145145
}
146146

147+
/**
148+
* @param resource $stream
149+
* @param mixed $vars
150+
* @param-out string|int|float|null $vars
151+
*
152+
* @return list<mixed>|int|false
153+
*/
154+
function fscanf($stream, string $format, &...$vars) {}
155+
147156
/**
148157
* @param mixed $war
149158
* @param mixed $vars

‎tests/PHPStan/Analyser/data/param-out.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,18 @@ function fooSort() {
257257
assertType('array{}', $emptyArray);
258258
}
259259

260+
function fooFscanf($r): void
261+
{
262+
fscanf($r, "%d:%d:%d", $hours, $minutes, $seconds);
263+
assertType('float|int|string|null', $hours);
264+
assertType('float|int|string|null', $minutes);
265+
assertType('float|int|string|null', $seconds);
266+
267+
$n = fscanf($r, "%s %s", $p1, $p2);
268+
assertType('float|int|string|null', $p1);
269+
assertType('float|int|string|null', $p2);
270+
}
271+
260272
function fooScanf(): void
261273
{
262274
sscanf("10:05:03", "%d:%d:%d", $hours, $minutes, $seconds);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /