問題描述
我有一個 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.
這篇關于如何抑制 NetBeans 的 PHP 文件中的警告?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!