Edit report at http://bugs.php.net/bug.php?id=54186&edit=1
ID: 54186 Updated by: cataphr...@php.net Reported by: james at jamesreno dot com Summary: Scope Resolution / Closure Class Issues -Status: Open +Status: Bogus Type: Bug Package: Class/Object related Operating System: Linux-2.6 PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: $a->callback(); not working a problem of executing callbacks in fields not being supported (there's a RFC proposing that), the other is a mere grammatical issue. Closing; if anything this would be a feature request, but in that case the two issues ought to be filled separately, as they're unrelated. Previous Comments: ------------------------------------------------------------------------ [2011-03-07 20:59:11] james at jamesreno dot com 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 this bug report at http://bugs.php.net/bug.php?id=54186&edit=1