ID:               31930
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mcroghan at digitalkeg dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Feature/Change Request
 Operating System: RH3
 PHP Version:      5.0.3
 New Comment:

Works fine for me, considering fixed in 5.1.


Previous Comments:
------------------------------------------------------------------------

[2005-02-11 08:45:01] mcroghan at digitalkeg dot com

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 this bug report at http://bugs.php.net/?id=31930&edit=1

Reply via email to