Skip to content

Commit b5bba7a

Browse files
authored
Merge pull request #79 from Automattic/fix-78/properly-reference-phpcsFile
Fix 78/properly reference phpcs file
2 parents 19c6afe + e974feb commit b5bba7a

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

WordPressVIPMinimum/Sniffs/Variables/VariableAnalysisSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ function scopeKey($currScope) {
379379

380380
// Warning: this is an autovivifying get
381381
function getScopeInfo($currScope, $autoCreate = true) {
382-
require_once( __DIR__ . '/VariableAnalysisHelper.php' );
382+
require_once( dirname(__FILE__) . '/VariableAnalysisHelper.php' );
383383
$scopeKey = $this->scopeKey($currScope);
384384
if (!isset($this->_scopes[$scopeKey])) {
385385
if (!$autoCreate) {
@@ -391,7 +391,7 @@ function getScopeInfo($currScope, $autoCreate = true) {
391391
}
392392

393393
function getVariableInfo($varName, $currScope, $autoCreate = true) {
394-
require_once( __DIR__ . '/VariableAnalysisHelper.php' );
394+
require_once( dirname(__FILE__) . '/VariableAnalysisHelper.php' );
395395
$scopeInfo = $this->getScopeInfo($currScope, $autoCreate);
396396
if (!isset($scopeInfo->variables[$varName])) {
397397
if (!$autoCreate) {
@@ -1443,7 +1443,7 @@ protected function processScopeClose(
14431443
}
14441444

14451445
function filter_non_whitespace_tokens($argumentPtr) {
1446-
$tokens = $phpcsFile->getTokens();
1446+
$tokens = $this->currentFile->getTokens();
14471447
return $tokens[$argumentPtr]['code'] !== T_WHITESPACE;
14481448
}
14491449
}//end class
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
function foo() {
4+
$a = 'Hello';
5+
$c = compact( $a, $b );
6+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Unit test class for WordPressVIPMinimum Coding Standard.
4+
*
5+
* @package VIPCS\WordPressVIPMinimum
6+
*/
7+
8+
/**
9+
* Unit test class for the Variable Analysis sniff.
10+
*
11+
* @package VIPCS\WordPressVIPMinimum
12+
*/
13+
class WordPressVIPMinimum_Tests_Variables_VariableAnalysisUnitTest extends AbstractSniffUnitTest {
14+
15+
/**
16+
* Returns the lines where errors should occur.
17+
*
18+
* @return array <int line number> => <int number of errors>
19+
*/
20+
public function getErrorList() {
21+
return array();
22+
}
23+
24+
/**
25+
* Returns the lines where warnings should occur.
26+
*
27+
* @return array <int line number> => <int number of warnings>
28+
*/
29+
public function getWarningList() {
30+
return array(
31+
5 => 2,
32+
);
33+
34+
}
35+
36+
} // End class.

0 commit comments

Comments
 (0)