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
First-class callable #6989
Comments
I found these snippets: https://psalm.dev/r/399d485cde<?php
class Foo
{
public function bar(): array
{
return $this->map($this->baz(...), [1, 2, 3]);
}
private function baz(int $val): int
{
return $val * 2;
}
private function map(callable $callback, array $val): array
{
$result = [];
foreach ($val as $key => $value) {
$result[$key] = $callback($value);
}
return $result;
}
}
var_dump((new Foo)->bar());
|
Can you try parsing the source file with |
It's not a PHP-Parser issue, it's indirectly due to #6628 in PHP-Parser 4.13, the argument list (for a In #6628, I replaced every use of MethodCall::args (and others) by MethodCall::getArgs() in order to fallback to a method that returns the same list of Args as before. However, PHP-Parser does an assert on MethodCall::args in order to check that it's not a first class callable to be able to make sure it only return Args. The effect of that is that Psalm doesn't have support for first class callable (it would have failed to parse in PHP-Parser 4.12 and now it fails on the assertion) This makes this issue very related to #6412, if not a duplicate |
Any news here? Stumbled over the same problem |
Actually, this should have been closed by #7113. @FractalizeR if you could make sure your use case work in latest master, it would help checking everything works. Please open a new issue if you encounter difficulties |
Latest master (pointing composer to dev-master branch) didn't work. The error is still:
|
@FractalizeR can you please open a new issue? |
|
Hi, I'm trying to get works psalm with php8.1 syntax, but getting error
Uncaught AssertionError: assert(!$this->isFirstClassCallable()) in /app/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php:36
when trying to inspect following line
When I trying to run the snippet https://psalm.dev/r/399d485cde , https://psalm.dev/check responds with 500 error:
The text was updated successfully, but these errors were encountered: