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.
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;
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PHP/comment...