From e2995ce352c43cc17ae4f72a263ce5b958fab214 Mon Sep 17 00:00:00 2001 From: Pierre PLAZANET Date: Wed, 3 Jul 2019 15:34:22 +0200 Subject: [PATCH] feat: Deprecate php 5.6 and 7.0 --- .circleci/config.yml | 68 ------------------- .php_cs.dist | 4 +- composer.json | 2 +- .../CS/Fixer/RuleSetFactorySpec.php | 2 + src/PedroTroller/CS/Fixer/AbstractFixer.php | 2 + .../AbstractOrderedClassElementsFixer.php | 6 +- .../OrderedWithGetterAndSetterFirstFixer.php | 2 + .../ExceptionsPunctuationFixer.php | 2 +- .../CodingStyle/ForbiddenFunctionsFixer.php | 4 +- .../LineBreakBetweenMethodArgumentsFixer.php | 8 ++- .../LineBreakBetweenStatementsFixer.php | 10 +-- .../Comment/CommentLineToPhpdocBlockFixer.php | 2 +- .../Fixer/Comment/SingleLineCommentFixer.php | 8 ++- .../CS/Fixer/Comment/UselessCommentFixer.php | 4 +- .../DeadCode/UselessCodeAfterReturnFixer.php | 4 +- .../CS/Fixer/DoctrineMigrationsFixer.php | 6 +- src/PedroTroller/CS/Fixer/Fixers.php | 2 + .../Phpspec/OrderedSpecElementsFixer.php | 2 + ...specScenarioReturnTypeDeclarationFixer.php | 4 +- .../Phpspec/PhpspecScenarioScopeFixer.php | 4 +- src/PedroTroller/CS/Fixer/PhpspecFixer.php | 8 ++- src/PedroTroller/CS/Fixer/Priority.php | 2 + src/PedroTroller/CS/Fixer/RuleSetFactory.php | 6 +- src/PedroTroller/CS/Fixer/TokenSignatures.php | 2 + src/PedroTroller/CS/Fixer/TokensAnalyzer.php | 4 +- tests/Orchestra.php | 2 +- tests/Runner.php | 10 +-- tests/TokensAnalyzerIntegration.php | 2 + tests/TokensAnalyzerIntegration/InSwitch.php | 4 +- .../LineIndentation.php | 4 +- .../MethodArguments.php | 6 +- .../NextSemiColon.php | 2 +- .../TokensAnalyzerIntegration/Parenthesis.php | 2 +- .../ReturnedType.php | 4 +- .../SizeOfTheLine.php | 4 +- tests/UseCase.php | 2 + tests/UseCase/ForbiddenFunctions.php | 2 + tests/UseCase/LineBreakBetweenMethods.php | 2 + .../Regression/Case1.php | 2 + .../Regression/Case2.php | 2 + .../Regression/Case3.php | 2 + ...eBreakBetweenMethodsWithNoReformatting.php | 2 + tests/UseCase/LineBreakBetweenStatements.php | 2 + tests/UseCase/OrderedSpecElements.php | 2 + .../OrderedSpecElements/Regression/Case1.php | 2 + .../OrderedWithGetterAndSetterFirst.php | 2 + .../Regression/Case1.php | 2 + .../Regression/Case2.php | 2 + tests/UseCase/Phpspec.php | 2 + tests/UseCase/PhpspecScenarioScope.php | 2 + tests/UseCase/UselessCodeAfterReturn.php | 2 + tests/UseCase/UselessComment.php | 2 + tests/UseCase/UselessComment/Php71.php | 2 + .../Regression/DoubleLineBreak.php | 2 + 54 files changed, 134 insertions(+), 112 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 987538d..23e90f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,54 +24,6 @@ tests_with_future_mode: &tests_with_future_mode vendor/bin/php-cs-fixer fix --diff || (echo "Coding standards are not respected. Run 'vendor/bin/php-cs-fixer fix'" && exit 1) jobs: - php 5.6: - docker: - - image: circleci/php:5.6 - steps: - - checkout - - <<: *composer - - <<: *tests - - php 5.6 with future mode: - docker: - - image: circleci/php:5.6 - steps: - - checkout - - <<: *composer - - <<: *tests - - php 5.6 with lowest dependencies: - docker: - - image: circleci/php:5.6 - steps: - - checkout - - <<: *composer_with_lowest_dependencies - - <<: *tests - - php 7.0: - docker: - - image: circleci/php:7.0 - steps: - - checkout - - <<: *composer - - <<: *tests - - php 7.0 with future mode: - docker: - - image: circleci/php:7.0 - steps: - - checkout - - <<: *composer - - <<: *tests_with_future_mode - - php 7.0 with lowest dependencies: - docker: - - image: circleci/php:7.0 - steps: - - checkout - - <<: *composer_with_lowest_dependencies - - <<: *tests - php 7.1: docker: - image: circleci/php:7.1 @@ -166,20 +118,6 @@ workflows: PR: jobs: - documentation is up to date - - php 5.6 - - php 5.6 with future mode: - requires: - - php 5.6 - - php 5.6 with lowest dependencies: - requires: - - php 5.6 - - php 7.0 - - php 7.0 with future mode: - requires: - - php 7.0 - - php 7.0 with lowest dependencies: - requires: - - php 7.0 - php 7.1 - php 7.1 with future mode: requires: @@ -204,12 +142,6 @@ workflows: - release: requires: - documentation is up to date - - php 5.6 - - php 5.6 with future mode - - php 5.6 with lowest dependencies - - php 7.0 - - php 7.0 with future mode - - php 7.0 with lowest dependencies - php 7.1 - php 7.1 with future mode - php 7.1 with lowest dependencies diff --git a/.php_cs.dist b/.php_cs.dist index 92a6471..f233da8 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,5 +1,7 @@ setRules( RuleSetFactory::create() ->phpCsFixer(true) - ->php(5.6, true) + ->php(7.1, true) ->pedrotroller(true) ->enable('ordered_imports') ->enable('align_multiline_comment') diff --git a/composer.json b/composer.json index 4732f68..bd0fac9 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "PHP-CS-FIXER : my custom fixers", "license": "MIT", "require": { - "php": ">=5.6", + "php": ">=7.1", "friendsofphp/php-cs-fixer": "^2.14.2" }, "require-dev": { diff --git a/spec/PedroTroller/CS/Fixer/RuleSetFactorySpec.php b/spec/PedroTroller/CS/Fixer/RuleSetFactorySpec.php index 60e9557..3627294 100644 --- a/spec/PedroTroller/CS/Fixer/RuleSetFactorySpec.php +++ b/spec/PedroTroller/CS/Fixer/RuleSetFactorySpec.php @@ -1,5 +1,7 @@ count(); $i < $count; ++$i) { if (!$tokens[$i]->isClassy()) { @@ -187,7 +189,7 @@ private function sortTokens( $startIndex, $endIndex, array $elements - ) { + ): void { $replaceTokens = []; foreach ($elements as $element) { diff --git a/src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php b/src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php index 173ee3b..058f70d 100644 --- a/src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php +++ b/src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php @@ -1,5 +1,7 @@
Risky: will change the exception message.'; } - protected function applyFix(SplFileInfo $file, Tokens $tokens) + protected function applyFix(SplFileInfo $file, Tokens $tokens): void { $cases = $this->analyze($tokens)->findAllSequences([ [ diff --git a/src/PedroTroller/CS/Fixer/CodingStyle/ForbiddenFunctionsFixer.php b/src/PedroTroller/CS/Fixer/CodingStyle/ForbiddenFunctionsFixer.php index 22005dc..48db2f0 100644 --- a/src/PedroTroller/CS/Fixer/CodingStyle/ForbiddenFunctionsFixer.php +++ b/src/PedroTroller/CS/Fixer/CodingStyle/ForbiddenFunctionsFixer.php @@ -1,5 +1,7 @@ getNextTokenOfKind($index, ['(']); $closeBraceIndex = $this->analyze($tokens)->getClosingParenthesis($openBraceIndex); @@ -220,7 +222,7 @@ private function splitArgs(Tokens $tokens, $index) $tokens->removeTrailingWhitespace($tokens->getPrevMeaningfulToken($closeBraceIndex)); } - private function mergeArgs(Tokens $tokens, $index) + private function mergeArgs(Tokens $tokens, $index): void { $openBraceIndex = $tokens->getNextTokenOfKind($index, ['(']); $closeBraceIndex = $this->analyze($tokens)->getClosingParenthesis($openBraceIndex); diff --git a/src/PedroTroller/CS/Fixer/CodingStyle/LineBreakBetweenStatementsFixer.php b/src/PedroTroller/CS/Fixer/CodingStyle/LineBreakBetweenStatementsFixer.php index dd7dd21..91d0ea5 100644 --- a/src/PedroTroller/CS/Fixer/CodingStyle/LineBreakBetweenStatementsFixer.php +++ b/src/PedroTroller/CS/Fixer/CodingStyle/LineBreakBetweenStatementsFixer.php @@ -1,5 +1,7 @@ findGivenKind(array_keys($this->handlers)) as $kind => $matchedTokens) { $this->{'handle'.ucfirst($this->handlers[$kind])}($matchedTokens, $tokens); } } - private function handleDo(array $matchedTokens, Tokens $tokens) + private function handleDo(array $matchedTokens, Tokens $tokens): void { foreach ($matchedTokens as $index => $token) { $this->fixSpaces( @@ -81,7 +83,7 @@ private function handleDo(array $matchedTokens, Tokens $tokens) } } - private function handleCommon(array $matchedTokens, Tokens $tokens) + private function handleCommon(array $matchedTokens, Tokens $tokens): void { foreach ($matchedTokens as $index => $token) { $curlyBracket = $tokens->findSequence([ @@ -111,7 +113,7 @@ private function handleCommon(array $matchedTokens, Tokens $tokens) } } - private function fixSpaces($index, Tokens $tokens) + private function fixSpaces($index, Tokens $tokens): void { $space = $index + 1; diff --git a/src/PedroTroller/CS/Fixer/Comment/CommentLineToPhpdocBlockFixer.php b/src/PedroTroller/CS/Fixer/Comment/CommentLineToPhpdocBlockFixer.php index cc27d38..4e126d3 100644 --- a/src/PedroTroller/CS/Fixer/Comment/CommentLineToPhpdocBlockFixer.php +++ b/src/PedroTroller/CS/Fixer/Comment/CommentLineToPhpdocBlockFixer.php @@ -85,7 +85,7 @@ public function getPriority() /** * {@inheritdoc} */ - protected function applyFix(SplFileInfo $file, Tokens $tokens) + protected function applyFix(SplFileInfo $file, Tokens $tokens): void { $elements = $this->analyze($tokens)->getClassyElements(); diff --git a/src/PedroTroller/CS/Fixer/Comment/SingleLineCommentFixer.php b/src/PedroTroller/CS/Fixer/Comment/SingleLineCommentFixer.php index 444cca6..610693f 100644 --- a/src/PedroTroller/CS/Fixer/Comment/SingleLineCommentFixer.php +++ b/src/PedroTroller/CS/Fixer/Comment/SingleLineCommentFixer.php @@ -1,5 +1,7 @@ {$this->configuration['action'].'Comment'}($tokens); } @@ -117,7 +119,7 @@ protected function createConfigurationDefinition() ]); } - private function expandedComment(Tokens $tokens) + private function expandedComment(Tokens $tokens): void { foreach ($this->getComments($tokens) as $index => $token) { $space = ''; @@ -135,7 +137,7 @@ private function expandedComment(Tokens $tokens) } } - private function collapsedComment(Tokens $tokens) + private function collapsedComment(Tokens $tokens): void { foreach ($this->getComments($tokens) as $index => $token) { foreach ($this->configuration['types'] as $variable) { diff --git a/src/PedroTroller/CS/Fixer/Comment/UselessCommentFixer.php b/src/PedroTroller/CS/Fixer/Comment/UselessCommentFixer.php index 286f85e..955a480 100644 --- a/src/PedroTroller/CS/Fixer/Comment/UselessCommentFixer.php +++ b/src/PedroTroller/CS/Fixer/Comment/UselessCommentFixer.php @@ -1,5 +1,7 @@ analyze($tokens)->getClassyElements() as $index => $element) { if ('method' !== $element['type']) { diff --git a/src/PedroTroller/CS/Fixer/DeadCode/UselessCodeAfterReturnFixer.php b/src/PedroTroller/CS/Fixer/DeadCode/UselessCodeAfterReturnFixer.php index 849b0e3..622abfe 100644 --- a/src/PedroTroller/CS/Fixer/DeadCode/UselessCodeAfterReturnFixer.php +++ b/src/PedroTroller/CS/Fixer/DeadCode/UselessCodeAfterReturnFixer.php @@ -1,5 +1,7 @@ findGivenKind(T_RETURN); $analyzer = $this->analyze($tokens); diff --git a/src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php b/src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php index fb2ec92..4e402b9 100644 --- a/src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php +++ b/src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php @@ -111,13 +111,13 @@ protected function createConfigurationDefinition() /** * {@inheritdoc} */ - protected function applyFix(SplFileInfo $file, Tokens $tokens) + protected function applyFix(SplFileInfo $file, Tokens $tokens): void { $this->removeUselessGetDocumentation($tokens); $this->removeUselessComments($tokens); } - private function removeUselessGetDocumentation(Tokens $tokens) + private function removeUselessGetDocumentation(Tokens $tokens): void { foreach ($this->analyze($tokens)->getElements() as $element) { if ('method' !== $element['type']) { @@ -157,7 +157,7 @@ private function removeUselessGetDocumentation(Tokens $tokens) } } - private function removeUselessComments(Tokens $tokens) + private function removeUselessComments(Tokens $tokens): void { $comments = $this->getComments($tokens); diff --git a/src/PedroTroller/CS/Fixer/Fixers.php b/src/PedroTroller/CS/Fixer/Fixers.php index 632d74e..19b524a 100644 --- a/src/PedroTroller/CS/Fixer/Fixers.php +++ b/src/PedroTroller/CS/Fixer/Fixers.php @@ -1,5 +1,7 @@ $token) { if (T_FUNCTION !== $token->getId()) { diff --git a/src/PedroTroller/CS/Fixer/Phpspec/PhpspecScenarioScopeFixer.php b/src/PedroTroller/CS/Fixer/Phpspec/PhpspecScenarioScopeFixer.php index 02af338..1aeeaca 100644 --- a/src/PedroTroller/CS/Fixer/Phpspec/PhpspecScenarioScopeFixer.php +++ b/src/PedroTroller/CS/Fixer/Phpspec/PhpspecScenarioScopeFixer.php @@ -1,5 +1,7 @@ $token) { if (T_FUNCTION !== $token->getId()) { diff --git a/src/PedroTroller/CS/Fixer/PhpspecFixer.php b/src/PedroTroller/CS/Fixer/PhpspecFixer.php index 1d854a9..453940b 100644 --- a/src/PedroTroller/CS/Fixer/PhpspecFixer.php +++ b/src/PedroTroller/CS/Fixer/PhpspecFixer.php @@ -1,5 +1,7 @@ removeScope($file, $tokens); $this->removeReturn($file, $tokens); @@ -146,7 +148,7 @@ protected function applyFix(SplFileInfo $file, Tokens $tokens) parent::applyFix($file, $tokens); } - private function removeScope(SplFileInfo $file, Tokens $tokens) + private function removeScope(SplFileInfo $file, Tokens $tokens): void { foreach ($tokens as $index => $token) { if (T_FUNCTION !== $token->getId()) { @@ -177,7 +179,7 @@ private function removeScope(SplFileInfo $file, Tokens $tokens) } } - private function removeReturn(SplFileInfo $file, Tokens $tokens) + private function removeReturn(SplFileInfo $file, Tokens $tokens): void { foreach ($tokens as $index => $token) { if (T_FUNCTION !== $token->getId()) { diff --git a/src/PedroTroller/CS/Fixer/Priority.php b/src/PedroTroller/CS/Fixer/Priority.php index fe5a1ac..4cd2b12 100644 --- a/src/PedroTroller/CS/Fixer/Priority.php +++ b/src/PedroTroller/CS/Fixer/Priority.php @@ -1,5 +1,7 @@ = $start && $index <= $end) { return true; diff --git a/tests/Orchestra.php b/tests/Orchestra.php index 339c9ec..7a79bba 100644 --- a/tests/Orchestra.php +++ b/tests/Orchestra.php @@ -27,7 +27,7 @@ private function __construct(FixerInterface $fixer) $this->fixer = $fixer; } - public static function run() + public static function run(): void { self::assert(new OrderedWithGetterAndSetterFirstFixer()) ->before(new OrderedClassElementsFixer()) diff --git a/tests/Runner.php b/tests/Runner.php index c6523bd..429c189 100644 --- a/tests/Runner.php +++ b/tests/Runner.php @@ -1,5 +1,7 @@ isInsideSwitchCase( diff --git a/tests/TokensAnalyzerIntegration/LineIndentation.php b/tests/TokensAnalyzerIntegration/LineIndentation.php index 81aa909..b66ae3c 100644 --- a/tests/TokensAnalyzerIntegration/LineIndentation.php +++ b/tests/TokensAnalyzerIntegration/LineIndentation.php @@ -1,5 +1,7 @@ getLineIndentation( diff --git a/tests/TokensAnalyzerIntegration/MethodArguments.php b/tests/TokensAnalyzerIntegration/MethodArguments.php index 7c14c1d..e1b1bd1 100644 --- a/tests/TokensAnalyzerIntegration/MethodArguments.php +++ b/tests/TokensAnalyzerIntegration/MethodArguments.php @@ -1,5 +1,7 @@ getClassyElements(), @@ -52,7 +54,7 @@ function ($element) { return 'method' === $element['type']; } Assert::count($methods, 3); - list($contructor, $theFunction, $setUser) = array_keys($methods); + [$contructor, $theFunction, $setUser] = array_keys($methods); $arguments = $analyzer->getMethodArguments($contructor); Assert::eq($analyzer->getNumberOfArguments($contructor), 0); diff --git a/tests/TokensAnalyzerIntegration/NextSemiColon.php b/tests/TokensAnalyzerIntegration/NextSemiColon.php index 1414312..e954984 100644 --- a/tests/TokensAnalyzerIntegration/NextSemiColon.php +++ b/tests/TokensAnalyzerIntegration/NextSemiColon.php @@ -48,7 +48,7 @@ public function theFunction() /** * {@inheritdoc} */ - public function assertions(TokensAnalyzer $analyzer, Tokens $tokens) + public function assertions(TokensAnalyzer $analyzer, Tokens $tokens): void { Assert::eq( $analyzer->getNextSemiColon( diff --git a/tests/TokensAnalyzerIntegration/Parenthesis.php b/tests/TokensAnalyzerIntegration/Parenthesis.php index 6647383..2f76274 100644 --- a/tests/TokensAnalyzerIntegration/Parenthesis.php +++ b/tests/TokensAnalyzerIntegration/Parenthesis.php @@ -45,7 +45,7 @@ public function setName(string $name): void PHP; } - public function assertions(TokensAnalyzer $analyzer, Tokens $tokens) + public function assertions(TokensAnalyzer $analyzer, Tokens $tokens): void { Assert::eq( $analyzer->getClosingParenthesis($this->tokenContaining($tokens, 'getId') + 1), diff --git a/tests/TokensAnalyzerIntegration/ReturnedType.php b/tests/TokensAnalyzerIntegration/ReturnedType.php index ebdb4a7..2f9fe94 100644 --- a/tests/TokensAnalyzerIntegration/ReturnedType.php +++ b/tests/TokensAnalyzerIntegration/ReturnedType.php @@ -1,5 +1,7 @@ getReturnedType( diff --git a/tests/TokensAnalyzerIntegration/SizeOfTheLine.php b/tests/TokensAnalyzerIntegration/SizeOfTheLine.php index 75f4a9f..975d84c 100644 --- a/tests/TokensAnalyzerIntegration/SizeOfTheLine.php +++ b/tests/TokensAnalyzerIntegration/SizeOfTheLine.php @@ -1,5 +1,7 @@ getSizeOfTheLine( diff --git a/tests/UseCase.php b/tests/UseCase.php index 1af4320..d961301 100644 --- a/tests/UseCase.php +++ b/tests/UseCase.php @@ -1,5 +1,7 @@