-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Support question
I'm trying to understand why is PHPStan throwing the error on this code
<?php
declare(strict_types=1);
trait A
{
public static function bla(): string
{
return 'bla';
}
}
function bar(): string
{
return A::bla();
}
function foo(): string
{
return (new class { use A; } )::bla();
}
echo bar();
echo foo();Line 15: Call to static method bla() on trait A.
So in the case of
function bar(): string
{
return A::bla();
}I will get an error but in case of
function foo(): string
{
return (new class { use A; } )::bla();
}There is no error.
How come if both will work just fine? The same happens if I'm in a class context and use a static method from a trait in another method directly using the name of the trait.
Reactions are currently unavailable