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.
Hi, there are multiple small problems with the scope-hints in the PHP editor: 1. $first is marked as "Variable does not seem to be used in its scope": $first = $keys[0]; $foo = $this->bar[$first]->getBaz(); 2. $actual is marked as "Variable does not seem to be used in its scope": $actual = $this->getParsedSegmentsFromFile('BROKEN'); $this->assertTrue($actual[0]['title'] == ''); 3. $conn is marked as "Variable does not seem to be used in its scope": try { $conn = ...; } catch (Exception $e) { $conn = ...; } or: if ($someConstraint) { $var = 'foo'; } else { $var = 'bar' } While I wouldn't write code like above, I'm spotting the above pattern very often. Netbeans marks these variables as "not used", which is wrong, as they are perfectly valid and always defined after passing the try-catch- or if-then-else- block. Perhaps the hint message should be changed to something more proper or not displayed as all. I'm using an up2date Netbeans dev nightly build: Product Version: NetBeans IDE Dev (Build 2009-04-30_14-26-24 ) Java: 1.6.0_05; Java HotSpot(TM) Client VM 10.0-b19 System: Windows Vista version 6.0 running on x86; Cp1252; de_DE (nb)
I'm seeing #3 quite often myself, dealing with a large pre-existing code base. There is a second warning triggered in patterns like these: $test = true; if ($test) { $out = 'true!'; } else { $out = 'false!'; } echo $out; The first two usages of $out are marked "Variable does not seem to be used in its scope" (which is silly, since the if statement does not introduce a new scope), and the third usage is marked "Variable might not have been initialized". Of course it may be very difficult to make sure the latter warning never appears spuriously, since you have to account for all the possible code branches you could travel through to arrive at the current line (imagine if the "else" block was a couple hundred lines of nested loops, switches, breaks, returns, and recursive function calls).
experimental hint *** This issue has been marked as a duplicate of 170541 ***