From d1d44e745d6b8468db46e17034f40bf877ce8b06 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Fri, 6 Nov 2020 22:49:30 +0100 Subject: [PATCH 1/8] Require slevomat/coding-standard --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b6817e0..b9f65d0 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "issues": "https://github.com/djoos/Symfony-coding-standard/issues" }, "require": { - "squizlabs/php_codesniffer": "^3.3.1" + "squizlabs/php_codesniffer": "^3.3.1", + "slevomat/coding-standard": "^7.0" }, "require-dev": { "phpunit/phpunit": "^5.0 || ^6.0 || ^7.0" From 6e8380fcf25c74b5124482f795a9e03133f0b20c Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Fri, 6 Nov 2020 22:50:08 +0100 Subject: [PATCH 2/8] Remove support for PHP <7.2 --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 493c273..db1ec3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: php php: - - 5.6 # security support until 31/12/2018 - - 7.0 # security support until 03/12/2018 - - 7.1 # security support until 01/12/2019 - 7.2 # security support until 30/11/2020 - 7.3 # security support until 06/12/2021 - 7.4 # security support until 28/11/2022 From 34faa2f6bd4359c29b6b65444995ed37ccd652a9 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Sat, 7 Nov 2020 00:51:01 +0100 Subject: [PATCH 3/8] Use PHP 7.2+ code --- Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php | 8 +++++--- Symfony/Sniffs/Classes/PropertyDeclarationSniff.php | 5 +---- Symfony/Sniffs/Commenting/AnnotationsSniff.php | 2 +- Symfony/Sniffs/Functions/ScopeOrderSniff.php | 6 +----- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php b/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php index df8ecd2..e2be14a 100644 --- a/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php +++ b/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php @@ -96,9 +96,11 @@ public function process(File $phpcsFile, $stackPtr) while ($lastCommaPtr < $closePtr -1) { $lastCommaPtr++; - if ($tokens[$lastCommaPtr]['code'] !== T_WHITESPACE - && $tokens[$lastCommaPtr]['code'] !== T_PHPCS_IGNORE - && $tokens[$lastCommaPtr]['code'] !== T_COMMENT + if (!in_array( + $tokens[$lastCommaPtr]['code'], + [T_WHITESPACE, T_PHPCS_IGNORE, T_COMMENT], + true + ) ) { $fix = $phpcsFile->addFixableError( 'Add a comma after each item in a multi-line array', diff --git a/Symfony/Sniffs/Classes/PropertyDeclarationSniff.php b/Symfony/Sniffs/Classes/PropertyDeclarationSniff.php index 1dd0d8b..8b09667 100644 --- a/Symfony/Sniffs/Classes/PropertyDeclarationSniff.php +++ b/Symfony/Sniffs/Classes/PropertyDeclarationSniff.php @@ -68,10 +68,7 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $end = null; - if (isset($tokens[$stackPtr]['scope_closer'])) { - $end = $tokens[$stackPtr]['scope_closer']; - } + $end = $tokens[$stackPtr]['scope_closer'] ?? null; $scope = $phpcsFile->findNext( T_FUNCTION, diff --git a/Symfony/Sniffs/Commenting/AnnotationsSniff.php b/Symfony/Sniffs/Commenting/AnnotationsSniff.php index ca0203a..1b1558b 100644 --- a/Symfony/Sniffs/Commenting/AnnotationsSniff.php +++ b/Symfony/Sniffs/Commenting/AnnotationsSniff.php @@ -28,7 +28,7 @@ */ class AnnotationsSniff implements Sniff { - const PATTERN = '/^@([^\\\(]+).*$/i'; + private const PATTERN = '/^@([^\\\(]+).*$/i'; /** * Registers the tokens that this sniff wants to listen for. diff --git a/Symfony/Sniffs/Functions/ScopeOrderSniff.php b/Symfony/Sniffs/Functions/ScopeOrderSniff.php index 15346e7..15c92aa 100644 --- a/Symfony/Sniffs/Functions/ScopeOrderSniff.php +++ b/Symfony/Sniffs/Functions/ScopeOrderSniff.php @@ -83,11 +83,7 @@ public function process(File $phpcsFile, $stackPtr) ); while ($function) { - $end = null; - - if (isset($tokens[$stackPtr]['scope_closer'])) { - $end = $tokens[$stackPtr]['scope_closer']; - } + $end = $tokens[$stackPtr]['scope_closer'] ?? null; $function = $phpcsFile->findNext( array( From ed987d484dc534a538cf73edae6c475f366af10a Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Fri, 6 Nov 2020 23:52:31 +0100 Subject: [PATCH 4/8] Use Slevomat.Classes.DisallowMultiPropertyDefinition --- Symfony/ruleset.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Symfony/ruleset.xml b/Symfony/ruleset.xml index 4ef6dc5..05e9885 100755 --- a/Symfony/ruleset.xml +++ b/Symfony/ruleset.xml @@ -10,9 +10,13 @@ - + + + + + + From 3dec7d9cb791b801c3a0bb9074b48026d35689ea Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Sat, 7 Nov 2020 00:10:54 +0100 Subject: [PATCH 5/8] Use Slevomat.Operators.DisallowEqualOperators instead of IdenticalComparison --- .../IdenticalComparisonSniff.php | 66 ------------------- .../IdenticalComparisonUnitTest.inc | 9 --- .../IdenticalComparisonUnitTest.php | 63 ------------------ Symfony/ruleset.xml | 2 + 4 files changed, 2 insertions(+), 138 deletions(-) delete mode 100644 Symfony/Sniffs/ControlStructure/IdenticalComparisonSniff.php delete mode 100644 Symfony/Tests/ControlStructure/IdenticalComparisonUnitTest.inc delete mode 100644 Symfony/Tests/ControlStructure/IdenticalComparisonUnitTest.php diff --git a/Symfony/Sniffs/ControlStructure/IdenticalComparisonSniff.php b/Symfony/Sniffs/ControlStructure/IdenticalComparisonSniff.php deleted file mode 100644 index 266b028..0000000 --- a/Symfony/Sniffs/ControlStructure/IdenticalComparisonSniff.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony-coding-standard - */ - -namespace Symfony\Sniffs\ControlStructure; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\Sniff; - -/** - * Checks for identical comparison and adds warning if not used. - * - * @category PHP - * @package Symfony-coding-standard - * @author wicliff wolda - * @license http://spdx.org/licenses/MIT MIT License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class IdenticalComparisonSniff implements Sniff -{ - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_IS_EQUAL, - T_IS_NOT_EQUAL, - ); - } - - /** - * Called when one of the token types that this sniff is listening for - * is found. - * - * @param File $phpcsFile The file where the token was found. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void|int Optionally returns a stack pointer. The sniff will not be - * called again on the current file until the returned stack - * pointer is reached. Return (count($tokens) + 1) to skip - * the rest of the file. - */ - public function process(File $phpcsFile, $stackPtr) - { - $phpcsFile->addWarning( - 'Always use identical comparison unless you need type juggling', - $stackPtr, - 'Warning' - ); - } - -} diff --git a/Symfony/Tests/ControlStructure/IdenticalComparisonUnitTest.inc b/Symfony/Tests/ControlStructure/IdenticalComparisonUnitTest.inc deleted file mode 100644 index 8736537..0000000 --- a/Symfony/Tests/ControlStructure/IdenticalComparisonUnitTest.inc +++ /dev/null @@ -1,9 +0,0 @@ - - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony2-coding-standard - */ - -namespace Symfony\Tests\ControlStructure; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the IdenticalComparisonUnitTest sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * PHP version 5 - * - * @category PHP - * @package Symfony-coding-standard - * @author wicliff - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony2-coding-standard - */ -class IdenticalComparisonUnitTest extends AbstractSniffUnitTest -{ - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return array(); - } - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return array( - 3 => 1, - 7 => 1, - ); - } -} diff --git a/Symfony/ruleset.xml b/Symfony/ruleset.xml index 05e9885..0d08244 100755 --- a/Symfony/ruleset.xml +++ b/Symfony/ruleset.xml @@ -112,4 +112,6 @@ There should always be a description, followed by a blank line, before the tags of a class comment. + + From a0e64ddf874338c6ebf230a58f9d2c116e2b9a7a Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Sat, 7 Nov 2020 00:18:54 +0100 Subject: [PATCH 6/8] Use Slevomat.ControlStructures.RequireYodaComparison instead of YodaConditions --- .../ControlStructure/YodaConditionsSniff.php | 97 ------------------- .../YodaConditionsUnitTest.inc | 9 -- .../YodaConditionsUnitTest.php | 63 ------------ Symfony/ruleset.xml | 1 + 4 files changed, 1 insertion(+), 169 deletions(-) delete mode 100644 Symfony/Sniffs/ControlStructure/YodaConditionsSniff.php delete mode 100644 Symfony/Tests/ControlStructure/YodaConditionsUnitTest.inc delete mode 100644 Symfony/Tests/ControlStructure/YodaConditionsUnitTest.php diff --git a/Symfony/Sniffs/ControlStructure/YodaConditionsSniff.php b/Symfony/Sniffs/ControlStructure/YodaConditionsSniff.php deleted file mode 100644 index 0a681b2..0000000 --- a/Symfony/Sniffs/ControlStructure/YodaConditionsSniff.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony-coding-standard - */ - -namespace Symfony\Sniffs\ControlStructure; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\Sniff; - -/** - * Checks whether variables are properly compared to expressions. - * - * @category PHP - * @package Symfony-coding-standard - * @author wicliff wolda - * @license http://spdx.org/licenses/MIT MIT License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class YodaConditionsSniff implements Sniff -{ - /** - * Tokens to require Yoda style for - * - * @var array - */ - private $_yodas = array( - T_IS_EQUAL, - T_IS_IDENTICAL, - T_IS_NOT_EQUAL, - T_IS_NOT_IDENTICAL, - ); - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_IF, - T_ELSEIF, - ); - } - - /** - * Called when one of the token types that this sniff is listening for - * is found. - * - * @param File $phpcsFile The file where the token was found. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void|int Optionally returns a stack pointer. The sniff will not be - * called again on the current file until the returned stack - * pointer is reached. Return (count($tokens) + 1) to skip - * the rest of the file. - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $opener = $tokens[$stackPtr]['parenthesis_opener']; - $closer = $tokens[$stackPtr]['parenthesis_closer']; - - do { - $comparison = $phpcsFile->findNext($this->_yodas, $opener + 1, $closer); - - if (false === $comparison) { - break; - } - - if (T_VARIABLE === $tokens[$comparison - 2]['code'] - && T_VARIABLE !== $tokens[$comparison + 2]['code'] - ) { - $error = 'Use Yoda conditions when checking a variable against '; - $error .= 'an expression to avoid an accidental assignment '; - $error .= 'inside the condition statement.'; - - $phpcsFile->addError($error, $stackPtr, 'Invalid'); - } - - $opener = $comparison + 1; - - } while ($opener < $closer); - } - -} diff --git a/Symfony/Tests/ControlStructure/YodaConditionsUnitTest.inc b/Symfony/Tests/ControlStructure/YodaConditionsUnitTest.inc deleted file mode 100644 index 067c371..0000000 --- a/Symfony/Tests/ControlStructure/YodaConditionsUnitTest.inc +++ /dev/null @@ -1,9 +0,0 @@ - - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony2-coding-standard - */ - -namespace Symfony\Tests\ControlStructure; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the YodaConditionsUnitTest sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * PHP version 5 - * - * @category PHP - * @package Symfony-coding-standard - * @author wicliff - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony2-coding-standard - */ -class YodaConditionsUnitTest extends AbstractSniffUnitTest -{ - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return array( - 3 => 1, - 7 => 1, - ); - } - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return array(); - } -} diff --git a/Symfony/ruleset.xml b/Symfony/ruleset.xml index 0d08244..979beff 100755 --- a/Symfony/ruleset.xml +++ b/Symfony/ruleset.xml @@ -114,4 +114,5 @@ + From 1607454dfcd52a4e92c39695a9a590ad02d70bcd Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Sat, 7 Nov 2020 00:40:24 +0100 Subject: [PATCH 7/8] Use Slevomat.Classes.RequireSingleLineMethodSignature instead of Arguments --- Symfony/Sniffs/Functions/ArgumentsSniff.php | 77 ------------------- Symfony/Tests/Functions/ArgumentsUnitTest.inc | 12 --- Symfony/Tests/Functions/ArgumentsUnitTest.php | 62 --------------- Symfony/ruleset.xml | 5 ++ 4 files changed, 5 insertions(+), 151 deletions(-) delete mode 100644 Symfony/Sniffs/Functions/ArgumentsSniff.php delete mode 100644 Symfony/Tests/Functions/ArgumentsUnitTest.inc delete mode 100644 Symfony/Tests/Functions/ArgumentsUnitTest.php diff --git a/Symfony/Sniffs/Functions/ArgumentsSniff.php b/Symfony/Sniffs/Functions/ArgumentsSniff.php deleted file mode 100644 index e7009aa..0000000 --- a/Symfony/Sniffs/Functions/ArgumentsSniff.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony-coding-standard - */ - -namespace Symfony\Sniffs\Functions; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\Sniff; - -/** - * Checks whether functions are defined on one line. - * - * @category PHP - * @package Symfony-coding-standard - * @author wicliff wolda - * @license http://spdx.org/licenses/MIT MIT License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class ArgumentsSniff implements Sniff -{ - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_FUNCTION, - ); - } - - /** - * Called when one of the token types that this sniff is listening for - * is found. - * - * @param File $phpcsFile The file where the token was found. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void|int Optionally returns a stack pointer. The sniff will not be - * called again on the current file until the returned stack - * pointer is reached. Return (count($tokens) + 1) to skip - * the rest of the file. - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $function = $tokens[$stackPtr]; - - $openerLine = $tokens[$function['parenthesis_opener']]['line']; - $closerLine = $tokens[$function['parenthesis_closer']]['line']; - - if ($openerLine !== $closerLine) { - $error = 'Declare all the arguments on the same line '; - $error .= 'as the method/function name, '; - $error .= 'no matter how many arguments there are.'; - - $phpcsFile->addError( - $error, - $stackPtr, - 'Invalid' - ); - } - } - -} diff --git a/Symfony/Tests/Functions/ArgumentsUnitTest.inc b/Symfony/Tests/Functions/ArgumentsUnitTest.inc deleted file mode 100644 index 34f8a44..0000000 --- a/Symfony/Tests/Functions/ArgumentsUnitTest.inc +++ /dev/null @@ -1,12 +0,0 @@ - - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony2-coding-standard - */ - -namespace Symfony\Tests\Functions; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ArgumentsUnitTest sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * PHP version 5 - * - * @category PHP - * @package Symfony-coding-standard - * @author wicliff - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony2-coding-standard - */ -class ArgumentsUnitTest extends AbstractSniffUnitTest -{ - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return array( - 3 => 1, - ); - } - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return array(); - } -} diff --git a/Symfony/ruleset.xml b/Symfony/ruleset.xml index 979beff..ef93bc2 100755 --- a/Symfony/ruleset.xml +++ b/Symfony/ruleset.xml @@ -115,4 +115,9 @@ + + + + + From 983c2717e58cd7a42e8dc70d1378790f43bd4eb6 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Sun, 8 Nov 2020 23:50:57 +0100 Subject: [PATCH 8/8] Use Slevomat sniffs instead of TypeHinting --- .../Sniffs/Commenting/TypeHintingSniff.php | 138 ------------------ .../Tests/Commenting/TypeHintingUnitTest.inc | 30 ---- .../Commenting/TypeHintingUnitTest.inc.fixed | 30 ---- .../Tests/Commenting/TypeHintingUnitTest.php | 65 --------- Symfony/ruleset.xml | 2 + 5 files changed, 2 insertions(+), 263 deletions(-) delete mode 100644 Symfony/Sniffs/Commenting/TypeHintingSniff.php delete mode 100644 Symfony/Tests/Commenting/TypeHintingUnitTest.inc delete mode 100644 Symfony/Tests/Commenting/TypeHintingUnitTest.inc.fixed delete mode 100644 Symfony/Tests/Commenting/TypeHintingUnitTest.php diff --git a/Symfony/Sniffs/Commenting/TypeHintingSniff.php b/Symfony/Sniffs/Commenting/TypeHintingSniff.php deleted file mode 100644 index 28709d9..0000000 --- a/Symfony/Sniffs/Commenting/TypeHintingSniff.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony-coding-standard - */ - -namespace Symfony\Sniffs\Commenting; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\Sniff; - -/** - * Checks for proper type hinting. - * - * @category PHP - * @package Symfony-coding-standard - * @author wicliff wolda - * @license http://spdx.org/licenses/MIT MIT License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class TypeHintingSniff implements Sniff -{ - /** - * Blacklisted types - * - * @var array - */ - private static $_blacklist = [ - 'boolean' => 'bool', - 'integer' => 'int', - 'double' => 'float', - 'real' => 'float', - ]; - - /** - * Cast tokens - * - * @var array - */ - private static $_casts = [ - T_BOOL_CAST, - T_INT_CAST, - T_DOUBLE_CAST, - ]; - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array - */ - public function register() - { - return [ - T_DOC_COMMENT_TAG, - T_BOOL_CAST, - T_INT_CAST, - T_DOUBLE_CAST, - ]; - } - - /** - * Called when one of the token types that this sniff is listening for - * is found. - * - * @param File $phpcsFile The file where the token was found. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void|int Optionally returns a stack pointer. The sniff will not be - * called again on the current file until the returned stack - * pointer is reached. Return (count($tokens) + 1) to skip - * the rest of the file. - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $tag = $tokens[$stackPtr]; - - $fixPtr = $stackPtr; - - if ('@var' === $tag['content']) { - $type = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $stackPtr + 1); - $fixPtr = $type; - $hint = strtolower( - preg_replace( - '/([^\s]+)[\s]+.*/', - '$1', - $tokens[$type]['content'] - ) - ); - } elseif (in_array($tag['code'], self::$_casts, true)) { - $hint = strtolower( - preg_replace( - '/\(([^\s]+)\)/', - '$1', - $tag['content'] - ) - ); - } - - if (isset($hint, self::$_blacklist[$hint])) { - $error = sprintf( - 'For type-hinting in PHPDocs and casting, use %s instead of %s', - self::$_blacklist[$hint], - $hint - ); - - $fixable = $phpcsFile->addFixableError($error, $stackPtr, 'Invalid'); - - if (true === $fixable) { - - if ($fixPtr === $stackPtr) { - $fixedContent = self::$_blacklist[$hint]; - $fixedContent = "({$fixedContent})"; - } else { - $fixedContent = $tokens[$fixPtr]['content']; - $fixedContent = preg_replace( - "/^$hint/", - self::$_blacklist[$hint], - $fixedContent - ); - } - - $phpcsFile->fixer->beginChangeset(); - $phpcsFile->fixer->replaceToken($fixPtr, $fixedContent); - $phpcsFile->fixer->endChangeset(); - } - } - } -} diff --git a/Symfony/Tests/Commenting/TypeHintingUnitTest.inc b/Symfony/Tests/Commenting/TypeHintingUnitTest.inc deleted file mode 100644 index 5bcbca1..0000000 --- a/Symfony/Tests/Commenting/TypeHintingUnitTest.inc +++ /dev/null @@ -1,30 +0,0 @@ - - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony2-coding-standard - */ - -namespace Symfony\Tests\Commenting; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the TypeHintingUnitTest sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * PHP version 5 - * - * @category PHP - * @package Symfony2-coding-standard - * @author wicliff - * @license http://spdx.org/licenses/MIT MIT License - * @link https://github.com/djoos/Symfony2-coding-standard - */ -class TypeHintingUnitTest extends AbstractSniffUnitTest -{ - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return array( - 6 => 1, - 11 => 1, - 22 => 1, - 23 => 1, - ); - } - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return array(); - } -} diff --git a/Symfony/ruleset.xml b/Symfony/ruleset.xml index ef93bc2..8833208 100755 --- a/Symfony/ruleset.xml +++ b/Symfony/ruleset.xml @@ -113,6 +113,8 @@ There should always be a description, followed by a blank line, before the tags of a class comment. + +