phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Add stringable-object pseudo type

Open rvanvelzen opened this issue 3 years ago • 2 comments

This implements the stringable-object type that Psalm also supports. A notable difference is that on PHP 8 it is simply an alias for Stringable.

On top of this type a new rule is also implemented that guard against possibly-invalid object-to-string casts. This only really applies to the simple object type, for which the stringable-ness was not checked yet.

rvanvelzen avatar Oct 24 '22 11:10 rvanvelzen

Do you see how we could get rid of StringAlwaysAcceptingObjectWithToStringType and these hacks? https://github.com/phpstan/phpstan-src/blob/7e9ab7231eed18aa4520b4031c6a32fe64bd24bb/src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php#L109-L142

ondrejmirtes avatar Oct 24 '22 11:10 ondrejmirtes

Do you see how we could get rid of StringAlwaysAcceptingObjectWithToStringType and these hacks?

Yep, working on it :)

rvanvelzen avatar Oct 24 '22 11:10 rvanvelzen