atom feed60 messages in net.php.lists.internalsRe: [PHP-DEV] Callable type
FromSent OnAttachments
Hannes MagnussonJun 6, 2011 12:41 pm.txt
Stas MalyshevJun 6, 2011 1:35 pm 
Hannes MagnussonJun 6, 2011 1:48 pm 
Christopher JonesJun 6, 2011 1:49 pm 
Stas MalyshevJun 6, 2011 2:16 pm 
Matthew Weier O'PhinneyJun 6, 2011 3:15 pm 
Pierre JoyeJun 6, 2011 3:26 pm 
Matthew Weier O'PhinneyJun 6, 2011 3:32 pm 
Etienne KneussJun 6, 2011 3:41 pm 
Chris StocktonJun 6, 2011 3:51 pm 
Chris StocktonJun 6, 2011 3:52 pm 
Ferenc KovacsJun 6, 2011 4:01 pm 
Stas MalyshevJun 6, 2011 4:01 pm 
Chris StocktonJun 6, 2011 4:20 pm 
Derick RethansJun 6, 2011 4:30 pm 
Martin ScottaJun 6, 2011 7:50 pm 
Jordi BoggianoJun 7, 2011 3:08 am 
Hannes MagnussonJun 7, 2011 6:59 am 
Richard QuadlingJun 7, 2011 7:03 am 
Hannes MagnussonJun 7, 2011 7:21 am 
Jaroslav HanslikJun 7, 2011 8:22 am 
Matthew Weier O'PhinneyJun 7, 2011 9:10 am 
Stas MalyshevJun 7, 2011 11:50 am 
David ZülkeJun 7, 2011 12:03 pm 
Stas MalyshevJun 7, 2011 12:12 pm 
David ZülkeJun 7, 2011 12:28 pm 
Anthony FerraraJun 7, 2011 12:37 pm 
Martin ScottaJun 7, 2011 1:28 pm 
Stas MalyshevJun 7, 2011 1:31 pm 
David ZülkeJun 7, 2011 1:32 pm 
Pierre JoyeJun 7, 2011 1:36 pm 
Mike van RielJun 7, 2011 1:43 pm 
Matthew Weier O'PhinneyJun 7, 2011 1:44 pm 
dukeofgamingJun 7, 2011 2:15 pm 
Matthew Weier O'PhinneyJun 7, 2011 2:41 pm 
dukeofgamingJun 7, 2011 3:38 pm 
Johannes SchlüterJun 7, 2011 4:39 pm 
David ZülkeJun 7, 2011 5:04 pm 
Alexey SheinJun 7, 2011 10:24 pm 
Hannes MagnussonJun 8, 2011 1:31 am 
Hannes MagnussonJun 8, 2011 1:38 am 
Alexey SheinJun 8, 2011 1:47 am 
Johannes SchlüterJun 8, 2011 3:04 am 
Hannes MagnussonJun 8, 2011 3:17 am 
Richard QuadlingJun 8, 2011 3:27 am 
Johannes SchlüterJun 8, 2011 3:28 am 
Hannes MagnussonJun 8, 2011 3:30 am 
Johannes SchlüterJun 8, 2011 3:31 am 
Richard QuadlingJun 8, 2011 3:31 am 
Anthony FerraraJun 8, 2011 6:31 am 
Martin ScottaJun 8, 2011 7:42 am 
Martin ScottaJun 8, 2011 7:48 am 
David ZülkeJun 8, 2011 8:53 am 
Johannes SchlüterJul 10, 2011 12:02 pm 
Stas MalyshevJul 10, 2011 12:57 pm 
Hannes MagnussonJul 11, 2011 1:21 am 
Stas MalyshevJul 11, 2011 1:27 am 
Peter CowburnJul 11, 2011 1:37 am 
Hannes MagnussonJul 11, 2011 1:38 am 
Stas MalyshevJul 11, 2011 1:43 am 
Subject:Re: [PHP-DEV] Callable type
From:Martin Scotta (mart@gmail.com)
Date:Jun 8, 2011 7:48:10 am
List:net.php.lists.internals

Martin Scotta

On Wed, Jun 8, 2011 at 10:31 AM, Anthony Ferrara <ircm@gmail.com>wrote:

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...

it works since long time ago

2011/6/8 Hannes Magnusson <hann@gmail.com>:

2011/6/8 Johannes Schlüter <joha@schlueters.de>:

On Tue, 2011-06-07 at 12:12 -0700, Stas Malyshev wrote:

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