From:             
Operating system: Linux-2.6
PHP version:      5.3.5
Package:          Class/Object related
Bug Type:         Bug
Bug description:Scope Resolution / Closure Class Issues

Description:
------------
closure objects which are members of another object can not be executed
without 

temp intermediary variables and constants of objects can not be accessed
when 

they are members of another object.



I can not find any documentation to support why these two items throw
syntax 

errors rather than executing as expected. At very least case this is a 

documentation issue and should be noted.

Test script:
---------------
<?



class apples {

 const test = "This is a test";

}



class test {

 public $callback = FALSE;

 public $test = FALSE;



 function __construct($callback) {

        $this->callback = $callback;

        $this->test = new apples();

 }

}





$a = new test(function(){

        echo "test\n";

});



/*

 * Broken Closure Class Example

 */



// BROKEN:

$a->callback();



// Works

$tmp = $a->callback;

$tmp();



/*

 * Broken constant scope resolution

 */



// BROKEN:

$a->test::test;



// Works

$tmp = $a->test;

echo $tmp::test;



?>

Expected result:
----------------
Would expect:



$a->callback() to execute the anonymous function.



would expect:

echo $a->test::test to echo "This is a test"

Actual result:
--------------
Both references cause syntax errors.

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

Reply via email to