Re: Type hinting
| From: | Melanie Rhianna Lewis | Date: | Fri, 18 Jun 2010 14:13:21 +0000 |
| Subject: | Re: Type hinting | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48826@lists.php.net to get a copy of this message | ||
On 17 Jun 2010, at 20:14, Stas Malyshev wrote:
> Hi!
>
>> I know the discussion is about scalar type hints. But what is with a
>> object type hint as base for all objects?
>
> When it makes sense to accept any object, regardless of the class, but not other types? I
> wonder if it's really a common use-case.
Its useful in some patterns. For example suppose you have a pattern where a class wraps another
class. The wrapped class could be *any* class if you're modify the behaviour of some default
methods (say doing something like a decorator pattern). Having a type hint that recognises object
vs non objects is useful.
Melanie