php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62689 get_callable_name function to avoid is_callable with callable type hint
Submitted: 2012-07-29 14:35 UTC Modified: 2020-09-17 14:32 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: franssen dot roland at gmail dot com Assigned:
Status: Suspended Package: Unknown/Other Function
PHP Version: 5.4.5 OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 + 47 = ?
Subscribe to this entry?

 
 [2012-07-29 14:35 UTC] franssen dot roland at gmail dot com
Description:
------------
Currently the callable name can only be fetched using is_callable and a 3rd argument. However this doesnt seem appropriate when using callable type hints..

get_callable_name (just like get_resource_type) would be in place imho.

Test script:
---------------
<?php
function foo(callable $bar) {
    $name = null;
    $name = is_callable($bar, true, $name);

    // vs

    $name = get_callable_name($bar);
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-14 14:37 UTC] cmb@php.net
Using is_callable() to get the name can be simplified:

  is_callable($bar, true, $name);
  
vs.

  $name = get_callable_name($bar);
  
That's not much of a difference. And of course, it is possible to
to write the desired function in userland code.
 [2020-09-17 14:32 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2020-09-17 14:32 UTC] cmb@php.net
If you're still interested in having get_callable_name(), please
forward this request to the internals mailing list[1], since this
feature needs to be discussed (besides that it's trivial to
implement the function in userland, the name wouldn't fit to our
naming scheme).  Thanks!  For the time being, I'm suspending this
ticket.

[1] <https://www.php.net/mailing-lists.php#internals>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 16:01:28 2024 UTC