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 271856

Summary: Wrong PHP syntax check for PHP foreach as list
Product: ide Reporter: kyborek
Component: CodeAssignee: issues@ide <issues>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.2   
Hardware: PC   
OS: Windows 10   
Issue Type: DEFECT Exception Reporter:
Attachments: IDE log
Screenshot of the actual problem

Description kyborek 2017-11-28 07:29:18 UTC
Product Version = NetBeans IDE 8.2 (Build 201705191307)
Operating System = Windows 10 version 10.0 running on amd64
Java; VM; Vendor = 1.8.0_101
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.101-b13

Reproducibility: Happens every time

STEPS:
  * Create a PHP function
  * Inside the function use code with 'foreach as list' like below
  * Turn on error checking for uninitialized variables if not enabled

CODE:
function foo($array){
 foreach ($array as list($first,$second)){
  echo $first." ".$second;//this is the problematic line of code
 }
}

ACTUAL:
  IDE shows warning stating that $first is an uninitialized variable

EXPECTED:
  No error regarding $first or $second variable as both were initialized in the 'list' statement
Comment 1 kyborek 2017-11-28 07:29:24 UTC
Created attachment 165507 [details]
IDE log
Comment 2 kyborek 2017-11-28 07:33:46 UTC
Created attachment 165508 [details]
Screenshot of the actual problem