Re: Q on Primitives
| From: | Giorgio Sironi | Date: | Thu, 18 Dec 2008 19:26:12 +0000 |
| Subject: | Re: Q on Primitives | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42335@lists.php.net to get a copy of this message | ||
2008/12/18 Dave Ingram <dave@dmi.me.uk>
> Nathan Rixham wrote:
> > [...]
> >
> > while I'm here I may as well also ask about further adding type
> > hinting for the existing scalars and array.
> +1, but I don't know what might have stopped it being implemented before
> (time, parsing API changes, etc), so it would be interesting to look
> into the history.
>
This is simple to achieve with
assert('is_string($argument)');
class MyTestClass {
> public function blah(Foo $f);
> public function blah(Bar $b);
> public function blah($v);
> }
>
> I would argue that the most specific function should be called, but how
> costly would that be to determine? What if you have a "Baz" subclass of
> Bar, but no corresponding method? What if Bar itself is a subclass of Foo?
>
I remember that multiple signatures was said to have a possible very
difficult implementation. However, a similar behaviour can be achieved by
some instanceof().
--
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://www.sourceforge.net/projects/ossigeno