How can I supress a warning in PHP files for NetBeans?(如何抑制 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.
这篇关于如何抑制 NetBeans 的 PHP 文件中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何抑制 NetBeans 的 PHP 文件中的警告?


基础教程推荐
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01