Skip to content

Support filter_*() functions #6261

@mklepaczewski

Description

@mklepaczewski

Feature request

Currently filter_input()'s resturn value is recognized to be mixed. While technically true, I would want this code to produce no errors:

<?php
declare( strict_types=1 );

function needs_int(int $x) : void {}

$x = filter_input(INPUT_POST, 'row_id', FILTER_VALIDATE_INT);

if($x === false || $x === null) {
    die("I expected a numeric string!\n");
}

needs_int($x);

Test code

https://phpstan.org/r/6573e85d-3ceb-439a-bd9d-e8b9f1a3e01a

Expected result

No errors

Current result

 ------ -----------------------------------------------------------------
  Line   test-filter_input.php
 ------ -----------------------------------------------------------------
  17     Parameter #1 $x of function needs_int expects int, mixed given.
 ------ -----------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions