PHP 函数返回引用冲突与自定义 WordPress 插件中的 PHPCodeSniffer 冲突

PHP function returning reference conflicts with PHPCodeSniffer in custom WordPress plugin

提问人:x4wp 提问时间:11/18/2023 最后编辑:x4wp 更新时间:11/18/2023 访问量:33

问:

我在我的自定义 WordPress 插件中尝试了以下代码:

function &test() {
  $a = 1;
  return $a;
}

这会导致 codesniffer 错误:

------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------
 5 | ERROR | [x] No space after opening parenthesis is prohibited
   |       |     (WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis)
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------

怎么修?请给我看工作代码。

php wordpress phpcodesniffer

评论


答: 暂无答案