Type hinting of class properties
| From: | Baptiste Autin | Date: | Mon, 19 Nov 2007 00:18:17 +0000 |
| Subject: | Type hinting of class properties | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33271@lists.php.net to get a copy of this message | ||
I know well the sacred "loose typing" anthem, but is there any hope to see
the class properties type hinted one day? (and the return value as well)
I mean, as an OPTION, as it is already done with function parameters...
Class A {
}
Class B {
public A $a;
}
Because:
1. It is so strange to see that in PHP5 only the function parameters
have this feature implemented today. It's like a half-done job.
2. Many design patterns make use of composition (versus inheritance -
thanks the GoF) and a composition would be more readable with such a
feature.
3. Model-driven, reverse-enginering tools would appreciate this too.
Other question: would it be conceivable to gather the ENV / GET / POST (and
so on) variables into one or more system classes? (sorts of "context
classes") so that one would always have the choice between looking into the
traditional arrays $_xxx, or into the system classes (I'm sure this point
has already been discussed, but I wasn't there :-).