Skip to content

Commit

Permalink
PHPCS + PHPUNIT fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CMalvika committed Feb 27, 2018
1 parent b52b5f8 commit fc8466b
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function register()
/**
* Processes this test, when one of its tokens is encountered.
*
* @param File $file The file being scanned.
* @param integer $stackPtr The position of the current token in the
* @param File$file The file being scanned.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
*
* @return null
Expand Down Expand Up @@ -251,7 +251,10 @@ public function process(File $file, $stackPtr)
}
}//end if
}//end if
} elseif ($type === 'Default' && $tokens[$nextBreak]['type'] !== 'T_THROW' && $tokens[$nextBreak]['type'] !== 'T_RETURN') {
} elseif ($type === 'Default' &&
$tokens[$nextBreak]['type'] !== 'T_THROW' &&
$tokens[$nextBreak]['type'] !== 'T_RETURN'
) {
$error = 'DEFAULT case must have a breaking statement';
$file->addError($error, $nextCase, 'DefaultNoBreak');
}//end if
Expand Down
4 changes: 2 additions & 2 deletions src/InterNations/Sniffs/Naming/AlternativeFunctionSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function register()
}

/**
* @param File $file
* @param integer $stackPtr
* @param File $file
* @param int $stackPtr
*/
public function process(File $file, $stackPtr)
{
Expand Down
4 changes: 2 additions & 2 deletions src/InterNations/Sniffs/Naming/ConstantNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function register()
/**
* Processes this test, when one of its tokens is encountered.
*
* @param File $file The file being scanned.
* @param integer $stackPtr The position of the current token in the stack passed in $tokens.
* @param File $file The file being scanned.
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
* @return null
*/
public function process(File $file, $stackPtr)
Expand Down
5 changes: 4 additions & 1 deletion src/InterNations/Sniffs/Syntax/DocBlockTypesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public function process(File $file, $stackPtr)
$commentStrPtr = $file->findNext([T_WHITESPACE, T_DOC_COMMENT_WHITESPACE], ($stackPtr + 1), null, true);

$file->fixer->beginChangeset();
$file->fixer->replaceToken($commentStrPtr, str_replace($type, static::$typeMap[$type], $tokens[$commentStrPtr]['content']));
$file->fixer->replaceToken(
$commentStrPtr,
str_replace($type, static::$typeMap[$type], $tokens[$commentStrPtr]['content'])
);
$file->fixer->endChangeset();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/InterNations/Sniffs/Waste/NonExecutableCodeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function register()
/**
* Processes this test, when one of its tokens is encountered.
*
* @param File $phpcsFile The file being scanned.
* @param integer $stackPtr The position of the current token in the stack passed in $tokens.
* @param File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
*
* @return null
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function register(): array
}

/**
* @param integer $stackPtr
* @param int $stackPtr
*/
public function process(File $file, $stackPtr): void
{
Expand Down Expand Up @@ -81,7 +81,7 @@ public function process(File $file, $stackPtr): void
}

/**
* @param integer[] $andMethodModifiers
* @param int[] $andMethodModifiers
* @return string[]
*/
private static function findClassMethods(string $className, array $andMethodModifiers): array
Expand All @@ -106,7 +106,7 @@ private static function findClassMethods(string $className, array $andMethodModi
}

/**
* @param integer[] $methodModifiers
* @param int[] $methodModifiers
*/
private static function validateMethodModifiers(array $methodModifiers): void
{
Expand Down
16 changes: 8 additions & 8 deletions src/InterNations/Tests/Sniffs/Syntax/DocBlockTypesSniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function testInvalidDocBlocks(): void
$file = __DIR__ . '/Fixtures/DocBlockTypes/InvalidDocBlocks.php';
$errors = $this->analyze(['InterNations/Sniffs/Syntax/DocBlockTypesSniff'], [$file]);

$this->assertReportCount(26, 0, $errors, $file);
$this->assertReportCount(27, 0, $errors, $file);
$this->assertReportContains(
$errors,
$file,
Expand All @@ -31,15 +31,15 @@ public function testInvalidDocBlocks(): void
$errors,
$file,
'errors',
'Found "@var bool", expected "@var boolean"',
'Found "@var boolean", expected "@var bool"',
'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes',
5
);
$this->assertReportContains(
$errors,
$file,
'errors',
'Found "@var int", expected "@var integer"',
'Found "@var integer", expected "@var int"',
'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes',
5
);
Expand Down Expand Up @@ -140,15 +140,15 @@ public function testInvalidDocBlocks(): void
$errors,
$file,
'errors',
'Found "@param bool", expected "@param boolean"',
'Found "@param boolean", expected "@param bool"',
'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes',
5
);
$this->assertReportContains(
$errors,
$file,
'errors',
'Found "@return bool", expected "@return boolean"',
'Found "@return boolean", expected "@return bool"',
'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes',
5
);
Expand All @@ -157,15 +157,15 @@ public function testInvalidDocBlocks(): void
$errors,
$file,
'errors',
'Found "@param int", expected "@param integer"',
'Found "@param integer", expected "@param int"',
'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes',
5
);
$this->assertReportContains(
$errors,
$file,
'errors',
'Found "@return int", expected "@return integer"',
'Found "@return integer", expected "@return int"',
'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes',
5
);
Expand Down Expand Up @@ -208,7 +208,7 @@ public function testInvalidDocBlocks(): void
$errors,
$file,
'errors',
'Found "@param int|null", expected "@param integer|null"',
'Found "@param integer|null", expected "@param int|null"',
'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes',
5
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class InvalidDocBlocks
private $string;

/**
* @var bool
* @var boolean
*/
private $bool;
private $boolean;

/**
* @var int
* @var integer
*/
private $int;
private $integer;

/**
* @var $this
Expand Down Expand Up @@ -74,18 +74,18 @@ public function realMethod($var)
}

/**
* @param bool $var
* @return bool
* @param boolean $var
* @return boolean
*/
public function boolMethod($var)
public function booleanMethod($var)
{
}

/**
* @param int $var
* @return int
* @param integer $var
* @return integer
*/
public function intMethod($var)
public function integerMethod($var)
{
}

Expand All @@ -106,7 +106,7 @@ public function thisMethod(self $var)
}

/**
* @param int|null
* @param integer|null
* @return void|integer
*/
public function combinedParam($var)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class LegalDocBlocks
private $array;

/**
* @var boolean
* @var bool
*/
private $boolean;
private $bool;

/**
* @var self
Expand Down Expand Up @@ -59,10 +59,10 @@ public function floatMethod($var)
}

/**
* @param boolean $var
* @return boolean
* @param bool $var
* @return bool
*/
public function booleanMethod($var)
public function boolMethod($var)
{
}

Expand All @@ -75,7 +75,7 @@ public function self(self $var)
}

/**
* @param string|integer $var
* @param string|int $var
* @return LegalDocBlocks|null
*/
public function multipleTypeMethods($var)
Expand Down

0 comments on commit fc8466b

Please sign in to comment.