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 232007

Summary: IDEA: Detect $this usage when inside an static function member
Product: php Reporter: stormbyte
Component: EditorAssignee: Ondrej Brejla <obrejla>
Status: NEW ---    
Severity: normal CC: amobilia
Priority: P3    
Version: 7.3   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description stormbyte 2013-06-28 17:46:27 UTC
This should be very simple to implement and despite it may seem obvious that there is no this when in static context, when you are working some hours, you find that in the code eventually and you hit yourself in a wall (Didn't it happened to anyone?)

So I propose, to have hints for that, or even detect it as a "syntax error" with that red underline to make it clear that you are committing a mistake that would not work.

Something like:

...
public static function foo() {
   $this->something=34;
   ^^^^^ (red underline) and a hint when you pass mouse cursor over to something like: Cannot use this when not in object instance context.
Comment 1 stormbyte 2013-06-28 18:09:46 UTC
I am not sure if this is applicable to all other modules (C++, Java), but maybe this "issue" affects other modules also.
Comment 2 amobilia 2016-09-22 18:16:06 UTC
Reproductible in 8.2rc / Dev 201609210002