From fc8466be42c3898b507058c8772b307a218debdd Mon Sep 17 00:00:00 2001 From: Malvika Chauhan Date: Tue, 27 Feb 2018 21:44:45 +0100 Subject: [PATCH] PHPCS + PHPUNIT fixes --- .../SwitchDeclarationSniff.php | 9 +++++--- .../Naming/AlternativeFunctionSniff.php | 4 ++-- .../Sniffs/Naming/ConstantNameSniff.php | 4 ++-- .../Sniffs/Syntax/DocBlockTypesSniff.php | 5 ++++- .../Sniffs/Waste/NonExecutableCodeSniff.php | 4 ++-- .../PhpUnitStaticallyCalledMethodsSniff.php | 6 ++--- .../Sniffs/Syntax/DocBlockTypesSniffTest.php | 16 +++++++------- .../DocBlockTypes/InvalidDocBlocks.php | 22 +++++++++---------- .../Fixtures/DocBlockTypes/LegalDocBlocks.php | 12 +++++----- 9 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/InterNations/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/InterNations/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 7f1572c..471baba 100644 --- a/src/InterNations/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/InterNations/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -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 @@ -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 diff --git a/src/InterNations/Sniffs/Naming/AlternativeFunctionSniff.php b/src/InterNations/Sniffs/Naming/AlternativeFunctionSniff.php index 5870b67..4c1b5da 100644 --- a/src/InterNations/Sniffs/Naming/AlternativeFunctionSniff.php +++ b/src/InterNations/Sniffs/Naming/AlternativeFunctionSniff.php @@ -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) { diff --git a/src/InterNations/Sniffs/Naming/ConstantNameSniff.php b/src/InterNations/Sniffs/Naming/ConstantNameSniff.php index a0b9a88..7be283d 100644 --- a/src/InterNations/Sniffs/Naming/ConstantNameSniff.php +++ b/src/InterNations/Sniffs/Naming/ConstantNameSniff.php @@ -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) diff --git a/src/InterNations/Sniffs/Syntax/DocBlockTypesSniff.php b/src/InterNations/Sniffs/Syntax/DocBlockTypesSniff.php index fffb935..79f960d 100644 --- a/src/InterNations/Sniffs/Syntax/DocBlockTypesSniff.php +++ b/src/InterNations/Sniffs/Syntax/DocBlockTypesSniff.php @@ -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(); } } diff --git a/src/InterNations/Sniffs/Waste/NonExecutableCodeSniff.php b/src/InterNations/Sniffs/Waste/NonExecutableCodeSniff.php index 670a19d..4a615fd 100644 --- a/src/InterNations/Sniffs/Waste/NonExecutableCodeSniff.php +++ b/src/InterNations/Sniffs/Waste/NonExecutableCodeSniff.php @@ -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 */ diff --git a/src/InterNations/Sniffs/Waste/PhpUnitStaticallyCalledMethodsSniff.php b/src/InterNations/Sniffs/Waste/PhpUnitStaticallyCalledMethodsSniff.php index 7972703..7ecdb32 100644 --- a/src/InterNations/Sniffs/Waste/PhpUnitStaticallyCalledMethodsSniff.php +++ b/src/InterNations/Sniffs/Waste/PhpUnitStaticallyCalledMethodsSniff.php @@ -36,7 +36,7 @@ public function register(): array } /** - * @param integer $stackPtr + * @param int $stackPtr */ public function process(File $file, $stackPtr): void { @@ -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 @@ -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 { diff --git a/src/InterNations/Tests/Sniffs/Syntax/DocBlockTypesSniffTest.php b/src/InterNations/Tests/Sniffs/Syntax/DocBlockTypesSniffTest.php index ba08445..dad1a34 100644 --- a/src/InterNations/Tests/Sniffs/Syntax/DocBlockTypesSniffTest.php +++ b/src/InterNations/Tests/Sniffs/Syntax/DocBlockTypesSniffTest.php @@ -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, @@ -31,7 +31,7 @@ public function testInvalidDocBlocks(): void $errors, $file, 'errors', - 'Found "@var bool", expected "@var boolean"', + 'Found "@var boolean", expected "@var bool"', 'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes', 5 ); @@ -39,7 +39,7 @@ public function testInvalidDocBlocks(): void $errors, $file, 'errors', - 'Found "@var int", expected "@var integer"', + 'Found "@var integer", expected "@var int"', 'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes', 5 ); @@ -140,7 +140,7 @@ public function testInvalidDocBlocks(): void $errors, $file, 'errors', - 'Found "@param bool", expected "@param boolean"', + 'Found "@param boolean", expected "@param bool"', 'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes', 5 ); @@ -148,7 +148,7 @@ public function testInvalidDocBlocks(): void $errors, $file, 'errors', - 'Found "@return bool", expected "@return boolean"', + 'Found "@return boolean", expected "@return bool"', 'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes', 5 ); @@ -157,7 +157,7 @@ public function testInvalidDocBlocks(): void $errors, $file, 'errors', - 'Found "@param int", expected "@param integer"', + 'Found "@param integer", expected "@param int"', 'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes', 5 ); @@ -165,7 +165,7 @@ public function testInvalidDocBlocks(): void $errors, $file, 'errors', - 'Found "@return int", expected "@return integer"', + 'Found "@return integer", expected "@return int"', 'InterNations.Syntax.DocBlockTypes.ShortDocCommentTypes', 5 ); @@ -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 ); diff --git a/src/InterNations/Tests/Sniffs/Syntax/Fixtures/DocBlockTypes/InvalidDocBlocks.php b/src/InterNations/Tests/Sniffs/Syntax/Fixtures/DocBlockTypes/InvalidDocBlocks.php index a7d5bee..31b5598 100644 --- a/src/InterNations/Tests/Sniffs/Syntax/Fixtures/DocBlockTypes/InvalidDocBlocks.php +++ b/src/InterNations/Tests/Sniffs/Syntax/Fixtures/DocBlockTypes/InvalidDocBlocks.php @@ -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 @@ -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) { } @@ -106,7 +106,7 @@ public function thisMethod(self $var) } /** - * @param int|null + * @param integer|null * @return void|integer */ public function combinedParam($var) diff --git a/src/InterNations/Tests/Sniffs/Syntax/Fixtures/DocBlockTypes/LegalDocBlocks.php b/src/InterNations/Tests/Sniffs/Syntax/Fixtures/DocBlockTypes/LegalDocBlocks.php index ce43d10..af695dd 100644 --- a/src/InterNations/Tests/Sniffs/Syntax/Fixtures/DocBlockTypes/LegalDocBlocks.php +++ b/src/InterNations/Tests/Sniffs/Syntax/Fixtures/DocBlockTypes/LegalDocBlocks.php @@ -17,9 +17,9 @@ class LegalDocBlocks private $array; /** - * @var boolean + * @var bool */ - private $boolean; + private $bool; /** * @var self @@ -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) { } @@ -75,7 +75,7 @@ public function self(self $var) } /** - * @param string|integer $var + * @param string|int $var * @return LegalDocBlocks|null */ public function multipleTypeMethods($var)