Comment by monster_truck
9 days ago
It's had return type declarations since 7. There's even intersection and literal types now. You could have typed this into google and it would have told you
9 days ago
It's had return type declarations since 7. There's even intersection and literal types now. You could have typed this into google and it would have told you
Type declarations are still quite limited, though. For example, you can declare that a function returns an array or a string, but not an array of strings.
Use a class if you need them.
How does that solve the problem? You can't declare an array of strings inside a class, either.
3 replies →
I did and it told me that it doesn't support typed arrays.
Man that goal post moved quick.
The example on the Psalm 7 page (https://psalm.dev/) showed the PHPDoc return type.
I was not precise enough about the exact version of it, fair, but my correction did not change my opinion on this topic.
And the PHPDoc stuff is old, it was normal to write them everywere 11 years ago and still today you have to write them for some cases.
Its still inconsistent and stupid.