> No default values, other then NULL allowed. > Otherwise we would need to support array("classname", "methodname") > too, and then people would want default array values for array > typehinting etc etc etc.
Unless I mis-read what you said, we already have default array values for array type-hinting: function foo(array $array = array('bar', 'baz')) { var_dump($array); } foo(); foo(array()); Works perfectly for me on 5.3.6... 2011/6/8 Hannes Magnusson <hannes.magnus...@gmail.com>: > 2011/6/8 Johannes Schlüter <johan...@schlueters.de>: >> On Tue, 2011-06-07 at 12:12 -0700, Stas Malyshev wrote: >>> Hi! >>> >>> > https://wiki.php.net/rfc/callable >>> >>> It is good there's an RFC. However it seems to lack code examples. I >>> understand it may be obvious to the proposers how it looks like, but >>> it'd be nice to have the actual example there as it is done nearly >>> everywhere else. >> >> The RFC is missing information about what happens in codebases which >> already have a "callable" type declared. Will that be prevented or will >> they hit a runtime error? ("callable expected, callable type found") > > You mean an interface/class with that name? > The error would be 'expected instanceof callable, string/array/closure > recieved. > > gettype("strpos") will still return a string, not callable. > > A callable wouldn't be fully featured type. > >> What about default values? Will >> function foo(callback $cb = 'strpos') { } >> be valid? > > No default values, other then NULL allowed. > Otherwise we would need to support array("classname", "methodname") > too, and then people would want default array values for array > typehinting etc etc etc. > > > >> The information on reflection is limited. what shall >> Reflection::Parameter::getTypehint() return? Will that method allow to >> differ between a class type and this "magic"? > > There is no such method anymore :) > > >> >> What about ARGINFO? Will internal functions be able to define this type >> via ARGINFO? How will this be reported in `php --rf function`? > > I didn't include arginfo in the patch, but good point. It should > probably be included. > As Felipe pointed out, ext/reflection hasn't been updated. > It should return [ callable $foobar ], just like with any other typehint > > -Hannes > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php