Skip to content

Treat all possible dynamic method invocations the same way #4608

@wouterj

Description

@wouterj

Feature request

https://phpstan.org/r/5fe67304-fc83-41c3-84d1-0c019eb8b90a

$c = new class {
	public function abc(): void {}
};

$s = rand(0, 1) ? 'abc' : 'not_abc';

$c->{$s}();
call_user_func([$c, $s]);
[$c, $s]();

As far as I know, there are 3 ways to dynamically build a method name and invoke it. The (2) and (3) in the code example above are reported by PHPstan, whereas all three are reported in strict mode. As I think there is no semantical difference between them (I can be wrong here), I think it makes sense if PHPstan reports all of them the same way.

cc @dkarlovi

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