Search code examples
phpnetbeanssuppress-warnings

How can I supress a warning in PHP files for NetBeans?


I have a PHP file with a line that produces a warning in NetBeans. How can I force the IDE to ignore that concrete warning?

Notice that I don't want to disable this type of warning solution-wide.

Here is a sample line of code:

if ($query = db_query("SELECT column FROM {table} WHERE type='some_value'")) { ... }

Here is a text of produced warning: 'Possible accidental assignment, assignments in conditions should be avoided.'


I know how to correct the code, but notice that I've asked completely other question! I need a way to suppress the warning having the same statement in the if clause.

I’m not going to use the @ operator either, because it has a completely other mission.

Below you can see how I suppress the ReSharper warning(s) in C#. I want something like that in PHP for NetBeans:

// ReSharper disable PossibleNullReferenceException
_currentPage = restoredStageSurvey._currentPage;
// ReSharper restore PossibleNullReferenceException

Solution

  • While you can't just disable one warning (look for bug reports like http://netbeans.org/bugzilla/show_bug.cgi?id=97224), there is a common solution for this problem (if you have "Ignore assignments in sub-statements" turned ON):

    if(($x=$y)) {}
    

    TLDR: Double brackets = Ignore this type of warning.