Skip to content

Commit

Permalink
feat: Deprecate php 5.6 and 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroTroller committed Jul 3, 2019
1 parent c361a1f commit e2995ce
Show file tree
Hide file tree
Showing 54 changed files with 134 additions and 112 deletions.
68 changes: 0 additions & 68 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use PedroTroller\CS\Fixer\Fixers;
use PedroTroller\CS\Fixer\RuleSetFactory;

Expand All @@ -8,7 +10,7 @@ return PhpCsFixer\Config::create()
->setRules(
RuleSetFactory::create()
->phpCsFixer(true)
->php(5.6, true)
->php(7.1, true)
->pedrotroller(true)
->enable('ordered_imports')
->enable('align_multiline_comment')
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions spec/PedroTroller/CS/Fixer/RuleSetFactorySpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\PedroTroller\CS\Fixer;

use PedroTroller\CS\Fixer\Fixers;
Expand Down
2 changes: 2 additions & 0 deletions src/PedroTroller/CS/Fixer/AbstractFixer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer;

use PhpCsFixer\AbstractFixer as PhpCsFixer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer;

use PhpCsFixer\Tokenizer\CT;
Expand All @@ -11,7 +13,7 @@ abstract class AbstractOrderedClassElementsFixer extends AbstractFixer
/**
* {@inheritdoc}
*/
protected function applyFix(SplFileInfo $file, Tokens $tokens)
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
for ($i = 1, $count = $tokens->count(); $i < $count; ++$i) {
if (!$tokens[$i]->isClassy()) {
Expand Down Expand Up @@ -187,7 +189,7 @@ private function sortTokens(
$startIndex,
$endIndex,
array $elements
) {
): void {
$replaceTokens = [];

foreach ($elements as $element) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer\ClassNotation;

use PedroTroller\CS\Fixer\AbstractOrderedClassElementsFixer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getDocumentation()
return 'Exception messages MUST ends by ".", "…", "?" or "!".<br /><br /><i>Risky: will change the exception message.</i>';
}

protected function applyFix(SplFileInfo $file, Tokens $tokens)
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
$cases = $this->analyze($tokens)->findAllSequences([
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer\CodingStyle;

use PedroTroller\CS\Fixer\AbstractFixer;
Expand Down Expand Up @@ -59,7 +61,7 @@ public function getDocumentation()
return 'Forbidden functions MUST BE commented';
}

protected function applyFix(SplFileInfo $file, Tokens $tokens)
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
$calls = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer\CodingStyle;

use PedroTroller\CS\Fixer\AbstractFixer;
Expand Down Expand Up @@ -82,7 +84,7 @@ public function fun3(
/**
* {@inheritdoc}
*/
protected function applyFix(SplFileInfo $file, Tokens $tokens)
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
$functions = [];

Expand Down Expand Up @@ -158,7 +160,7 @@ protected function createConfigurationDefinition()
]);
}

private function splitArgs(Tokens $tokens, $index)
private function splitArgs(Tokens $tokens, $index): void
{
$openBraceIndex = $tokens->getNextTokenOfKind($index, ['(']);
$closeBraceIndex = $this->analyze($tokens)->getClosingParenthesis($openBraceIndex);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer\CodingStyle;

use PedroTroller\CS\Fixer\AbstractFixer;
Expand Down Expand Up @@ -64,14 +66,14 @@ public function getDocumentation()
return 'Transform multiline docblocks with only one comment into a singleline docblock.';
}

protected function applyFix(SplFileInfo $file, Tokens $tokens)
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
foreach ($tokens->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(
Expand All @@ -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([
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 5 additions & 3 deletions src/PedroTroller/CS/Fixer/Comment/SingleLineCommentFixer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer\Comment;

use PedroTroller\CS\Fixer\AbstractFixer;
Expand Down Expand Up @@ -96,7 +98,7 @@ public function getDeprecationReplacement()
/**
* {@inheritdoc}
*/
protected function applyFix(SplFileInfo $file, Tokens $tokens)
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
$this->{$this->configuration['action'].'Comment'}($tokens);
}
Expand All @@ -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 = '';
Expand All @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/PedroTroller/CS/Fixer/Comment/UselessCommentFixer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer\Comment;

use PedroTroller\CS\Fixer\AbstractFixer;
Expand Down Expand Up @@ -78,7 +80,7 @@ public function getDeprecationReplacement()
/**
* {@inheritdoc}
*/
protected function applyFix(SplFileInfo $file, Tokens $tokens)
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
foreach ($this->analyze($tokens)->getClassyElements() as $index => $element) {
if ('method' !== $element['type']) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer\DeadCode;

use PedroTroller\CS\Fixer\AbstractFixer;
Expand Down Expand Up @@ -72,7 +74,7 @@ public function buildCallable()
/**
* {@inheritdoc}
*/
protected function applyFix(SplFileInfo $file, Tokens $tokens)
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
$returns = $tokens->findGivenKind(T_RETURN);
$analyzer = $this->analyze($tokens);
Expand Down
6 changes: 3 additions & 3 deletions src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down Expand Up @@ -157,7 +157,7 @@ private function removeUselessGetDocumentation(Tokens $tokens)
}
}

private function removeUselessComments(Tokens $tokens)
private function removeUselessComments(Tokens $tokens): void
{
$comments = $this->getComments($tokens);

Expand Down
2 changes: 2 additions & 0 deletions src/PedroTroller/CS/Fixer/Fixers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer;

use IteratorAggregate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PedroTroller\CS\Fixer\Phpspec;

use PedroTroller\CS\Fixer\AbstractOrderedClassElementsFixer;
Expand Down
Loading

0 comments on commit e2995ce

Please sign in to comment.