Re: Re: Opinions / Votes Needed
| From: | Jochem Maas | Date: | Sat, 17 Jan 2009 22:07:27 +0000 |
| Subject: | Re: Re: Opinions / Votes Needed | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286574@lists.php.net to get a copy of this message | ||
Nathan Rixham schreef:
> Jochem Maas wrote:
>> Nathan Rixham schreef:
...
>> try this snippet on for size:
>>
>> function test(stdClass $o) { var_dump($o); } $o = (object)1; test($o);
>
> ahh.. you miss the point, request: "I want to type hint that my function
> can accept objects of any type, but not primatives/array"
didn't miss your point, I complete misunderstood php functionality, for
some reason I was under the impression that every object was a derivative
of stdClass ... silly me.
do think this item on your wish list is a good idea, you should be
able to typehint 'object' ... and given tat we can already typehint
'array' I see no reason that other scalar types shouldn't be typehint-able.
note that 'array' is a valid typehint (can't remember which version that
came in exactly):
php -r ' function foo(array $r) { var_dump($r); } $r = array(); foo($r);'