From:             mjs at beebo dot org
Operating system: Ubuntu
PHP version:      5.3.0
PHP Bug Type:     Class/Object related
Bug description:  __callStatic() only invoked if instance method does not exist

Description:
------------
A static call to Foo::bar() does not invoke __callStatic() if an 
instance method bar() exists.

One reason you might want this is to convert static calls to Foo::bar() 
to the equivalent operation on a singleton:

public static function __callStatic($name, $args) {
    $obj = self::getInstance();
    return call_user_func_array(array($obj, $name), $args);
}

In the sample code below, __callStatic() is not invoked even though the 
caller has deliberately initiated a static call.

Reproduce code:
---------------
<?php

class Foo {

    public static function __callStatic($name, $args) {
        echo "In __callStatic()\n";
    }

    public function bar() {
        echo "In bar()\n";
    }

}                                                                         
                                                                      
                                                                          
                                                                      
echo Foo::bar();


Expected result:
----------------
In _callStatic()

Actual result:
--------------
PHP Strict Standards:  Non-static method Foo::bar() should not be called 
statically in /mnt/hgfs/workspace/scratch/wart1.php on line 15

Strict Standards: Non-static method Foo::bar() should not be called 
statically in /mnt/hgfs/workspace/scratch/wart1.php on line 15
In bar()


-- 
Edit bug report at http://bugs.php.net/?id=49542&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49542&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49542&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49542&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49542&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49542&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49542&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49542&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49542&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49542&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49542&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49542&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49542&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49542&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49542&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49542&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49542&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49542&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49542&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49542&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49542&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49542&r=mysqlcfg

Reply via email to