From:             
Operating system: Mac OS X
PHP version:      5.3.8
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:"Undefined variable" when calling closure/anon function from 
static property

Description:
------------
When trying to call a function stored in a static property I get the
"Undefined 
variable" notice and a "Function must be a string" fatal error. This
happens 
whether or not the function is stored directly in the property or in an
array.

A work around (for now) seems to be storing the property into a temp
variable.

Test script:
---------------
// Test Case 1:

class Foo
{
        public static $bar;
}

Foo::$bar = function() {
        echo 'Foo bar!';
};

Foo::$bar();

// Work around:

/*
$f = Foo::$bar;
$f();
*/

// Test Case 2:

class Foo
{
        public static $bar = array();
}

Foo::$bar['bar'] = function() {
        echo 'Foo bar!';
};

Foo::$bar['bar']();

Expected result:
----------------
Foo bar!

Actual result:
--------------
Notice: Undefined variable: bar
Fatal error: Function name must be a string

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

Reply via email to