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 - Invalid warnings shown for variable variables ($$) in php
Summary: Invalid warnings shown for variable variables ($$) in php
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.1
Hardware: All All
: P4 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-23 09:23 UTC by sherif.onion
Modified: 2016-06-02 12:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.