From:             mcroghan at digitalkeg dot com
Operating system: RH3
PHP version:      5.0.3
PHP Bug Type:     Feature/Change Request
Bug description:  is_callable / __call interaction

Description:
------------
Long story short, I created a class factory class.  I have singleton
classes which this class handles beautifully, except for non-singleton
classes which use __call.

All singleton classes have a method named "Singleton".  If this method
exists, I invoke the Singleton method via call_user_func (which I noticed
call_user_func doesn't route to __call, though that's in the bug DB).

Though I understand how __call is supposed to work and I love how it
works, I feel there needs to be some sort of differentiation between
classes that are explicitly defined in the class file vs what's being
routed to __call.

I spent a good 3 hours scouring the online PHP documentation to find a
solution that already exists for this, so my only assumption is that one
doesn't exist.  It would be a real asset to the function is_callable (or a
separate function) to be able to check for explicitly defined methods that
do not use __call.

I think it is valuable to be able to have the option for is_callable to be
able to detect methods that are callable via __call. I feel it is also
absolutely necessary that methods that can't be called without __call can
be detected properly as well. 

Reproduce code:
---------------
class CClass
{
   public function __constructor () {}

   public function __call ($_function, $_arguments)
   {}
}

$_className = 'CClass';

if (is_callable (array ($_className,'Singleton')))
        $class = call_user_func (array($_className, 'Singleton'));
else
        $class = new $_className ();

Expected result:
----------------
I would expect no fatal errors because PHP took a dump reporting singleton
doesn't exist when hitting call_user_func.

Actual result:
--------------
Fatal error: Call to undefined method CURL_Wrapper::singleton() in
/home/webos2/public_html/WebOS2/WebOS2.php on line 75

is_callable states the class method exists regardless of the situation
when using __call in a class.

-- 
Edit bug report at http://bugs.php.net/?id=31930&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31930&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31930&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31930&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31930&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31930&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31930&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31930&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31930&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31930&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31930&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31930&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31930&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31930&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31930&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31930&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31930&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31930&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31930&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31930&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31930&r=mysqlcfg

Reply via email to