Skip to content

Commit

Permalink
Improve sscanf() signature
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffycondor committed Jul 7, 2021
1 parent 790a838 commit d50aa7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion resources/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11546,7 +11546,8 @@
'sqlsrv_server_info' => ['array', 'conn'=>'resource'],
'sqrt' => ['float', 'number'=>'float'],
'srand' => ['void', 'seed='=>'int', 'mode='=>'int'],
'sscanf' => ['mixed', 'str'=>'string', 'format'=>'string', '&...w_vars='=>'string|int|float|null'],
'sscanf' => ['int|null', 'str'=>'string', 'format'=>'string', '&w_war'=>'string|int|float|null', '&...w_vars='=>'string|int|float|null'],
'sscanf\'1' => ['array|null', 'str'=>'string', 'format'=>'string'],
'ssdeep_fuzzy_compare' => ['int', 'signature1'=>'string', 'signature2'=>'string'],
'ssdeep_fuzzy_hash' => ['string', 'to_hash'=>'string'],
'ssdeep_fuzzy_hash_filename' => ['string', 'file_name'=>'string'],
Expand Down
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/non-empty-string.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-3981.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-4711.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/sscanf.php');
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/data/sscanf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

use function PHPStan\Testing\assertType;

assertType('int|null', sscanf('20-20', '%d-%d', $first, $second));
assertType('array|null', sscanf('20-20', '%d-%d'));

0 comments on commit d50aa7d

Please sign in to comment.