|
13 | 13 | /**
|
14 | 14 | * WordPressVIPMinimum_Sniffs_Files_IncludingFileSniff.
|
15 | 15 | *
|
16 |
| - * Checks for custom variables, functions and constants, and external URLs used in file inclusion. |
| 16 | + * Checks that __DIR__, dirname( __FILE__ ) or plugin_dir_path( __FILE__ ) |
| 17 | + * is used when including or requiring files. |
17 | 18 | *
|
18 | 19 | * @package VIPCS\WordPressVIPMinimum
|
19 | 20 | */
|
@@ -54,17 +55,6 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
|
54 | 55 | 'WP_PLUGIN_DIR',
|
55 | 56 | ];
|
56 | 57 |
|
57 |
| - /** |
58 |
| - * List of keywords allowed for use in custom constants. |
59 |
| - * Note: Customizing this property will overwrite current default values. |
60 |
| - * |
61 |
| - * @var array |
62 |
| - */ |
63 |
| - public $allowedKeywords = [ |
64 |
| - 'PATH', |
65 |
| - 'DIR', |
66 |
| - ]; |
67 |
| - |
68 | 58 | /**
|
69 | 59 | * Functions used for modify slashes.
|
70 | 60 | *
|
@@ -132,11 +122,6 @@ public function process_token( $stackPtr ) {
|
132 | 122 | return;
|
133 | 123 | }
|
134 | 124 |
|
135 |
| - if ( $this->has_custom_path( $this->tokens[ $nextToken ]['content'] ) === true ) { |
136 |
| - // The construct is using a constant with an allowed keyword. |
137 |
| - return; |
138 |
| - } |
139 |
| - |
140 | 125 | if ( array_key_exists( $this->tokens[ $nextToken ]['content'], $this->restrictedConstants ) === true ) {
|
141 | 126 | // The construct is using one of the restricted constants.
|
142 | 127 | $message = '`%s` constant might not be defined or available. Use `%s()` instead.';
|
@@ -187,21 +172,4 @@ public function process_token( $stackPtr ) {
|
187 | 172 | $message = 'Absolute include path must be used. Use `get_template_directory()`, `get_stylesheet_directory()` or `plugin_dir_path()`.';
|
188 | 173 | $this->phpcsFile->addError( $message, $nextToken, 'NotAbsolutePath' );
|
189 | 174 | }
|
190 |
| - |
191 |
| - /** |
192 |
| - * Check if a content string contains a keyword in custom paths. |
193 |
| - * |
194 |
| - * @param string $content Content string. |
195 |
| - * |
196 |
| - * @return bool True if the string partially matches a keyword in $allowedCustomKeywords, false otherwise. |
197 |
| - */ |
198 |
| - private function has_custom_path( $content ) { |
199 |
| - foreach ( $this->allowedKeywords as $keyword ) { |
200 |
| - if ( strpos( $content, $keyword ) !== false ) { |
201 |
| - return true; |
202 |
| - } |
203 |
| - } |
204 |
| - |
205 |
| - return false; |
206 |
| - } |
207 | 175 | }
|
0 commit comments