I consider this an improvement in terms of consistency w.r.t.
callbacks, so +1 from me, good job!

Best,

On Sun, Jun 5, 2011 at 18:21, Felipe Pena <felipe...@gmail.com> wrote:
> 2011/6/5 Benjamin Eberlei <kont...@beberlei.de>
>
>> That can lead to quite a bit of simplifications in code where you now have
>> to check for is_array/is_callable/instanceof Closure and such. I like it.
>>
>>
> Exactly, and since our current $x = 'hello::world'; $x(); doesn't support
> method calls, the array one can help on this just like the call_user_func()
> approach with arrays.
>
> <?php
>
> class Hello {
>   static public function world($x) {
>     echo "Hello, $x\n";
>   }
> }
>
> function hello_world($x) {
>   echo "Hello, $x\n";
> }
>
> $callbacks = array(
>   array('Hello', 'world'),
>   function ($x) { echo "Hello, $x\n"; },
>   'hello_world'
> );
>
> foreach ($callbacks as $k => $callback) {
>   if (is_callable($callback)) {
>     $callback($k);
>   }
> }
>
> Output:
> Hello, 0
> Hello, 1
> Hello, 2
>
> --
> Regards,
> Felipe Pena
>



-- 
Etienne Kneuss
http://www.colder.ch

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to