php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54186 Scope Resolution / Closure Class Issues
Submitted: 2011-03-07 20:59 UTC Modified: 2011-03-09 17:26 UTC
From: james at jamesreno dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.5 OS: Linux-2.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: james at jamesreno dot com
New email:
PHP Version: OS:

 

 [2011-03-07 20:59 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-09 11:10 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-03-09 11:10 UTC] cataphract@php.net
$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.
 [2011-03-09 17:26 UTC] james at jamesreno dot com
"the other is a mere grammatical issue."  Would you care to explain?

To me these features seem half implemented which mean they are bugs -- not 
feature requests. The language already supports said items just not in "certain 
contexts" (To which should be noted in documentation, at very least).  At least 
change this to a documentation bug - do not close it as "bogus" the bug is 
clearly NOT bogus as it indeed is real and does affect the language and usage 
there-of -- "WONT FIX" is more like it.

Anyone can close bugs as bogus and put some b.s. response. I spent the time to 
detail out the issue and document it clearly it would be nice if you could at 
least spend the same effort responding to it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 11 16:01:36 2024 UTC