Skip to content

Add support for parameterised variable checks #12

@muglug

Description

@muglug

This code passes (if $a is an array<mixed> and Foo::bar() is a method)

if ($a['b'] instanceof Foo) {
  $a['b']->bar();
}

but this code (assuming $b is defined) emits a MixedMethodCall issue:

if ($a[$b] instanceof Foo) {
  $a[$b]->bar();
}

It currently fails because Psalm does not allow array fetches with variable-key-offsets to be considered scoped variables. But we should adapt Psalm to allow variable-key array offsets, and then remove those variables from Context::$vars_in_scope when either the array is modified or the key variable is modified.

Related (slightly) to #11

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