Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array destructuring - if first element not given var name error ensues #2646

Open
caliguIa opened this issue Apr 25, 2024 · 0 comments
Open

Comments

@caliguIa
Copy link

caliguIa commented Apr 25, 2024

Hi,

I'm noticing an issue with the following.

... rest of code

[, $enum2] = HelperFunc::MethodThatReturnsEnums($aggregation);

return [$enum2->value, $enum2->enumMethod($arg)];

... rest of code

In this example code MethodThatReturnsEnums returns a tuple of values with two different enum types.

[E1, E2].

in the above $enum2 actually has the type of E1 according to phpactor, when in reality it is of enum E2, the end result is that when we call $enum2->enumMethod($arg), it's displaying an error as enumMethod doesn't exist on E1 (which is correct).

[$_, $enum2] = HelperFunc::MethodThatReturnsEnums($aggregation);

if I then update the code like so, everything gets typed correctly ($enum2 is of type E2) and the incorrect errors go away.

For reference this issue does not take place on PhpStorm, but it does also display with Intelephense.

If I can provide any other info please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant