Bug report
Given the following...
<?php
final class Url
{
public function __clone(): never // <<
{
throw new \BadMethodCallException('Always throw');
}
}
final class Email
{
/**
* @return never
*/
public function __clone(): never
{
throw new \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.
Code snippet that reproduces the problem
https://phpstan.org/r/4670249c-9af0-4d1a-bcc2-c583c449dd46
Expected output
I didn't expect the error.
Did PHPStan help you today? Did it make you happy in any way?
Always :)
Bug report
Given the following...
...PHPStan warns (on line 5) that a method that throws unconditionally should have the
neverreturn 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 isphpstanPlayground.never. Also interesting that the PHPDoc one works.Code snippet that reproduces the problem
https://phpstan.org/r/4670249c-9af0-4d1a-bcc2-c583c449dd46
Expected output
I didn't expect the error.
Did PHPStan help you today? Did it make you happy in any way?
Always :)