Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

11
Since PHP 8, "static" is allowed as a return type, but still not allowed as a property or parameter type. My thoughts on this
Post Body

I get why "static" is not allowed as a property type (but "self" is), obviously the use of the word in this manner would create ambiguities with normal static declaration. That is, would this line of code mean a declaration of a static property or a property whose type is the current class or a subclass: public static $myProp;

Still, though, the fact that you can use "static" to coerce a method's return type to be either an instance of the current class or an instance of a descendant class but you can't do the same with properties feels...incomplete somehow. Or maybe I'm just overthinking it and there is no practical real-life scenario that would benefit from it. What do you think, and what other keywords/syntax could the developers of the language use in the future to implement what I'm talking about? For the latter, I'm thinking something like this (taking inspiration from Java): public <? extends self> $myProp;

Author
Account Strength
100%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
5,125
Link Karma
983
Comment Karma
4,129
Profile updated: 3 days ago
Posts updated: 8 hours ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago