Re: Type hinting
| From: | Lukas Kahwe Smith | Date: | Fri, 18 Jun 2010 14:28:31 +0000 |
| Subject: | Re: Type hinting | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48827@lists.php.net to get a copy of this message | ||
On 18.06.2010, at 16:13, Melanie Rhianna Lewis wrote:
>
>
> 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.
isnt this what interfaces are for?
regards,
Lukas Kahwe Smith
mls@pooteeweet.org