如何在Netbeans的PHP文件中禁止警告? [英] How to supress a warning in PHP files for Netbeans?

查看:97
本文介绍了如何在Netbeans的PHP文件中禁止警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP文件,其中的一行会在NetBeans中产生警告. 如何强制IDE忽略该具体警告?请注意,我不想在整个解决方案中都禁用这种类型的警告.

I have a PHP file with a line that produces a warning in the 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.'

UPD:亲爱的同事们,我知道如何更正代码,但是请注意,我已经完全问了另一个问题! 我需要一种方法来抑制if子句中具有相同语句的警告.

UPD: Dear colleagues, 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 also because it has completely other mission.

UPD2: 在下面,您可以看到如何抑制C#中的Resharper警告.我想要在PHP for NetBeans中使用类似的方法:

UPD2: 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

推荐答案

虽然不能只禁用一个警告(请查找错误报告,例如

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 assigments in sub-statements" turned ON):

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

TLDR:双括号=忽略这种类型的警告.

TLDR: Double brackets = Ignore this type of warning.

这篇关于如何在Netbeans的PHP文件中禁止警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆