This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 179303

Summary: "Variable does not seem to be used in this scope" warning sometimes wrong
Product: php Reporter: lathspell
Component: EditorAssignee: rmatous <rmatous>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description lathspell 2010-01-08 02:59:44 UTC
Hello

Netbeans warns me with a little yellow alert sign on the left side that the following code is considered suspicious. When I put the mouse over the alert sign it says "Variable does not seem to be used in this scope". I like this check as it helps spotting typos in variable names but this time it is certainly on the wrong track. It underlins the $i in the foreach statement although that variable gets used as a object reference one line below:

    class T {
	public $attr = 42;

	public function f() {
            $a = array(new T(), new T());
	    foreach ($a as $i) {
	 	echo $i->attr;
	    }
	}
    }

The bug does not occur in every foreach nor if I move the foreach out of the class.
Comment 1 rmatous 2010-03-19 13:42:36 UTC
experimental hint

*** This bug has been marked as a duplicate of bug 170541 ***