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

False-positive when destructuring callable-array #2653

Closed
jaikdean opened this issue Jan 17, 2020 · 1 comment
Closed

False-positive when destructuring callable-array #2653

jaikdean opened this issue Jan 17, 2020 · 1 comment

Comments

@jaikdean
Copy link

The callable-array type doesn't appear to be correctly treated as an array.

https://psalm.dev/r/cfc2aac7c2

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/cfc2aac7c2
<?php
  
function getCallable(): callable {
    return [DateTimeImmutable::class, 'createFromFormat'];
}

$callable = getCallable();

if (!is_array($callable)) {
  exit;
}

[$classOrObject, $method] = $callable;
Psalm output (using commit c50fa27):

ERROR: InvalidArrayOffset - 13:1 - Cannot destructure non-array of type callable-array{0: class-string|object, 1: string}

INFO: UnusedVariable - 13:2 - Variable $classOrObject is never referenced

INFO: UnusedVariable - 13:18 - Variable $method is never referenced

@muglug muglug closed this as completed in 2c48d42 Jan 17, 2020
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