php - phpcs - 防止显示“多行函数调用的左括号必须是该行的最后一个内容”
问题描述
此代码发生错误:
$posts = App\Post::whereHas('comments', function (Builder $query) {
$query->where('content', 'like', 'foo%');
});
我正在使用phpcs vscode,需要phpcs的所有默认规则,除了这个!
你能告诉我怎么做吗
- 编写一个包含所有默认规则的 phpcs
- 如何排除此规则
解决方案
您可以使用ruleset.xml
此内容
<?xml version="1.0"?>
<ruleset name="MyStandard">
<description>My custom coding standard.</description>
<rule ref="PEAR">
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
</rule>
</ruleset>
然后在 Phpcs 中添加这一行:standards settings.json
in VS code
{
"phpcs.standard": "path_to_your_standard/ruleset.xml"
}
有关规则集的更多信息,您可以在此处找到
推荐阅读
- r - 应用函数与用户定义的函数一起使用
- c++ - 需要帮助将两个 STL 地图合二为一(地图
和地图 进入地图 >) - configuration - 我可以从 Apache ActiveMQ Artemis broker.xml 中引用环境变量吗?
- python - LARGE txt文件中的Python匹配数据?
- scala - 指定任务 fs2 流 Scala 的处理时间
- express - 邮递员邮递不起作用,curl 也不能表达服务器。我究竟做错了什么?
- python - 在序列化程序自定义字段中排序
- java - 在 Java 中查找带有流的重复条目
- reactjs - Antd V4 表单列表 setFieldValue
- sql-server-2008 - 使用相关子查询与父查询的 sql 性能与通过获取最新记录的方法进行过度/分区