Skip to content

class_implements() has wrong return type in PHP 7.x  #4172

@melkamar

Description

@melkamar

Support question

I'm trying to fix static typing issue in my code but whatever I do, something complains. With the following code PHPStorm's EA extension complains (rightly) that $messageInterfaces might not support array operations (because it may be false):

$messageInterfaces = \class_implements('SomeClass');
$messageInterfaces[] = 'foobar';

But when I fix this and check for false, then PHPStan complains that comparison between false and array is always false.

https://phpstan.org/r/6e1121b4-9b76-4403-8125-767d5b0003bc

What I don't understand is why this works fine with PHP8. To my knowledge the signature of \class_implements() did not change between 7.4 and 8.

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