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 - IDEA: Detect $this usage when inside an static function member
Summary: IDEA: Detect $this usage when inside an static function member
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-28 17:46 UTC by stormbyte
Modified: 2016-09-22 18:16 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

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