# PR 659 / #60687: directly call a callable

- Thread: https://externals.io/message/74229
- Original archive: https://news-web.php.net/php.internals/74229
- Started by Marc Bennewitz on 2014-05-15T18:11:04+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #74229 — Marc Bennewitz — 2014-05-15T18:11:04+00:00

URL: https://externals.io/message/74229#74229

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

---

## #74231 — Sebastian Krebs — 2014-05-15T18:17:09+00:00

URL: https://externals.io/message/74229#74231 · In reply to: #74229

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


-- 
github.com/KingCrunch

---

## #74233 — Marc Bennewitz — 2014-05-15T18:22:32+00:00

URL: https://externals.io/message/74229#74233 · In reply to: #74231

> 2014-05-15 20:11 GMT+02:00 Marc Bennewitz <php@marc-bennewitz.de
> <mailto: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
>
>     --
>     
>     
>
>
>
>
> --
> github.com/KingCrunch <https://github.com/KingCrunch

---

## #74385 — Marc Bennewitz — 2014-05-20T18:53:10+00:00

URL: https://externals.io/message/74229#74385 · In reply to: #74229

Nobody here to tell me if I have something to do with it?


> 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
