While building Sunny, I’ve been vaguely checking my code coverage and checking PHPstan and seeing what I’m “forced” to write to get to 100% coverage or to make stan happy. I’ve finally encountered an instance where these tools encourage me to break my patterns:
https://techenby.com/posts/first-friction-with-coverage-and-phpstan
https://techenby.com/posts/first-friction-with-coverage-and-phpstan
Comments
The return type of `?string` means `null` or `string`. Not returning anything from the method would be a `void` type and give a type error.
It showed a similar issue around a missing return, but I was able to resolve it by setting the return type to string|void. I imagine that should work in PHPStan too.
Wondered if it's possible to essentially override the return type in a docblock using tool specific return types, but doesn't seem possible. Using docblocks only is an option but not a great one.