Automattic / Automattic/VIP-Coding-Standards
File inclusion - check for constant defined in the current file
- Vorherrschende Sprache
- PHP
- Sterne
- 261
- Forks
- 44
- Ø Merge
- 19 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
## 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 . '/...';
```
Beitragsleitfaden
Rechercherichtung
Beginne damit, den Sniff zu finden, der WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant ausgibt, und untersuche, wie er Konstanten in Ausdrücken zum Einbinden von Dateien erkennt. Füge Abdeckung für das Beispiel mit der undefinierten Konstante und für die Konstante hinzu, die zuvor in derselben Datei definiert wurde; abgeschlossen ist die Aufgabe, wenn nur der undefinierte Fall gemeldet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100