Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319001

Summary: Anonymous function inside a class method breaks the scope
Product: z_Archived Reporter: Kirill <kirill>
Component: PDTAssignee: PHP Core <php.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: gadi, ganoro, gern_, kirill, petyo_tanchev, silviya, zhaozhongwei
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows All   
Whiteboard:
Attachments:
Description Flags
Test for reproduction
none
Patch file.
none
Unitest for the bug
none
patch none

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