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.
<?php function foo() { foreach ([] as list($a, $b, $c)) { $a; $b; $c; // Variable $a/$b/$c seems to be uninitialized } } ?> <?php foreach ([] as list($a, $b, $c)) { $a; $b; $c; // no warnings } ?> Only happens when inside a function or class method. No difference with a containing namespace and/or declare (in either statement or block form).
The problem still exists. Any progress in fixing for last 2 years?
(In reply to Megas from comment #1) > The problem still exists. > Any progress in fixing for last 2 years? Is the expected result the following? <?php function foo() { foreach ([] as list($a, $b, $c)) { $a; $b; $c; // Variable $a/$b/$c seems to be "unused" in its scope } } If no, could you provide some examples with expected and actual results? Thanks.
I don't remember this code showing an unused warning back then so that (or my settings) may have changed since. The expected behavior is that the same code inside and outside of a function should be analyzed the same way with respect to the uninitialized warning. So yes: it should show only the unused warning in both cases. Here's a small update to the repro code: // good foreach ([] as list($a, $b, $c)) { echo $a, $b, $c; // expected: no warnings, actual: no warnings } // bad function foo() { foreach ([] as list($a, $b, $c)) { echo $a, $b, $c; // expected: no warnings, actual: $a/$b/$c uninitialized } }
(In reply to requinix from comment #3) > I don't remember this code showing an unused warning back then so that (or > my settings) may have changed since. > > The expected behavior is that the same code inside and outside of a function > should be analyzed the same way with respect to the uninitialized warning. > So yes: it should show only the unused warning in both cases. > > Here's a small update to the repro code: > > // good > foreach ([] as list($a, $b, $c)) { > echo $a, $b, $c; // expected: no warnings, actual: no warnings > } > > // bad > function foo() { > foreach ([] as list($a, $b, $c)) { > echo $a, $b, $c; // expected: no warnings, actual: $a/$b/$c uninitialized > } > } I see. I'll try to fix it later. Thanks!
Fixed. http://hg.netbeans.org/web-main/rev/fb1bd20ec6ee Thanks.
Integrated into 'main-silver', will be available in build *201705260001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/fb1bd20ec6ee User: Junichi Yamamoto <junichi11@netbeans.org> Log: #249508 - In a function, foreach with list($a) warns about uninitialized $a