Skip to content

Commit

Permalink
Merge pull request #79 from Automattic/fix-78/properly-reference-phpc…
Browse files Browse the repository at this point in the history
…sFile

Fix 78/properly reference phpcs file
  • Loading branch information
david-binda authored Aug 14, 2017
2 parents 19c6afe + e974feb commit b5bba7a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function scopeKey($currScope) {

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

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

function filter_non_whitespace_tokens($argumentPtr) {
$tokens = $phpcsFile->getTokens();
$tokens = $this->currentFile->getTokens();
return $tokens[$argumentPtr]['code'] !== T_WHITESPACE;
}
}//end class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function foo() {
$a = 'Hello';
$c = compact( $a, $b );
}
36 changes: 36 additions & 0 deletions WordPressVIPMinimum/Tests/Variables/VariableAnalysisUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Unit test class for WordPressVIPMinimum Coding Standard.
*
* @package VIPCS\WordPressVIPMinimum
*/

/**
* Unit test class for the Variable Analysis sniff.
*
* @package VIPCS\WordPressVIPMinimum
*/
class WordPressVIPMinimum_Tests_Variables_VariableAnalysisUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
*
* @return array <int line number> => <int number of errors>
*/
public function getErrorList() {
return array();
}

/**
* Returns the lines where warnings should occur.
*
* @return array <int line number> => <int number of warnings>
*/
public function getWarningList() {
return array(
5 => 2,
);

}

} // End class.

0 comments on commit b5bba7a

Please sign in to comment.