diff --git a/docs/running_psalm/issues/InvalidToString.md b/docs/running_psalm/issues/InvalidToString.md index 353b44770..98bdc78d4 100644 --- a/docs/running_psalm/issues/InvalidToString.md +++ b/docs/running_psalm/issues/InvalidToString.md @@ -7,6 +7,7 @@ Emitted when a `__toString` method does not always return a `string` class A { public function __toString() { + /** @psalm-suppress InvalidReturnStatement */ return true; } } diff --git a/tests/ToStringTest.php b/tests/ToStringTest.php index 1b0ba17c9..a088b9690 100644 --- a/tests/ToStringTest.php +++ b/tests/ToStringTest.php @@ -219,6 +219,19 @@ class ToStringTest extends TestCase }', 'error_message' => 'InvalidToString', ], + 'invalidInferredToStringReturnTypeWithTruePhp8' => [ + ' 'InvalidToString', + [], + false, + '8.0' + ], 'implicitCastWithStrictTypes' => [ '