Req #64185 [Opn]: is_callable does not check syntax

From: Date: Wed, 13 Feb 2013 14:40:45 +0000
Subject: Req #64185 [Opn]: is_callable does not check syntax
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-176603@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64185&edit=1

 ID:                 64185
 Updated by:         johannes@php.net
 Reported by:        hanskrentel at yahoo dot de
 Summary:            is_callable does not check syntax
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 PHP Version:        5.4.11
 Block user comment: N
 Private report:     N

 New Comment:

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"


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#176603) next »