On 18 June 2010 15:13, Melanie Rhianna Lewis <cybersp...@php.net> 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.
>
> Melanie
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

class::method(object $instance)

would certainly be useful.

Could this not be solved by internally extending all userland classes
(and whilst we are at this why not all internal classes) from a PHP
supplied empty class? Maybe stdClass?

scalar, array, class, interface, untyped class.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to