Automattic / Automattic/VIP-Coding-Standards

File inclusion - check for constant defined in the current file

Open
#456 1 comment 0 reactions 0 assignees View on GitHub
Standard: VIP-Go Type: Enhancement
Dominant language
PHP
Stars
261
Forks
44
Avg merge
19m
Merged PRs (30d)
1

Description

## 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 . '/...';
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.