You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive: Always throwing and returning never #15070
<?phpfinalclass Url
{
publicfunction__clone(): never // <<
{
thrownew \BadMethodCallException('Always throw');
}
}
finalclass Email
{
/** * @return never */publicfunction__clone(): never
{
thrownew \BadMethodCallException('Always throw');
}
}
...PHPStan warns (on line 5) that a method that throws unconditionally should have the never return type (which it already does).
Originally, I had code returning void, but I never saw that warning in our code, it only showed up in the playground when I happened to paste my code for trying something else. Interestingly, the error identifier is phpstanPlayground.never. Also interesting that the PHPDoc one works.
Activity
staabm commentedon Aug 11, 2026
note:
public function __clone(): neveris a fatal error on PHP < 8.1https://3v4l.org/2WDCe#veol