-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
In the below code, there is an error in the PHPDoc, the return type of the terminate() method in PHPDocs is not correct
https://phpstan.org/r/2ad3775b-590e-4f0f-a933-3af59e3cdf3d
<?php declare(strict_types = 1);
class MyClassWithErrorInPHPDocs{
/**
* The PHP docs return type below is wrong as it returns a bool
* @return void
*/
public function terminate(): bool
{
return true;
}
public function foo()
{
if($this->terminate()){
echo "C'est fini";
}
}
}
The error message generated for level 0 and 1 is :
Result of method MyClassWithErrorInPHPDocs::terminate() (void) is used.
From level 2 onwards you also get:
PHPDoc tag @return with type void is incompatible with native type bool.
I believe that given level 0 and 1 do not check PHPDoc, PHPStan should not report any error for level 0 and 1 as the header of the terminate() method is that it returns a bool.
Reactions are currently unavailable