Re: [RFC] Type hints
| From: | Marcus Boerger | Date: | Sun, 09 May 2004 13:25:32 +0000 |
| Subject: | Re: [RFC] Type hints | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9761@lists.php.net to get a copy of this message | ||
Hello Stanislav,
Sunday, May 9, 2004, 12:58:48 PM, you wrote:
DR>>>I was also wondering if the following would also work:
DR>>>
DR>>>class b extends a { }
DR>>>
DR>>>function foo (a $obj) { }
DR>>>
DR>>>$b = new b;
DR>>>foo($b);
DR>>>
DR>>>(ie, an inherited class also passes the hint check)
> This should definitely work. As I see from current code, it also does :)
It works. What we cannot do is inheriting a function and specifying
a base class typehint:
class Root {
}
class Base {
function f(Base $p) {}
}
class Leaf {
function f(Root $p) {}
}
It is doable as the following patch shows:
http://somabo.de/php/ext/ze2/ze2-type-hint-classes-20040327.diff.txt
(the patch me be a little bit outdated though).
I guess this can pretty good wait for 5.1.
marcus