Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319001 - Anonymous function inside a class method breaks the scope
Summary: Anonymous function inside a class method breaks the scope
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 319921 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-07-06 08:49 EDT by Kirill CLA
Modified: 2020-05-14 11:16 EDT (History)
7 users (show)

See Also:


Attachments
Test for reproduction (168 bytes, application/x-httpd-php)
2010-07-06 08:52 EDT, Kirill CLA
no flags Details
Patch file. (1.75 KB, patch)
2010-07-06 09:21 EDT, Kirill CLA
no flags Details | Diff
Unitest for the bug (934 bytes, application/octet-stream)
2010-07-06 09:28 EDT, Kirill CLA
no flags Details
patch (6.95 KB, patch)
2010-07-06 10:48 EDT, Zhongwei Zhao CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kirill CLA 2010-07-06 08:49:26 EDT
Build Identifier: Studio 7.2 based on Eclipse 3.6

Anonymous function inside a class method breaks current scope. Everything that comes after the lambda function declaration becomes belonging to the outer scope, which is a class in this case. This issue can be seen in an Outline view.

Reproducible: Always
Comment 1 Kirill CLA 2010-07-06 08:52:25 EDT
Created attachment 173542 [details]
Test for reproduction

Use this for test/reproduction.
Local variables $before and $after should not be displayed in Outline.
Comment 2 Kirill CLA 2010-07-06 09:21:00 EDT
Created attachment 173547 [details]
Patch file.
Comment 3 Kirill CLA 2010-07-06 09:21:28 EDT
Fixed. The patch is attached.
Comment 4 Kirill CLA 2010-07-06 09:28:30 EDT
Created attachment 173548 [details]
Unitest for the bug
Comment 5 Zhongwei Zhao CLA 2010-07-06 10:46:45 EDT
Hi Kirill

Thanks for you patch!!
I have not noticed you also fixed this bug,I am trying to fix this too:)
After apply your patch:
class A {
	
	public function Foo() 

	{
		$before = 0;
		$add = function ($x) {
			return ($| + 1);//$x is not shown here when call CA
		};
		$after = 0;
	
	}

}

And I will attach my patch,and I am not sure if my patch will cause other problem:)
Comment 6 Zhongwei Zhao CLA 2010-07-06 10:48:20 EDT
Created attachment 173564 [details]
patch

my patch
Comment 7 Zhongwei Zhao CLA 2010-07-14 23:16:31 EDT
*** Bug 319921 has been marked as a duplicate of this bug. ***
Comment 8 Petyo Tanchev CLA 2010-08-31 06:22:40 EDT
Tested on 2.2.1.v20100829
Fixed