Automattic / Automattic/VIP-Coding-Standards
Catch incorrect bloginfo() usage
- 主要语言
- PHP
- 星标
- 261
- 派生
- 44
- 平均合并
- 19 分钟
- 30 天内合并 PR
- 1
描述
## What problem would the enhancement address for VIP?
When using `bloginfo()`, the caller should not echo the output, as `bloginfo()` does this internally (see [here](https://developer.wordpress.org/reference/functions/bloginfo/#source)). Callers should simply call `bloginfo()` without any `echo`, but if the callers want to control when the output is echoed, they should use `get_bloginfo()` ([#](https://developer.wordpress.org/reference/functions/get_bloginfo/)). Our standards should catch these kinds of issues in code.
## Describe the solution you'd like
The usage of `echo bloginfo()` should be caught and advice given on using `get_bloginfo()` instead or to skip the echo.
## What code should be reported as a violation?
echo bloginfo( 'name' );
## What code should *not* be reported as a violation?
echo get_bloginfo( 'name' );
贡献指南
调研方向
从检查函数使用情况的 PHP_CodeSniffer 规则开始,以 bloginfo() 和 get_bloginfo() 作为入口点。确认 echo bloginfo( 'name' ) 会被报告,并建议省略 echo 或使用 get_bloginfo(),而 echo get_bloginfo( 'name' ) 不会被报告;如果相关规则测试可用,请运行它们。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- tooling
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100