| From | Sent On | Attachments |
|---|---|---|
| Felipe Pena | Jun 5, 2011 8:52 am | |
| Benjamin Eberlei | Jun 5, 2011 8:57 am | |
| Felipe Pena | Jun 5, 2011 9:20 am | |
| Etienne Kneuss | Jun 5, 2011 9:41 am | |
| Pierre Joye | Jun 5, 2011 9:42 am | |
| Marcel Esser | Jun 5, 2011 9:48 am | |
| Ferenc Kovacs | Jun 5, 2011 11:16 am | |
| Stas Malyshev | Jun 5, 2011 12:49 pm | |
| Zeev Suraski | Jun 5, 2011 12:52 pm | |
| Pierre Joye | Jun 5, 2011 12:54 pm | |
| Johannes Schlüter | Jun 5, 2011 12:55 pm | |
| Felipe Pena | Jun 5, 2011 1:01 pm | |
| Zeev Suraski | Jun 5, 2011 1:09 pm | |
| Felipe Pena | Jun 5, 2011 1:34 pm | |
| Stas Malyshev | Jun 5, 2011 1:50 pm | |
| Felipe Pena | Jun 5, 2011 2:15 pm | |
| Hannes Landeholm | Jun 5, 2011 2:49 pm | |
| Stas Malyshev | Jun 5, 2011 3:15 pm | |
| Dmitry Stogov | Jun 6, 2011 12:23 am | |
| David Zülke | Jun 6, 2011 3:53 am | |
| Julien Pauli | Jun 6, 2011 6:21 am | |
| Hannes Magnusson | Jun 6, 2011 7:33 am | |
| Matthew Weier O'Phinney | Jun 6, 2011 8:54 am | |
| Matthew Weier O'Phinney | Jun 6, 2011 9:31 am | |
| Christopher Jones | Jun 6, 2011 1:50 pm | |
| Felipe Pena | Jun 6, 2011 2:49 pm | |
| Christian Kaps | Jun 8, 2011 4:38 am | |
| Felipe Pena | Jun 8, 2011 4:57 am | |
| Christian Kaps | Jun 8, 2011 5:11 am | |
| Felipe Pena | Jun 8, 2011 5:46 am | |
| Jordi Boggiano | Jun 8, 2011 6:39 am | |
| Christian Kaps | Jun 8, 2011 6:41 am | |
| Christian Kaps | Jun 8, 2011 6:48 am | |
| Rune Kaagaard | Jul 14, 2011 2:03 pm | |
| Felipe Pena | Jul 14, 2011 2:13 pm |
| Subject: | [PHP-DEV] Re: $arr = array('Hello', 'world'); $arr(); | |
|---|---|---|
| From: | Matthew Weier O'Phinney (weie...@php.net) | |
| Date: | Jun 6, 2011 8:54:44 am | |
| List: | net.php.lists.internals | |
On 2011-06-05, Felipe Pena <feli...@gmail.com> wrote:
Reading our bug tracker I noticed a good feature request [1] from 2009 which points to an interesting feature that I think makes sense for us, since we are now working with $f() using objects and strings, and the array('class', 'method') is an old known for call_user_func()-like functions.
So, I wrote a patch [2] that allow such behavior to be consistent with arrays. See some examples:
class Hello { public function world($x) { echo "Hello, $x\n"; return $this; } }
$f = array('Hello','world'); var_dump($f('you'));
$f = array(new Hello, 'foo'); $f();
All such calls match with the call_user_func() behavior related to magic methods, static & non-static methods.
The array to be a valid callback should be a 2-element array, and it must be for the first element object/string and for the second string only. (just like our zend_is_callable() check and opcodes related to init call)
Any thoughts?
Huge +1 from me -- having to do constructs like the following have been a huge headache for me:
if (is_callable($callback)) { if (is_object($callback) || is_string($callback)) { return $callback($arg); }
return call_user_func($callback, $arg) }
This would simplify that tremendously:
if (is_callable($callback)) { return $callback($arg); }
-- Matthew Weier O'Phinney Project Lead | matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php





