Skip to content

Commit

Permalink
Use generic function definition for sscanf
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed May 11, 2020
1 parent 8f2f261 commit eefd2e7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,10 @@ private static function handlePossiblyMatchingByRefParam(

if (isset($function_storage->param_out_types[$argument_offset])) {
$by_ref_out_type = $function_storage->param_out_types[$argument_offset];
} elseif ($argument_offset >= count($function_params)
&& isset($function_storage->param_out_types[count($function_params) - 1])
) {
$by_ref_out_type = $function_storage->param_out_types[count($function_params) - 1];
}

if ($by_ref_type && $by_ref_type->isNullable()) {
Expand Down
1 change: 0 additions & 1 deletion src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public function __construct()
$this->registerClass(ReturnTypeProvider\GetClassMethodsReturnTypeProvider::class);
$this->registerClass(ReturnTypeProvider\FirstArgStringReturnTypeProvider::class);
$this->registerClass(ReturnTypeProvider\HexdecReturnTypeProvider::class);
$this->registerClass(ReturnTypeProvider\SScanFReturnTypeProvider::class);
}

/**
Expand Down

This file was deleted.

7 changes: 7 additions & 0 deletions src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,10 @@ function range($start, $end, $step = 1) {}
* )
*/
function date(string $format, int $timestamp = 0) {}

/**
* @param mixed $vars
* @param-out string|int|float $vars
* @return (func_num_args() is 2 ? list<float|int|string> : int)
*/
function sscanf(string $str, string $format, &...$vars) {}

0 comments on commit eefd2e7

Please sign in to comment.