From:             tom at r dot je
Operating system: Windows Vista
PHP version:      5.3.0
PHP Bug Type:     Feature/Change Request
Bug description:  Reference Native Function in variable (function pointers)

Description:
------------
With the intorduction of closures it would be nice to be able to have some
control over native functions for example:


$foo = function() { 
echo 'bar';
}

$foo();

Works fine. 


It would be nice to be able to do something like

function foo() {
echo 'bar';
}

$foo = &foo;
$foo();

And ultimately, override the defined function:

function foo() {
echo 'bar';
}

$oldFoo = &foo;
foo = function() use ($oldFoo) {
   $oldFoo();
   echo 'bar';
}


foo(); // will print 'foobar';

There are several uses for this, just look at the way closures are
commonly used in javascript. It's really useful for debugging, as a
function can be substituted easily.

Though this probably isn't possible due to the clear distinction php makes
between functions and variables. 


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

Reply via email to