Skip to content

Commit a3c33c9

Browse files
authored
Merge pull request #109 from Automattic/ignore-locate-template-in-include-sniff
Ignore `locate_template` in IncludingFile sniff
2 parents 58f15af + c6a957f commit a3c33c9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

WordPressVIPMinimum/Sniffs/Files/IncludingFileSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ class IncludingFileSniff implements \PHP_CodeSniffer_Sniff {
2525
*
2626
* @var array
2727
*/
28-
public $getPathFuncitons = array(
28+
public $getPathFunctions = array(
2929
'plugin_dir_path',
3030
'dirname',
3131
'get_stylesheet_directory',
3232
'get_template_directory',
33+
'locate_template',
3334
);
3435

3536
/**
@@ -106,7 +107,7 @@ public function process( File $phpcsFile, $stackPtr ) {
106107

107108
if ( T_STRING === $tokens[ $nextToken ]['code'] ) {
108109

109-
if ( true === in_array( $tokens[ $nextToken ]['content'], $this->getPathFuncitons, true ) ) {
110+
if ( true === in_array( $tokens[ $nextToken ]['content'], $this->getPathFunctions, true ) ) {
110111
// The construct is using one of the function for getting correct path which is fine.
111112
return;
112113
}

WordPressVIPMinimum/Tests/Files/IncludingFileUnitTest.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ include( __DIR__ . "/my_file.php" ); // OK.
88

99
include ( MY_CONSTANT . "my_file.php" ); // Warning.
1010

11-
require_once ( MY_CONSTANT . "my_file.php" ); // Warning.
11+
require_once ( MY_CONSTANT . "my_file.php" ); // Warning.
12+
13+
include( locate_template('index-loop.php') ); // Ok.

0 commit comments

Comments
 (0)