FAQ
Hi list

Since the hype-hint "callable" is out it doesn't catch if the callable
argument is directly callable - so currently using
"call_user_func[_array]" is a requirement.

@see http://3v4l.org/OYAgk

class MyClass {
      public static function test() {
          var_dump(__METHOD__);
      }
}

function call(callable $f) {
      $f();
}

call('MyClass::test');

I have created a PR to make this one possible and would very like to see
this one fixed from PHP-5.6 down to PHP-5.4 were the callable type-hint
was added.

Is there something I have to do ?
(I'll be not available after the next week for 3 month)

Marc

Search Discussions

  • Sebastian Krebs at May 15, 2014 at 6:17 pm

    2014-05-15 20:11 GMT+02:00 Marc Bennewitz <php@marc-bennewitz.de>:

    Hi list

    Since the hype-hint "callable" is out it doesn't catch if the callable
    argument is directly callable - so currently using "call_user_func[_array]"
    is a requirement.

    @see http://3v4l.org/OYAgk

    class MyClass {
    public static function test() {
    var_dump(__METHOD__);
    }
    }

    function call(callable $f) {
    $f();
    }

    call('MyClass::test');

    I have created a PR to make this one possible and would very like to see
    this one fixed from PHP-5.6 down to PHP-5.4 were the callable type-hint was
    added.

    Is there something I have to do ?
    (I'll be not available after the next week for 3 month)


    Hi

    I've fixed it :)

    http://3v4l.org/et7MX

    <?php

    class MyClass {
         public static function test() {
             var_dump(__METHOD__);
         }
    }

    function call(callable $f) {
         $f();
    }

    call(['MyClass','test']);


    Regards,
    Sebastian


    Marc

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

    --
    github.com/KingCrunch
  • Marc Bennewitz at May 15, 2014 at 6:22 pm

    On 15.05.2014 20:17, Sebastian Krebs wrote:
    2014-05-15 20:11 GMT+02:00 Marc Bennewitz <php@marc-bennewitz.de

    Hi list

    Since the hype-hint "callable" is out it doesn't catch if the
    callable argument is directly callable - so currently using
    "call_user_func[_array]" is a requirement.

    @see http://3v4l.org/OYAgk

    class MyClass {
    public static function test() {
    var_dump(__METHOD__);
    }
    }

    function call(callable $f) {
    $f();
    }

    call('MyClass::test');

    I have created a PR to make this one possible and would very like to
    see this one fixed from PHP-5.6 down to PHP-5.4 were the callable
    type-hint was added.

    Is there something I have to do ?
    (I'll be not available after the next week for 3 month)



    Hi

    I've fixed it :)

    http://3v4l.org/et7MX

    <?php

    class MyClass {
    public static function test() {
    var_dump(__METHOD__);
    }
    }

    function call(callable $f) {
    $f();
    }

    call(['MyClass','test']);
    You missed the point here. The callable type-hint accepts static methods
    formed as string but you can't call it directly. As a API developer
    point of view you have to call it using "call_user_func[_array]" or to
    parse and normalize such arguments which reduces readability and
    performance a lot.

    Regards,
    Sebastian



    Marc

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




    --
    github.com/KingCrunch <https://github.com/KingCrunch>
  • Marc Bennewitz at May 20, 2014 at 6:53 pm
    Nobody here to tell me if I have something to do with it?
    On 15.05.2014 20:11, Marc Bennewitz wrote:
    Hi list

    Since the hype-hint "callable" is out it doesn't catch if the callable
    argument is directly callable - so currently using
    "call_user_func[_array]" is a requirement.

    @see http://3v4l.org/OYAgk

    class MyClass {
    public static function test() {
    var_dump(__METHOD__);
    }
    }

    function call(callable $f) {
    $f();
    }

    call('MyClass::test');

    I have created a PR to make this one possible and would very like to see
    this one fixed from PHP-5.6 down to PHP-5.4 were the callable type-hint
    was added.

    Is there something I have to do ?
    (I'll be not available after the next week for 3 month)

    Marc

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedMay 15, '14 at 6:11p
activeMay 20, '14 at 6:53p
posts4
users2
websitephp.net

2 users in discussion

Marc Bennewitz: 3 posts Sebastian Krebs: 1 post

People

Translate

site design / logo © 2022 Grokbase