Re: Problem with (namespaced) code extending ReflectionProperty - possible bug?

From: Date: Mon, 08 Dec 2008 16:27:40 +0000
Subject: Re: Problem with (namespaced) code extending ReflectionProperty - possible bug?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-42160@lists.php.net to get a copy of this message
Hello Stanislav, Monday, December 8, 2008, 4:50:52 PM, you wrote: > Hi! >> According to the manual and the PHP source the signature is this: >> public function getValue(stdclass $object) > Manual is unfortunately not exact in this point - true signature for it > is public function getValue([object $object]) - i.e. $object is not > required and if it's supplied, it doesn't have to be stdclass - any > object will do. Thus, engine correctly complains that your signature - > required object of stdclass - is not compatible. Which reminds me that we still have no way to do that in userland. In userland you cannot write: function foo(Object $bla = NULL). The missing part is 'Object' as a type hint. I once long ago suggested using 'class' as in 'any class member'. But people felt it wouldn't be self explanatory enough. And unfortunately we cannot use 'Object' for obvious reasons. We simply cannot turn that into a reserved word not can we expect no one to have a class named Object already. So my suggestion holds: Let's add type hint 'class' to allow hints for objects. marcus >> >> This is my test code: >> ---- snip ---- >> <?php >> class PropertyReflection extends ReflectionProperty { >> public function getValue(stdclass $object) {} >> } >> ?> > Use public function getValue($object = null) {} instead. > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com http://www.zend.com/ > (408)253-8829 MSN: stas@zend.com Best regards, Marcus

« previous php.internals (#42160) next »