如何抑制 NetBeans 的 PHP 文件中的警告?
我有一个 PHP 文件,其中一行在 NetBeans 中产生警告.如何强制 IDE 忽略该具体警告?
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.
这是一行示例代码:
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.'
我知道如何更正代码,但请注意,我问了完全不同的问题!我需要一种方法来抑制在 if 子句中具有相同语句的警告.
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.
您可以在下面看到我如何抑制 C# 中的 ReSharper 警告.我想在 PHP 中为 NetBeans 提供类似的东西:
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
推荐答案
虽然你不能只禁用一个警告(寻找像 http://netbeans.org/bugzilla/show_bug.cgi?id=97224),这个问题有一个通用的解决方案(如果你有忽略子语句中的赋值"打开):
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:双括号 = 忽略此类警告.
TLDR: Double brackets = Ignore this type of warning.
相关文章