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 callables type is not inferred if it is an inherited static method #8363
Labels
Comments
I found these snippets: https://psalm.dev/r/bbc03df04c<?php
/** @template T */
class Holder
{
/** @param T $value */
public function __construct(public $value) {}
}
abstract class A
{
final public function __construct(public int $i) {}
/** @return Holder<static> */
public static function create(int $i): Holder
{
return new Holder(new static($i));
}
}
class C extends A
{
}
$cl1 = C::create(...);
/** @psalm-trace $cl1 */ ;
$cl2 = fn(int $i): Holder => C::create($i);
/** @psalm-trace $cl2 */ ;
|
someniatko
changed the title
[v5] first-class callables type is not inferred if it is an overridden static method
first-class callables type is not inferred if it is an overridden static method
Aug 3, 2022
Found a much easier reproducer: https://psalm.dev/r/428333f418 Basically it doesn't work properly if it doesn't find a static method in the class itself (e.g. if it's an inherited method) |
I found these snippets: https://psalm.dev/r/428333f418<?php
abstract class A
{
public function foo(int $i): string
{
return (string) $i;
}
}
class C extends A {}
/** @param \Closure(int):string $_ */
function takesIntToString(\Closure $_): void {}
takesIntToString(C::foo(...));
|
someniatko
changed the title
first-class callables type is not inferred if it is an overridden static method
first-class callables type is not inferred if it is an inherited static method
Aug 4, 2022
@AndrolGenhald I found a fix for the "easier" reproducer (see the message above), but I'll need your help for fixing the original case. I'll submit a PR shortly. |
someniatko
added a commit
to someniatko/psalm
that referenced
this issue
Aug 4, 2022
…st-class callables
someniatko
added a commit
to someniatko/psalm
that referenced
this issue
Aug 4, 2022
…st-class callables
someniatko
added a commit
to someniatko/psalm
that referenced
this issue
Aug 4, 2022
…the first-class callables
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
refs #6412
it seems the support for the first-class callables is not yet complete:
https://psalm.dev/r/bbc03df04c
The text was updated successfully, but these errors were encountered: