|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-03-09 11:10 UTC] cataphract@php.net
-Status: Open
+Status: Bogus
[2011-03-09 11:10 UTC] cataphract@php.net
[2011-03-09 17:26 UTC] james at jamesreno dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 19:00:01 2025 UTC |
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.