Automattic / Automattic/VIP-Coding-Standards

File inclusion - check for constant defined in the current file

未关闭
#456 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Standard: VIP-Go Type: Enhancement
主要语言
PHP
星标
261
派生
44
平均合并
19 分钟
30 天内合并 PR
1

描述

## What problem would the enhancement address for VIP?

The frequency with which "Warning: File inclusion using custom constant (`PREFIX_PATH`). Probably needs manual inspection (WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant)." shows up just below a line that matches the pattern is high.

Perhaps we can reduce this noise.

## Describe the solution you'd like

See if we can improve the sniff, to see if the constant has been defined in the current file, and if so, skip the violation.

## What code should be reported as a violation?

```php
require PREFIX_PATH_UNDEFINED_IN_THIS_FILE . '/...';
```

## What code should *not* be reported as a violation?

```php
define( 'PREFIX_PATH_DEFINED_IN_THIS_FILE', '...' );
...other code...
require PREFIX_PATH_DEFINED_IN_THIS_FILE . '/...';
```

贡献指南

打开贡献指南

调研方向

首先找到发出 WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant 的 sniff,并检查它如何检测文件包含表达式中的常量。为未定义常量的示例以及在同一文件中较早定义的常量添加覆盖;完成标准是只报告未定义的情况。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
tooling
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。