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 258109

Summary: Invalid warnings shown for variable variables ($$) in php
Product: php Reporter: sherif.onion
Component: EditorAssignee: Tomas Mysik <tmysik>
Status: NEW ---    
Severity: normal CC: junichi11
Priority: P4    
Version: 8.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description sherif.onion 2016-02-23 09:23:38 UTC
Invalid editor warnings are shown if you use variable variables in php.


Here is a simple (reproducible) example:

$a = 'hello';
$$a = ' world';
echo $hello;  // produces 'world'
echo $a . $$a; // produces 'hello world'

The editor shows warnings as follows:
- Lines 1 & 2 "You should only use one assignment (2 used)..."
- Line 3 "$hello is not initialised" (it is initialised and has a value 'world').
Comment 1 junichi11 2016-03-12 23:49:46 UTC
(In reply to sherif.onion from comment #0)
> - Lines 1 & 2 "You should only use one assignment (2 used)..."

$$a should be ignored.

> - Line 3 "$hello is not initialised" (it is initialised and has a value
> 'world').

Probably, it's hard to fix this(Line3).

Thanks.
Comment 2 Tomas Mysik 2016-06-02 12:08:48 UTC
IMHO using "$$" is not a good practice, it makes code really difficult to read and understand.

Thanks for reporting.