psalm
psalm copied to clipboard
False-positive `ReservedWord` issue
https://psalm.dev/r/3c8525e655
https://psalm.dev/r/9d2811b8b0
I found these snippets:
https://psalm.dev/r/3c8525e655
<?php
declare(strict_types=1);
namespace Tests\Fixture;
final class Test {}
final class Test2 {}
final class IntersectionParameter
{
public function __invoke(
Test&Test2 $test
): void {
unset($test);
}
}
Psalm output (using commit 08afc45):
ERROR: ReservedWord - 13:9 - Parameter cannot be never
https://psalm.dev/r/9d2811b8b0
<?php
declare(strict_types=1);
namespace Tests\Fixture;
final class Test {}
final class Test2 {}
final class IntersectionParameter
{
public function __invoke(
Test&Test2 $test
): void {
unset($test);
}
}
(new IntersectionParameter())(new Test);
Psalm output (using commit 08afc45):
ERROR: InvalidArgument - 20:31 - Argument 1 of Tests\Fixture\IntersectionParameter::__invoke expects never, but Tests\Fixture\Test provided
ERROR: ReservedWord - 14:9 - Parameter cannot be never
How can your parameter be both a Test1 and a Test2 when they don't share a parent?
Psalm shouldn't report the ResevedWord here though