From 7f0152f73d592c1eb12bc2268827529fb89d3a87 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 25 Dec 2019 17:52:47 +0100 Subject: [PATCH 1/4] :package: Refacto --- .../Sniffs/Arrays/ArrayDeclarationSniff.php | 84 +++++++------------ SymfonyCustom/Sniffs/FixerHelper.php | 31 +++++++ .../Tests/Arrays/ArrayDeclarationUnitTest.inc | 2 + .../Arrays/ArrayDeclarationUnitTest.inc.fixed | 2 + .../Tests/Arrays/ArrayDeclarationUnitTest.php | 1 + 5 files changed, 66 insertions(+), 54 deletions(-) diff --git a/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php b/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php index 9511809..2995c2d 100644 --- a/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -158,56 +158,40 @@ public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $star $nextArrow = $phpcsFile->findNext(T_DOUBLE_ARROW, $start + 1, $end); while (false !== $nextArrow) { if (T_WHITESPACE !== $tokens[$nextArrow - 1]['code']) { + $spaceBefore = 0; + } else { + $spaceBefore = $tokens[$nextArrow - 1]['length']; + } + + if (1 !== $spaceBefore) { $fix = $phpcsFile->addFixableError( - 'Expected 1 space between "%s" and double arrow; 0 found', + 'Expected 1 space between "%s" and double arrow; %s found', $nextArrow, - 'NoSpaceBeforeDoubleArrow', - [$tokens[$nextArrow - 1]['content']] + 'SpaceAfterDoubleArrow', + [$tokens[$nextArrow - 1]['content'], $spaceBefore] ); if ($fix) { - $phpcsFile->fixer->addContentBefore($nextArrow, ' '); - } - } else { - $spaceLength = $tokens[$nextArrow - 1]['length']; - if (1 !== $spaceLength) { - $fix = $phpcsFile->addFixableError( - 'Expected 1 space between "%s" and double arrow; %s found', - $nextArrow, - 'SpaceBeforeDoubleArrow', - [$tokens[$nextArrow - 2]['content'], $spaceLength] - ); - - if ($fix) { - $phpcsFile->fixer->replaceToken($nextArrow - 1, ' '); - } + FixerHelper::fixWhitespaceBefore($phpcsFile, $nextArrow, 1, $spaceBefore); } } if (T_WHITESPACE !== $tokens[$nextArrow + 1]['code']) { + $spaceAfter = 0; + } else { + $spaceAfter = $tokens[$nextArrow + 1]['length']; + } + + if (1 !== $spaceAfter) { $fix = $phpcsFile->addFixableError( - 'Expected 1 space between double arrow and "%s"; 0 found', + 'Expected 1 space between double arrow and "%s"; %s found', $nextArrow, - 'NoSpaceAfterDoubleArrow', - [$tokens[$nextArrow + 1]['content']] + 'SpaceAfterDoubleArrow', + [$tokens[$nextArrow + 1]['content'], $spaceAfter] ); if ($fix) { - $phpcsFile->fixer->addContent($nextArrow, ' '); - } - } else { - $spaceLength = $tokens[$nextArrow + 1]['length']; - if (1 !== $spaceLength) { - $fix = $phpcsFile->addFixableError( - 'Expected 1 space between double arrow and "%s"; %s found', - $nextArrow, - 'SpaceAfterDoubleArrow', - [$tokens[$nextArrow + 2]['content'], $spaceLength] - ); - - if ($fix) { - $phpcsFile->fixer->replaceToken($nextArrow + 1, ' '); - } + FixerHelper::fixWhitespaceAfter($phpcsFile, $nextArrow, 1, $spaceAfter); } } @@ -218,29 +202,21 @@ public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $star // We have a multiple value array foreach ($commas as $comma) { if (T_WHITESPACE !== $tokens[$comma + 1]['code']) { + $spaceAfter = 0; + } else { + $spaceAfter = $tokens[$comma + 1]['length']; + } + + if (1 !== $spaceAfter) { $fix = $phpcsFile->addFixableError( - 'Expected 1 space between comma and "%s"; 0 found', + 'Expected 1 space between comma and "%s"; %s found', $comma, - 'NoSpaceAfterComma', - [$tokens[$comma + 1]['content']] + 'SpaceAfterComma', + [$tokens[$comma + 1]['content'], $spaceAfter] ); if ($fix) { - $phpcsFile->fixer->addContent($comma, ' '); - } - } else { - $spaceLength = $tokens[$comma + 1]['length']; - if (1 !== $spaceLength) { - $fix = $phpcsFile->addFixableError( - 'Expected 1 space between comma and "%s"; %s found', - $comma, - 'SpaceAfterComma', - [$tokens[$comma + 2]['content'], $spaceLength] - ); - - if ($fix) { - $phpcsFile->fixer->replaceToken($comma + 1, ' '); - } + FixerHelper::fixWhitespaceAfter($phpcsFile, $comma, 1, $spaceAfter); } } diff --git a/SymfonyCustom/Sniffs/FixerHelper.php b/SymfonyCustom/Sniffs/FixerHelper.php index ecf8e52..208edac 100644 --- a/SymfonyCustom/Sniffs/FixerHelper.php +++ b/SymfonyCustom/Sniffs/FixerHelper.php @@ -58,6 +58,37 @@ public static function removeLines(File $phpcsFile, int $fromPtr, int $fromLine, $phpcsFile->fixer->endChangeset(); } + /** + * @param File $phpcsFile + * @param int $stackPtr + * @param int $expected + * @param int|string $found + */ + public static function fixWhitespaceAfter( + File $phpcsFile, + int $stackPtr, + int $expected, + $found + ): void { + $phpcsFile->fixer->beginChangeset(); + + if (0 === $found) { + $phpcsFile->fixer->addContent($stackPtr, str_repeat(' ', $expected)); + } else { + if ('newline' === $found) { + $next = $phpcsFile->findNext(T_WHITESPACE, $stackPtr, null, true); + + for ($i = $stackPtr + 1; $i < $next; $i++) { + $phpcsFile->fixer->replaceToken($i, ''); + } + } + + $phpcsFile->fixer->replaceToken($stackPtr + 1, str_repeat(' ', $expected)); + } + + $phpcsFile->fixer->endChangeset(); + } + /** * @param File $phpcsFile * @param int $stackPtr diff --git a/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc b/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc index d7b8338..1452f2e 100644 --- a/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc +++ b/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc @@ -147,3 +147,5 @@ return [ 1 => 2, ]; + +[1 => 2 , 2=>3,4 => 5]; diff --git a/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed b/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed index 3211704..0a7eb73 100644 --- a/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed +++ b/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed @@ -145,3 +145,5 @@ return [ 0 => 1, 1 => 2, ]; + +[1 => 2, 2 => 3, 4 => 5]; diff --git a/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php b/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php index a838008..b12c048 100644 --- a/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php +++ b/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php @@ -53,6 +53,7 @@ protected function getErrorList(): array 107 => 2, 142 => 1, 148 => 1, + 151 => 7, ]; } From 081d20bf8ca5d57cc933f42ff6f38698fb067b4b Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 25 Dec 2019 19:28:46 +0100 Subject: [PATCH 2/4] :package: Refacto Folder --- .../{Sniffs => Helpers}/FixerHelper.php | 2 +- .../{Sniffs => Helpers}/SniffHelper.php | 2 +- .../Sniffs/Arrays/ArrayDeclarationSniff.php | 2 +- .../DocCommentGroupSameTypeSniff.php | 4 +- .../Sniffs/Commenting/DocCommentSniff.php | 2 +- .../AlphabeticallySortedUseSniff.php | 2 +- .../Sniffs/Namespaces/UnusedUseSniff.php | 2 +- .../WhiteSpace/DocCommentTagSpacingSniff.php | 2 +- TwigCS/{ => src}/Command/TwigCSCommand.php | 0 TwigCS/{ => src}/Config/Config.php | 0 .../Environment/StubbedEnvironment.php | 0 TwigCS/{ => src}/Report/Report.php | 0 TwigCS/{ => src}/Report/SniffViolation.php | 0 TwigCS/{ => src}/Report/TextFormatter.php | 0 .../Ruleset/Generic/BlankEOFSniff.php | 0 .../Ruleset/Generic/DelimiterSpacingSniff.php | 0 .../Generic/DisallowCommentedCodeSniff.php | 0 .../Ruleset/Generic/EmptyLinesSniff.php | 0 .../Ruleset/Generic/OperatorSpacingSniff.php | 0 TwigCS/{ => src}/Ruleset/Ruleset.php | 0 TwigCS/{ => src}/Runner/Fixer.php | 0 TwigCS/{ => src}/Runner/Linter.php | 0 TwigCS/{ => src}/Sniff/AbstractSniff.php | 0 .../{ => src}/Sniff/AbstractSpacingSniff.php | 0 TwigCS/{ => src}/Sniff/SniffInterface.php | 0 TwigCS/{ => src}/Token/Token.php | 0 TwigCS/{ => src}/Token/TokenParser.php | 0 TwigCS/{ => src}/Token/Tokenizer.php | 0 TwigCS/{ => src}/Token/TokenizerHelper.php | 0 TwigCS/tests/AbstractSniffTest.php | 82 +++++++++++++++++++ TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig | 2 + TwigCS/tests/Fixtures/BlankEOFTest.twig | 3 + .../Fixtures/DelimiterSpacingTest.fixed.twig | 20 +++++ .../tests/Fixtures/DelimiterSpacingTest.twig | 20 +++++ .../Fixtures/DisallowCommentedCodeTest.twig | 7 ++ .../tests/Fixtures/EmptyLinesTest.fixed.twig | 3 + TwigCS/tests/Fixtures/EmptyLinesTest.twig | 4 + .../Fixtures/OperatorSpacingTest.fixed.twig | 20 +++++ .../tests/Fixtures/OperatorSpacingTest.twig | 20 +++++ TwigCS/tests/Ruleset/Generic/BlankEOFTest.php | 21 +++++ .../Ruleset/Generic/DelimiterSpacingTest.php | 24 ++++++ .../Generic/DisallowCommentedCodeTest.php | 21 +++++ .../tests/Ruleset/Generic/EmptyLinesTest.php | 21 +++++ .../Ruleset/Generic/OperatorSpacingTest.php | 52 ++++++++++++ composer.json | 8 +- composer.lock | 42 +++++----- 46 files changed, 356 insertions(+), 32 deletions(-) rename SymfonyCustom/{Sniffs => Helpers}/FixerHelper.php (98%) rename SymfonyCustom/{Sniffs => Helpers}/SniffHelper.php (98%) rename TwigCS/{ => src}/Command/TwigCSCommand.php (100%) rename TwigCS/{ => src}/Config/Config.php (100%) rename TwigCS/{ => src}/Environment/StubbedEnvironment.php (100%) rename TwigCS/{ => src}/Report/Report.php (100%) rename TwigCS/{ => src}/Report/SniffViolation.php (100%) rename TwigCS/{ => src}/Report/TextFormatter.php (100%) rename TwigCS/{ => src}/Ruleset/Generic/BlankEOFSniff.php (100%) rename TwigCS/{ => src}/Ruleset/Generic/DelimiterSpacingSniff.php (100%) rename TwigCS/{ => src}/Ruleset/Generic/DisallowCommentedCodeSniff.php (100%) rename TwigCS/{ => src}/Ruleset/Generic/EmptyLinesSniff.php (100%) rename TwigCS/{ => src}/Ruleset/Generic/OperatorSpacingSniff.php (100%) rename TwigCS/{ => src}/Ruleset/Ruleset.php (100%) rename TwigCS/{ => src}/Runner/Fixer.php (100%) rename TwigCS/{ => src}/Runner/Linter.php (100%) rename TwigCS/{ => src}/Sniff/AbstractSniff.php (100%) rename TwigCS/{ => src}/Sniff/AbstractSpacingSniff.php (100%) rename TwigCS/{ => src}/Sniff/SniffInterface.php (100%) rename TwigCS/{ => src}/Token/Token.php (100%) rename TwigCS/{ => src}/Token/TokenParser.php (100%) rename TwigCS/{ => src}/Token/Tokenizer.php (100%) rename TwigCS/{ => src}/Token/TokenizerHelper.php (100%) create mode 100644 TwigCS/tests/AbstractSniffTest.php create mode 100644 TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig create mode 100644 TwigCS/tests/Fixtures/BlankEOFTest.twig create mode 100644 TwigCS/tests/Fixtures/DelimiterSpacingTest.fixed.twig create mode 100644 TwigCS/tests/Fixtures/DelimiterSpacingTest.twig create mode 100644 TwigCS/tests/Fixtures/DisallowCommentedCodeTest.twig create mode 100644 TwigCS/tests/Fixtures/EmptyLinesTest.fixed.twig create mode 100644 TwigCS/tests/Fixtures/EmptyLinesTest.twig create mode 100644 TwigCS/tests/Fixtures/OperatorSpacingTest.fixed.twig create mode 100644 TwigCS/tests/Fixtures/OperatorSpacingTest.twig create mode 100644 TwigCS/tests/Ruleset/Generic/BlankEOFTest.php create mode 100644 TwigCS/tests/Ruleset/Generic/DelimiterSpacingTest.php create mode 100644 TwigCS/tests/Ruleset/Generic/DisallowCommentedCodeTest.php create mode 100644 TwigCS/tests/Ruleset/Generic/EmptyLinesTest.php create mode 100644 TwigCS/tests/Ruleset/Generic/OperatorSpacingTest.php diff --git a/SymfonyCustom/Sniffs/FixerHelper.php b/SymfonyCustom/Helpers/FixerHelper.php similarity index 98% rename from SymfonyCustom/Sniffs/FixerHelper.php rename to SymfonyCustom/Helpers/FixerHelper.php index 208edac..5dbbb72 100644 --- a/SymfonyCustom/Sniffs/FixerHelper.php +++ b/SymfonyCustom/Helpers/FixerHelper.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SymfonyCustom\Sniffs; +namespace SymfonyCustom\Helpers; use PHP_CodeSniffer\Files\File; diff --git a/SymfonyCustom/Sniffs/SniffHelper.php b/SymfonyCustom/Helpers/SniffHelper.php similarity index 98% rename from SymfonyCustom/Sniffs/SniffHelper.php rename to SymfonyCustom/Helpers/SniffHelper.php index 55afa59..1b4ef17 100644 --- a/SymfonyCustom/Sniffs/SniffHelper.php +++ b/SymfonyCustom/Helpers/SniffHelper.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SymfonyCustom\Sniffs; +namespace SymfonyCustom\Helpers; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens; diff --git a/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php b/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php index 2995c2d..70d5784 100644 --- a/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -7,7 +7,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; -use SymfonyCustom\Sniffs\FixerHelper; +use SymfonyCustom\Helpers\FixerHelper; /** * A test to ensure that arrays conform to the array coding standard. diff --git a/SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php b/SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php index 4f17d99..d8a84b2 100644 --- a/SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php +++ b/SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php @@ -6,8 +6,8 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; -use SymfonyCustom\Sniffs\FixerHelper; -use SymfonyCustom\Sniffs\SniffHelper; +use SymfonyCustom\Helpers\FixerHelper; +use SymfonyCustom\Helpers\SniffHelper; /** * Throws errors if comments are not grouped by type with one blank line between them. diff --git a/SymfonyCustom/Sniffs/Commenting/DocCommentSniff.php b/SymfonyCustom/Sniffs/Commenting/DocCommentSniff.php index 7fa4ab6..9052067 100644 --- a/SymfonyCustom/Sniffs/Commenting/DocCommentSniff.php +++ b/SymfonyCustom/Sniffs/Commenting/DocCommentSniff.php @@ -6,7 +6,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; -use SymfonyCustom\Sniffs\FixerHelper; +use SymfonyCustom\Helpers\FixerHelper; /** * Ensures doc blocks follow basic formatting. diff --git a/SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php b/SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php index 2db5411..1bf3f95 100644 --- a/SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php +++ b/SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php @@ -7,7 +7,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; -use SymfonyCustom\Sniffs\SniffHelper; +use SymfonyCustom\Helpers\SniffHelper; /** * Class AlphabeticallySortedUseSniff diff --git a/SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php b/SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php index ebd682c..dc5c920 100644 --- a/SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php +++ b/SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php @@ -7,7 +7,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; -use SymfonyCustom\Sniffs\SniffHelper; +use SymfonyCustom\Helpers\SniffHelper; /** * Checks for "use" statements that are not needed in a file. diff --git a/SymfonyCustom/Sniffs/WhiteSpace/DocCommentTagSpacingSniff.php b/SymfonyCustom/Sniffs/WhiteSpace/DocCommentTagSpacingSniff.php index 4c1e9d3..4486f09 100644 --- a/SymfonyCustom/Sniffs/WhiteSpace/DocCommentTagSpacingSniff.php +++ b/SymfonyCustom/Sniffs/WhiteSpace/DocCommentTagSpacingSniff.php @@ -6,7 +6,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; -use SymfonyCustom\Sniffs\SniffHelper; +use SymfonyCustom\Helpers\SniffHelper; /** * Checks that there are not 2 empty lines following each other. diff --git a/TwigCS/Command/TwigCSCommand.php b/TwigCS/src/Command/TwigCSCommand.php similarity index 100% rename from TwigCS/Command/TwigCSCommand.php rename to TwigCS/src/Command/TwigCSCommand.php diff --git a/TwigCS/Config/Config.php b/TwigCS/src/Config/Config.php similarity index 100% rename from TwigCS/Config/Config.php rename to TwigCS/src/Config/Config.php diff --git a/TwigCS/Environment/StubbedEnvironment.php b/TwigCS/src/Environment/StubbedEnvironment.php similarity index 100% rename from TwigCS/Environment/StubbedEnvironment.php rename to TwigCS/src/Environment/StubbedEnvironment.php diff --git a/TwigCS/Report/Report.php b/TwigCS/src/Report/Report.php similarity index 100% rename from TwigCS/Report/Report.php rename to TwigCS/src/Report/Report.php diff --git a/TwigCS/Report/SniffViolation.php b/TwigCS/src/Report/SniffViolation.php similarity index 100% rename from TwigCS/Report/SniffViolation.php rename to TwigCS/src/Report/SniffViolation.php diff --git a/TwigCS/Report/TextFormatter.php b/TwigCS/src/Report/TextFormatter.php similarity index 100% rename from TwigCS/Report/TextFormatter.php rename to TwigCS/src/Report/TextFormatter.php diff --git a/TwigCS/Ruleset/Generic/BlankEOFSniff.php b/TwigCS/src/Ruleset/Generic/BlankEOFSniff.php similarity index 100% rename from TwigCS/Ruleset/Generic/BlankEOFSniff.php rename to TwigCS/src/Ruleset/Generic/BlankEOFSniff.php diff --git a/TwigCS/Ruleset/Generic/DelimiterSpacingSniff.php b/TwigCS/src/Ruleset/Generic/DelimiterSpacingSniff.php similarity index 100% rename from TwigCS/Ruleset/Generic/DelimiterSpacingSniff.php rename to TwigCS/src/Ruleset/Generic/DelimiterSpacingSniff.php diff --git a/TwigCS/Ruleset/Generic/DisallowCommentedCodeSniff.php b/TwigCS/src/Ruleset/Generic/DisallowCommentedCodeSniff.php similarity index 100% rename from TwigCS/Ruleset/Generic/DisallowCommentedCodeSniff.php rename to TwigCS/src/Ruleset/Generic/DisallowCommentedCodeSniff.php diff --git a/TwigCS/Ruleset/Generic/EmptyLinesSniff.php b/TwigCS/src/Ruleset/Generic/EmptyLinesSniff.php similarity index 100% rename from TwigCS/Ruleset/Generic/EmptyLinesSniff.php rename to TwigCS/src/Ruleset/Generic/EmptyLinesSniff.php diff --git a/TwigCS/Ruleset/Generic/OperatorSpacingSniff.php b/TwigCS/src/Ruleset/Generic/OperatorSpacingSniff.php similarity index 100% rename from TwigCS/Ruleset/Generic/OperatorSpacingSniff.php rename to TwigCS/src/Ruleset/Generic/OperatorSpacingSniff.php diff --git a/TwigCS/Ruleset/Ruleset.php b/TwigCS/src/Ruleset/Ruleset.php similarity index 100% rename from TwigCS/Ruleset/Ruleset.php rename to TwigCS/src/Ruleset/Ruleset.php diff --git a/TwigCS/Runner/Fixer.php b/TwigCS/src/Runner/Fixer.php similarity index 100% rename from TwigCS/Runner/Fixer.php rename to TwigCS/src/Runner/Fixer.php diff --git a/TwigCS/Runner/Linter.php b/TwigCS/src/Runner/Linter.php similarity index 100% rename from TwigCS/Runner/Linter.php rename to TwigCS/src/Runner/Linter.php diff --git a/TwigCS/Sniff/AbstractSniff.php b/TwigCS/src/Sniff/AbstractSniff.php similarity index 100% rename from TwigCS/Sniff/AbstractSniff.php rename to TwigCS/src/Sniff/AbstractSniff.php diff --git a/TwigCS/Sniff/AbstractSpacingSniff.php b/TwigCS/src/Sniff/AbstractSpacingSniff.php similarity index 100% rename from TwigCS/Sniff/AbstractSpacingSniff.php rename to TwigCS/src/Sniff/AbstractSpacingSniff.php diff --git a/TwigCS/Sniff/SniffInterface.php b/TwigCS/src/Sniff/SniffInterface.php similarity index 100% rename from TwigCS/Sniff/SniffInterface.php rename to TwigCS/src/Sniff/SniffInterface.php diff --git a/TwigCS/Token/Token.php b/TwigCS/src/Token/Token.php similarity index 100% rename from TwigCS/Token/Token.php rename to TwigCS/src/Token/Token.php diff --git a/TwigCS/Token/TokenParser.php b/TwigCS/src/Token/TokenParser.php similarity index 100% rename from TwigCS/Token/TokenParser.php rename to TwigCS/src/Token/TokenParser.php diff --git a/TwigCS/Token/Tokenizer.php b/TwigCS/src/Token/Tokenizer.php similarity index 100% rename from TwigCS/Token/Tokenizer.php rename to TwigCS/src/Token/Tokenizer.php diff --git a/TwigCS/Token/TokenizerHelper.php b/TwigCS/src/Token/TokenizerHelper.php similarity index 100% rename from TwigCS/Token/TokenizerHelper.php rename to TwigCS/src/Token/TokenizerHelper.php diff --git a/TwigCS/tests/AbstractSniffTest.php b/TwigCS/tests/AbstractSniffTest.php new file mode 100644 index 0000000..80b0ccd --- /dev/null +++ b/TwigCS/tests/AbstractSniffTest.php @@ -0,0 +1,82 @@ +checkGenericSniff(new Sniff(), [...]); + */ + abstract public function testSniff(): void; + + /** + * @param SniffInterface $sniff + * @param array $expects + */ + protected function checkGenericSniff(SniffInterface $sniff, array $expects): void + { + $env = new StubbedEnvironment(); + $tokenizer = new Tokenizer($env); + $linter = new Linter($env, $tokenizer); + $ruleset = new Ruleset(); + + try { + $class = new ReflectionClass(get_called_class()); + $className = $class->getShortName(); + $file = __DIR__.'/Fixtures/'.$className.'.twig'; + + $ruleset->addSniff($sniff); + $report = $linter->run([$file], $ruleset); + } catch (Exception $e) { + $this->fail($e->getMessage()); + + return; + } + + $messages = $report->getMessages(); + $messagePositions = []; + + foreach ($messages as $message) { + if (Report::MESSAGE_TYPE_FATAL === $message->getLevel()) { + $errorMessage = $message->getMessage(); + $line = $message->getLine(); + + if (null !== $line) { + $errorMessage = sprintf('Line %s: %s', $line, $errorMessage); + } + $this->fail($errorMessage); + } + + $messagePositions[] = [$message->getLine() => $message->getLinePosition()]; + } + $this->assertEquals($expects, $messagePositions); + + $fixedFile = __DIR__.'/Fixtures/'.$className.'.fixed.twig'; + if (file_exists($fixedFile)) { + $fixer = new Fixer($ruleset, $tokenizer); + $sniff->enableFixer($fixer); + $fixer->fixFile($file); + + $diff = $fixer->generateDiff($fixedFile); + if ('' !== $diff) { + $this->fail($diff); + } + } + } +} diff --git a/TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig b/TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig new file mode 100644 index 0000000..1936aaf --- /dev/null +++ b/TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig @@ -0,0 +1,2 @@ +
+
diff --git a/TwigCS/tests/Fixtures/BlankEOFTest.twig b/TwigCS/tests/Fixtures/BlankEOFTest.twig new file mode 100644 index 0000000..99dfd42 --- /dev/null +++ b/TwigCS/tests/Fixtures/BlankEOFTest.twig @@ -0,0 +1,3 @@ +
+
+ diff --git a/TwigCS/tests/Fixtures/DelimiterSpacingTest.fixed.twig b/TwigCS/tests/Fixtures/DelimiterSpacingTest.fixed.twig new file mode 100644 index 0000000..692a539 --- /dev/null +++ b/TwigCS/tests/Fixtures/DelimiterSpacingTest.fixed.twig @@ -0,0 +1,20 @@ +{{ foo }} +{# comment #} +{% if foo %}{% endif %} + +{{- foo -}} +{#- comment -#} +{%- if foo -%}{%- endif -%} + +{{ + shouldNotCareAboutNewLine +}} +{%- if foo -%}{%- endif -%} + +{{ foo({'bar': {'baz': 'shouldNotCareAboutDoubleHashes'}}) }} + +
+ {{ + shouldNotCareAboutNewLine + }} +
diff --git a/TwigCS/tests/Fixtures/DelimiterSpacingTest.twig b/TwigCS/tests/Fixtures/DelimiterSpacingTest.twig new file mode 100644 index 0000000..0175972 --- /dev/null +++ b/TwigCS/tests/Fixtures/DelimiterSpacingTest.twig @@ -0,0 +1,20 @@ +{{ foo }} +{# comment #} +{% if foo %}{% endif %} + +{{- foo -}} +{#- comment -#} +{%- if foo -%}{%- endif -%} + +{{ + shouldNotCareAboutNewLine +}} +{%-if foo -%}{%- endif-%} + +{{ foo({'bar': {'baz': 'shouldNotCareAboutDoubleHashes'}}) }} + +
+ {{ + shouldNotCareAboutNewLine + }} +
diff --git a/TwigCS/tests/Fixtures/DisallowCommentedCodeTest.twig b/TwigCS/tests/Fixtures/DisallowCommentedCodeTest.twig new file mode 100644 index 0000000..cc03dae --- /dev/null +++ b/TwigCS/tests/Fixtures/DisallowCommentedCodeTest.twig @@ -0,0 +1,7 @@ +
+ {# {% set var = 'This is a comment' %} #} +
+ +
+ {# 'This is a comment' #} +
diff --git a/TwigCS/tests/Fixtures/EmptyLinesTest.fixed.twig b/TwigCS/tests/Fixtures/EmptyLinesTest.fixed.twig new file mode 100644 index 0000000..70c6156 --- /dev/null +++ b/TwigCS/tests/Fixtures/EmptyLinesTest.fixed.twig @@ -0,0 +1,3 @@ +
+ +
diff --git a/TwigCS/tests/Fixtures/EmptyLinesTest.twig b/TwigCS/tests/Fixtures/EmptyLinesTest.twig new file mode 100644 index 0000000..018bc05 --- /dev/null +++ b/TwigCS/tests/Fixtures/EmptyLinesTest.twig @@ -0,0 +1,4 @@ +
+ + +
diff --git a/TwigCS/tests/Fixtures/OperatorSpacingTest.fixed.twig b/TwigCS/tests/Fixtures/OperatorSpacingTest.fixed.twig new file mode 100644 index 0000000..f76f2e7 --- /dev/null +++ b/TwigCS/tests/Fixtures/OperatorSpacingTest.fixed.twig @@ -0,0 +1,20 @@ +{{ 1 + 2 }} +{{ 1 - 2 }} +{{ 1 / 2 }} +{{ 1 * 2 }} +{{ 1 % 2 }} +{{ 1 // 2 }} +{{ 1 ** 2 }} +{{ foo ~ bar }} +{{ true ? true : false }} +{{ 1 == 2 }} +{{ not true }} +{{ false and true }} +{{ false or true }} +{{ a in array }} +{{ a is array }} + +Untouch +-/*%==: + +{{ [1, 2, 3] }} +{{ {'foo': 'bar'} }} diff --git a/TwigCS/tests/Fixtures/OperatorSpacingTest.twig b/TwigCS/tests/Fixtures/OperatorSpacingTest.twig new file mode 100644 index 0000000..8bb3808 --- /dev/null +++ b/TwigCS/tests/Fixtures/OperatorSpacingTest.twig @@ -0,0 +1,20 @@ +{{ 1+2 }} +{{ 1-2 }} +{{ 1/2 }} +{{ 1*2 }} +{{ 1%2 }} +{{ 1//2 }} +{{ 1**2 }} +{{ foo~bar }} +{{ true ? true : false }} +{{ 1==2 }} +{{ not true }} +{{ false and true }} +{{ false or true }} +{{ a in array }} +{{ a is array }} + +Untouch +-/*%==: + +{{ [1, 2, 3] }} +{{ {'foo': 'bar'} }} diff --git a/TwigCS/tests/Ruleset/Generic/BlankEOFTest.php b/TwigCS/tests/Ruleset/Generic/BlankEOFTest.php new file mode 100644 index 0000000..a6fd61c --- /dev/null +++ b/TwigCS/tests/Ruleset/Generic/BlankEOFTest.php @@ -0,0 +1,21 @@ +checkGenericSniff(new BlankEOFSniff(), [ + [4 => 1], + ]); + } +} diff --git a/TwigCS/tests/Ruleset/Generic/DelimiterSpacingTest.php b/TwigCS/tests/Ruleset/Generic/DelimiterSpacingTest.php new file mode 100644 index 0000000..24b8c54 --- /dev/null +++ b/TwigCS/tests/Ruleset/Generic/DelimiterSpacingTest.php @@ -0,0 +1,24 @@ +checkGenericSniff(new DelimiterSpacingSniff(), [ + [12 => 1], + [12 => 12], + [12 => 15], + [12 => 25], + ]); + } +} diff --git a/TwigCS/tests/Ruleset/Generic/DisallowCommentedCodeTest.php b/TwigCS/tests/Ruleset/Generic/DisallowCommentedCodeTest.php new file mode 100644 index 0000000..f30f55d --- /dev/null +++ b/TwigCS/tests/Ruleset/Generic/DisallowCommentedCodeTest.php @@ -0,0 +1,21 @@ +checkGenericSniff(new DisallowCommentedCodeSniff(), [ + [2 => 5], + ]); + } +} diff --git a/TwigCS/tests/Ruleset/Generic/EmptyLinesTest.php b/TwigCS/tests/Ruleset/Generic/EmptyLinesTest.php new file mode 100644 index 0000000..49d0e8b --- /dev/null +++ b/TwigCS/tests/Ruleset/Generic/EmptyLinesTest.php @@ -0,0 +1,21 @@ +checkGenericSniff(new EmptyLinesSniff(), [ + [3 => 1], + ]); + } +} diff --git a/TwigCS/tests/Ruleset/Generic/OperatorSpacingTest.php b/TwigCS/tests/Ruleset/Generic/OperatorSpacingTest.php new file mode 100644 index 0000000..dc0dc5d --- /dev/null +++ b/TwigCS/tests/Ruleset/Generic/OperatorSpacingTest.php @@ -0,0 +1,52 @@ +checkGenericSniff(new OperatorSpacingSniff(), [ + [1 => 4], + [1 => 4], + [2 => 5], + [2 => 5], + [3 => 5], + [3 => 5], + [4 => 5], + [4 => 5], + [5 => 5], + [5 => 5], + [6 => 5], + [6 => 5], + [7 => 5], + [7 => 5], + [8 => 7], + [8 => 7], + [9 => 10], + [9 => 10], + [9 => 19], + [9 => 19], + [10 => 5], + [10 => 5], + [11 => 6], + [11 => 6], + [12 => 11], + [12 => 11], + [13 => 11], + [13 => 11], + [14 => 7], + [14 => 7], + [15 => 7], + [15 => 7], + ]); + } +} diff --git a/composer.json b/composer.json index cf2cd31..ff16b37 100644 --- a/composer.json +++ b/composer.json @@ -28,9 +28,13 @@ "phpunit/phpunit": "^7.0" }, "autoload": { - "psr-4": { "TwigCS\\": "TwigCS/" } + "psr-4": { + "TwigCS\\": "TwigCS/src/" + } }, "autoload-dev": { - "psr-4": { "TwigCS\\Tests\\": "TwigCS/Tests/" } + "psr-4": { + "TwigCS\\Tests\\": "TwigCS/tests/" + } } } diff --git a/composer.lock b/composer.lock index 389b78b..619a7e0 100644 --- a/composer.lock +++ b/composer.lock @@ -108,16 +108,16 @@ }, { "name": "symfony/console", - "version": "v5.0.1", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "dae5ef273d700771168ab889d9f8a19b2d206656" + "reference": "fe6e3cd889ca64172d7a742a2eb058541404ef47" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/dae5ef273d700771168ab889d9f8a19b2d206656", - "reference": "dae5ef273d700771168ab889d9f8a19b2d206656", + "url": "https://api.github.com/repos/symfony/console/zipball/fe6e3cd889ca64172d7a742a2eb058541404ef47", + "reference": "fe6e3cd889ca64172d7a742a2eb058541404ef47", "shasum": "" }, "require": { @@ -180,11 +180,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-12-01T10:51:15+00:00" + "time": "2019-12-17T13:20:22+00:00" }, { "name": "symfony/finder", - "version": "v5.0.1", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -523,16 +523,16 @@ }, { "name": "symfony/twig-bridge", - "version": "v5.0.1", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/symfony/twig-bridge.git", - "reference": "09b1efdbedcba4953b448d8696333a1626db26d6" + "reference": "abbaeee38ff39651e335c55be40752be2ddd0976" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/09b1efdbedcba4953b448d8696333a1626db26d6", - "reference": "09b1efdbedcba4953b448d8696333a1626db26d6", + "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/abbaeee38ff39651e335c55be40752be2ddd0976", + "reference": "abbaeee38ff39651e335c55be40752be2ddd0976", "shasum": "" }, "require": { @@ -620,7 +620,7 @@ ], "description": "Symfony Twig Bridge", "homepage": "https://symfony.com", - "time": "2019-11-30T14:12:50+00:00" + "time": "2019-12-18T16:23:52+00:00" }, { "name": "twig/twig", @@ -948,16 +948,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.2", + "version": "4.3.3", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + "reference": "2ecaa9fef01634c83bfa8dc1fe35fb5cef223a62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2ecaa9fef01634c83bfa8dc1fe35fb5cef223a62", + "reference": "2ecaa9fef01634c83bfa8dc1fe35fb5cef223a62", "shasum": "" }, "require": { @@ -995,7 +995,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-09-12T14:27:41+00:00" + "time": "2019-12-20T13:40:23+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1046,16 +1046,16 @@ }, { "name": "phpspec/prophecy", - "version": "1.10.0", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "d638ebbb58daba25a6a0dc7969e1358a0e3c6682" + "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d638ebbb58daba25a6a0dc7969e1358a0e3c6682", - "reference": "d638ebbb58daba25a6a0dc7969e1358a0e3c6682", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/cbe1df668b3fe136bcc909126a0f529a78d4cbbc", + "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc", "shasum": "" }, "require": { @@ -1105,7 +1105,7 @@ "spy", "stub" ], - "time": "2019-12-17T16:54:23+00:00" + "time": "2019-12-22T21:05:45+00:00" }, { "name": "phpunit/php-code-coverage", From a4651b80d975f67adb50e72785ce8145b4ef076f Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 25 Dec 2019 19:29:38 +0100 Subject: [PATCH 3/4] :sparkles: Add coverage --- .gitignore | 1 + .../Tests/NamingConventions/ValidFileNameUnitTest.php | 6 +----- build.xml | 9 +++++++++ phpunit.xml.dist | 10 +++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index e4b8cba..6ea25b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea/ composer.phar +coverage/ vendor/ diff --git a/SymfonyCustom/Tests/NamingConventions/ValidFileNameUnitTest.php b/SymfonyCustom/Tests/NamingConventions/ValidFileNameUnitTest.php index 20d5894..4e2aaa0 100644 --- a/SymfonyCustom/Tests/NamingConventions/ValidFileNameUnitTest.php +++ b/SymfonyCustom/Tests/NamingConventions/ValidFileNameUnitTest.php @@ -21,12 +21,8 @@ class ValidFileNameUnitTest extends AbstractSniffUnitTest protected function getErrorList($filename = '') { switch ($filename) { - case 'ValidFileNameUnitTest.inc': - return []; case 'ValidFileNameUnitTest.Invalid.inc': - return [ - 1 => 1, - ]; + return [1 => 1]; default: return []; } diff --git a/build.xml b/build.xml index 884e7ae..2d61cba 100644 --- a/build.xml +++ b/build.xml @@ -39,6 +39,15 @@ + + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0398e24..833bd1d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,9 +10,9 @@ stopOnFailure="false" bootstrap="./bootstrap.php" > - - - ./vendor/squizlabs/php_codesniffer/tests/Standards/AllSniffs.php - - + + + ./vendor/squizlabs/php_codesniffer/src/Standards/SymfonyCustom + + From 51dbba451deee3eac9e4151ae13429a070513384 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 25 Dec 2019 19:39:09 +0100 Subject: [PATCH 4/4] :bug: Fix weird duplication --- TwigCS/tests/AbstractSniffTest.php | 82 ------------------- TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig | 2 - TwigCS/tests/Fixtures/BlankEOFTest.twig | 3 - .../Fixtures/DelimiterSpacingTest.fixed.twig | 20 ----- .../tests/Fixtures/DelimiterSpacingTest.twig | 20 ----- .../Fixtures/DisallowCommentedCodeTest.twig | 7 -- .../tests/Fixtures/EmptyLinesTest.fixed.twig | 3 - TwigCS/tests/Fixtures/EmptyLinesTest.twig | 4 - .../Fixtures/OperatorSpacingTest.fixed.twig | 20 ----- .../tests/Fixtures/OperatorSpacingTest.twig | 20 ----- TwigCS/tests/Ruleset/Generic/BlankEOFTest.php | 21 ----- .../Ruleset/Generic/DelimiterSpacingTest.php | 24 ------ .../Generic/DisallowCommentedCodeTest.php | 21 ----- .../tests/Ruleset/Generic/EmptyLinesTest.php | 21 ----- .../Ruleset/Generic/OperatorSpacingTest.php | 52 ------------ 15 files changed, 320 deletions(-) delete mode 100644 TwigCS/tests/AbstractSniffTest.php delete mode 100644 TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig delete mode 100644 TwigCS/tests/Fixtures/BlankEOFTest.twig delete mode 100644 TwigCS/tests/Fixtures/DelimiterSpacingTest.fixed.twig delete mode 100644 TwigCS/tests/Fixtures/DelimiterSpacingTest.twig delete mode 100644 TwigCS/tests/Fixtures/DisallowCommentedCodeTest.twig delete mode 100644 TwigCS/tests/Fixtures/EmptyLinesTest.fixed.twig delete mode 100644 TwigCS/tests/Fixtures/EmptyLinesTest.twig delete mode 100644 TwigCS/tests/Fixtures/OperatorSpacingTest.fixed.twig delete mode 100644 TwigCS/tests/Fixtures/OperatorSpacingTest.twig delete mode 100644 TwigCS/tests/Ruleset/Generic/BlankEOFTest.php delete mode 100644 TwigCS/tests/Ruleset/Generic/DelimiterSpacingTest.php delete mode 100644 TwigCS/tests/Ruleset/Generic/DisallowCommentedCodeTest.php delete mode 100644 TwigCS/tests/Ruleset/Generic/EmptyLinesTest.php delete mode 100644 TwigCS/tests/Ruleset/Generic/OperatorSpacingTest.php diff --git a/TwigCS/tests/AbstractSniffTest.php b/TwigCS/tests/AbstractSniffTest.php deleted file mode 100644 index 80b0ccd..0000000 --- a/TwigCS/tests/AbstractSniffTest.php +++ /dev/null @@ -1,82 +0,0 @@ -checkGenericSniff(new Sniff(), [...]); - */ - abstract public function testSniff(): void; - - /** - * @param SniffInterface $sniff - * @param array $expects - */ - protected function checkGenericSniff(SniffInterface $sniff, array $expects): void - { - $env = new StubbedEnvironment(); - $tokenizer = new Tokenizer($env); - $linter = new Linter($env, $tokenizer); - $ruleset = new Ruleset(); - - try { - $class = new ReflectionClass(get_called_class()); - $className = $class->getShortName(); - $file = __DIR__.'/Fixtures/'.$className.'.twig'; - - $ruleset->addSniff($sniff); - $report = $linter->run([$file], $ruleset); - } catch (Exception $e) { - $this->fail($e->getMessage()); - - return; - } - - $messages = $report->getMessages(); - $messagePositions = []; - - foreach ($messages as $message) { - if (Report::MESSAGE_TYPE_FATAL === $message->getLevel()) { - $errorMessage = $message->getMessage(); - $line = $message->getLine(); - - if (null !== $line) { - $errorMessage = sprintf('Line %s: %s', $line, $errorMessage); - } - $this->fail($errorMessage); - } - - $messagePositions[] = [$message->getLine() => $message->getLinePosition()]; - } - $this->assertEquals($expects, $messagePositions); - - $fixedFile = __DIR__.'/Fixtures/'.$className.'.fixed.twig'; - if (file_exists($fixedFile)) { - $fixer = new Fixer($ruleset, $tokenizer); - $sniff->enableFixer($fixer); - $fixer->fixFile($file); - - $diff = $fixer->generateDiff($fixedFile); - if ('' !== $diff) { - $this->fail($diff); - } - } - } -} diff --git a/TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig b/TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig deleted file mode 100644 index 1936aaf..0000000 --- a/TwigCS/tests/Fixtures/BlankEOFTest.fixed.twig +++ /dev/null @@ -1,2 +0,0 @@ -
-
diff --git a/TwigCS/tests/Fixtures/BlankEOFTest.twig b/TwigCS/tests/Fixtures/BlankEOFTest.twig deleted file mode 100644 index 99dfd42..0000000 --- a/TwigCS/tests/Fixtures/BlankEOFTest.twig +++ /dev/null @@ -1,3 +0,0 @@ -
-
- diff --git a/TwigCS/tests/Fixtures/DelimiterSpacingTest.fixed.twig b/TwigCS/tests/Fixtures/DelimiterSpacingTest.fixed.twig deleted file mode 100644 index 692a539..0000000 --- a/TwigCS/tests/Fixtures/DelimiterSpacingTest.fixed.twig +++ /dev/null @@ -1,20 +0,0 @@ -{{ foo }} -{# comment #} -{% if foo %}{% endif %} - -{{- foo -}} -{#- comment -#} -{%- if foo -%}{%- endif -%} - -{{ - shouldNotCareAboutNewLine -}} -{%- if foo -%}{%- endif -%} - -{{ foo({'bar': {'baz': 'shouldNotCareAboutDoubleHashes'}}) }} - -
- {{ - shouldNotCareAboutNewLine - }} -
diff --git a/TwigCS/tests/Fixtures/DelimiterSpacingTest.twig b/TwigCS/tests/Fixtures/DelimiterSpacingTest.twig deleted file mode 100644 index 0175972..0000000 --- a/TwigCS/tests/Fixtures/DelimiterSpacingTest.twig +++ /dev/null @@ -1,20 +0,0 @@ -{{ foo }} -{# comment #} -{% if foo %}{% endif %} - -{{- foo -}} -{#- comment -#} -{%- if foo -%}{%- endif -%} - -{{ - shouldNotCareAboutNewLine -}} -{%-if foo -%}{%- endif-%} - -{{ foo({'bar': {'baz': 'shouldNotCareAboutDoubleHashes'}}) }} - -
- {{ - shouldNotCareAboutNewLine - }} -
diff --git a/TwigCS/tests/Fixtures/DisallowCommentedCodeTest.twig b/TwigCS/tests/Fixtures/DisallowCommentedCodeTest.twig deleted file mode 100644 index cc03dae..0000000 --- a/TwigCS/tests/Fixtures/DisallowCommentedCodeTest.twig +++ /dev/null @@ -1,7 +0,0 @@ -
- {# {% set var = 'This is a comment' %} #} -
- -
- {# 'This is a comment' #} -
diff --git a/TwigCS/tests/Fixtures/EmptyLinesTest.fixed.twig b/TwigCS/tests/Fixtures/EmptyLinesTest.fixed.twig deleted file mode 100644 index 70c6156..0000000 --- a/TwigCS/tests/Fixtures/EmptyLinesTest.fixed.twig +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/TwigCS/tests/Fixtures/EmptyLinesTest.twig b/TwigCS/tests/Fixtures/EmptyLinesTest.twig deleted file mode 100644 index 018bc05..0000000 --- a/TwigCS/tests/Fixtures/EmptyLinesTest.twig +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
diff --git a/TwigCS/tests/Fixtures/OperatorSpacingTest.fixed.twig b/TwigCS/tests/Fixtures/OperatorSpacingTest.fixed.twig deleted file mode 100644 index f76f2e7..0000000 --- a/TwigCS/tests/Fixtures/OperatorSpacingTest.fixed.twig +++ /dev/null @@ -1,20 +0,0 @@ -{{ 1 + 2 }} -{{ 1 - 2 }} -{{ 1 / 2 }} -{{ 1 * 2 }} -{{ 1 % 2 }} -{{ 1 // 2 }} -{{ 1 ** 2 }} -{{ foo ~ bar }} -{{ true ? true : false }} -{{ 1 == 2 }} -{{ not true }} -{{ false and true }} -{{ false or true }} -{{ a in array }} -{{ a is array }} - -Untouch +-/*%==: - -{{ [1, 2, 3] }} -{{ {'foo': 'bar'} }} diff --git a/TwigCS/tests/Fixtures/OperatorSpacingTest.twig b/TwigCS/tests/Fixtures/OperatorSpacingTest.twig deleted file mode 100644 index 8bb3808..0000000 --- a/TwigCS/tests/Fixtures/OperatorSpacingTest.twig +++ /dev/null @@ -1,20 +0,0 @@ -{{ 1+2 }} -{{ 1-2 }} -{{ 1/2 }} -{{ 1*2 }} -{{ 1%2 }} -{{ 1//2 }} -{{ 1**2 }} -{{ foo~bar }} -{{ true ? true : false }} -{{ 1==2 }} -{{ not true }} -{{ false and true }} -{{ false or true }} -{{ a in array }} -{{ a is array }} - -Untouch +-/*%==: - -{{ [1, 2, 3] }} -{{ {'foo': 'bar'} }} diff --git a/TwigCS/tests/Ruleset/Generic/BlankEOFTest.php b/TwigCS/tests/Ruleset/Generic/BlankEOFTest.php deleted file mode 100644 index a6fd61c..0000000 --- a/TwigCS/tests/Ruleset/Generic/BlankEOFTest.php +++ /dev/null @@ -1,21 +0,0 @@ -checkGenericSniff(new BlankEOFSniff(), [ - [4 => 1], - ]); - } -} diff --git a/TwigCS/tests/Ruleset/Generic/DelimiterSpacingTest.php b/TwigCS/tests/Ruleset/Generic/DelimiterSpacingTest.php deleted file mode 100644 index 24b8c54..0000000 --- a/TwigCS/tests/Ruleset/Generic/DelimiterSpacingTest.php +++ /dev/null @@ -1,24 +0,0 @@ -checkGenericSniff(new DelimiterSpacingSniff(), [ - [12 => 1], - [12 => 12], - [12 => 15], - [12 => 25], - ]); - } -} diff --git a/TwigCS/tests/Ruleset/Generic/DisallowCommentedCodeTest.php b/TwigCS/tests/Ruleset/Generic/DisallowCommentedCodeTest.php deleted file mode 100644 index f30f55d..0000000 --- a/TwigCS/tests/Ruleset/Generic/DisallowCommentedCodeTest.php +++ /dev/null @@ -1,21 +0,0 @@ -checkGenericSniff(new DisallowCommentedCodeSniff(), [ - [2 => 5], - ]); - } -} diff --git a/TwigCS/tests/Ruleset/Generic/EmptyLinesTest.php b/TwigCS/tests/Ruleset/Generic/EmptyLinesTest.php deleted file mode 100644 index 49d0e8b..0000000 --- a/TwigCS/tests/Ruleset/Generic/EmptyLinesTest.php +++ /dev/null @@ -1,21 +0,0 @@ -checkGenericSniff(new EmptyLinesSniff(), [ - [3 => 1], - ]); - } -} diff --git a/TwigCS/tests/Ruleset/Generic/OperatorSpacingTest.php b/TwigCS/tests/Ruleset/Generic/OperatorSpacingTest.php deleted file mode 100644 index dc0dc5d..0000000 --- a/TwigCS/tests/Ruleset/Generic/OperatorSpacingTest.php +++ /dev/null @@ -1,52 +0,0 @@ -checkGenericSniff(new OperatorSpacingSniff(), [ - [1 => 4], - [1 => 4], - [2 => 5], - [2 => 5], - [3 => 5], - [3 => 5], - [4 => 5], - [4 => 5], - [5 => 5], - [5 => 5], - [6 => 5], - [6 => 5], - [7 => 5], - [7 => 5], - [8 => 7], - [8 => 7], - [9 => 10], - [9 => 10], - [9 => 19], - [9 => 19], - [10 => 5], - [10 => 5], - [11 => 6], - [11 => 6], - [12 => 11], - [12 => 11], - [13 => 11], - [13 => 11], - [14 => 7], - [14 => 7], - [15 => 7], - [15 => 7], - ]); - } -}