Skip to content

If equals empty string type coercion #2727

@thg2k

Description

@thg2k

The following code:

$x = function(string $a) {
};
$data = @file_get_contents("non_existing_file");
if ($data == "")
  exit();
$x($data);

Produces the following error:

Parameter #1 $a of closure expects string, string|false given.

But that is not correct as if ($data == "") enters for $data = false, thus there is no way that $x is called with false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions