Req #64185 [Opn->Wfx]: is_callable does not check syntax
Edit report at https://bugs.php.net/bug.php?id=64185&edit=1
ID: 64185
Updated by: nikic@php.net
Reported by: hanskrentel at yahoo dot de
Summary: is_callable does not check syntax
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 5.4.11
Block user comment: N
Private report: N
New Comment:
Agree with what johannes said, marking as wontfix.
Previous Comments:
------------------------------------------------------------------------
[2013-02-13 14:40:45] johannes@php.net
Even with classes such names could - theoretically - exist due to weird (3rd party) extensions etc.
(i hope nobody does, but there's nothing stopping one)
So "syntax" in this case does not mean "one could use those names in syntactically
correct PHP code" but "the overall structure matches something that might be used in a
lookup"
------------------------------------------------------------------------
[2013-02-10 17:04:38] hanskrentel at yahoo dot de
NikiC was so friendly to just remind me that checking for the method name *is* limited because of
__call and __callStatic (basically everything for a method name works, including a zero-length
string).
So this feature request is actually more about the classname validation then the method name
validation.
------------------------------------------------------------------------
[2013-02-10 16:04:21] hanskrentel at yahoo dot de
Description:
------------
Using is_callable with the syntax_only parameter set to true does actually *not*
check the syntax, for example of a valid classname or FQCN.
Also not for the method name.
My feature request is, that it will always check those strings according to the
rules set in the PHP parser of the same PHP version the function ships with so
that it can be used to validate PHP syntax as well.
Same for calls with :: for static class name method calls.
Test script:
---------------
var_dump(is_callable(['', ''], true));
var_dump(is_callable(['', 'method'], true));
var_dump(is_callable(['0', 'method'], true));
var_dump(is_callable(['0\\foo', 'method'], true));
var_dump(is_callable(['\\0\\foo', 'method'], true));
Expected result:
----------------
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
Actual result:
--------------
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64185&edit=1
Thread (5 messages)