Re: Type hinting
| From: | Lukas Kahwe Smith | Date: | Fri, 18 Jun 2010 16:18:23 +0000 |
| Subject: | Re: Type hinting | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48829@lists.php.net to get a copy of this message | ||
On 18.06.2010, at 18:13, Christian Kaps wrote:
> On Fri, 18 Jun 2010 16:28:31 +0200, Lukas Kahwe Smith <mls@pooteeweet.org>
> wrote:
>> 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
>
> Sure, you can create an empty interface for this scenario but only for
> self defined classes. All PHP classes can't used with this interface.
and you seriously need type hints for this use case?
regards,
Lukas Kahwe Smith
mls@pooteeweet.org