Skip to content

Commit

Permalink
feat: deprecate php 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroTroller committed Feb 26, 2020
1 parent 8855261 commit b72957d
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 66 deletions.
58 changes: 29 additions & 29 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,81 +26,81 @@ tests_with_future_mode: &tests_with_future_mode
composer run php-cs-fixer || (echo "Coding standards are not respected. Run 'composer run php-cs-fixer'" && exit 1)
jobs:
php 7.1:
php 7.2:
docker:
- image: circleci/php:7.1
- image: circleci/php:7.2
steps:
- checkout
- <<: *composer
- <<: *tests

php 7.1 with future mode:
php 7.2 with future mode:
docker:
- image: circleci/php:7.1
- image: circleci/php:7.2
steps:
- checkout
- <<: *composer
- <<: *tests_with_future_mode

php 7.1 with lowest dependencies:
php 7.2 with lowest dependencies:
docker:
- image: circleci/php:7.1
- image: circleci/php:7.2
steps:
- checkout
- <<: *composer_with_lowest_dependencies
- <<: *tests

php 7.2:
php 7.3:
docker:
- image: circleci/php:7.2
- image: circleci/php:7.3
steps:
- checkout
- <<: *composer
- <<: *tests

php 7.2 with future mode:
php 7.3 with future mode:
docker:
- image: circleci/php:7.2
- image: circleci/php:7.3
steps:
- checkout
- <<: *composer
- <<: *tests_with_future_mode

php 7.2 with lowest dependencies:
php 7.3 with lowest dependencies:
docker:
- image: circleci/php:7.2
- image: circleci/php:7.3
steps:
- checkout
- <<: *composer_with_lowest_dependencies
- <<: *tests

php 7.3:
php 7.4:
docker:
- image: circleci/php:7.3
- image: circleci/php:7.4
steps:
- checkout
- <<: *composer
- <<: *tests

php 7.3 with future mode:
php 7.4 with future mode:
docker:
- image: circleci/php:7.3
- image: circleci/php:7.4
steps:
- checkout
- <<: *composer
- <<: *tests_with_future_mode

php 7.3 with lowest dependencies:
php 7.4 with lowest dependencies:
docker:
- image: circleci/php:7.3
- image: circleci/php:7.4
steps:
- checkout
- <<: *composer_with_lowest_dependencies
- <<: *tests

documentation is up to date:
docker:
- image: circleci/php:7.3
- image: circleci/php:7.4
steps:
- checkout
- <<: *composer
Expand All @@ -120,13 +120,6 @@ workflows:
PR:
jobs:
- documentation is up to date
- php 7.1
- php 7.1 with future mode:
requires:
- php 7.1
- php 7.1 with lowest dependencies:
requires:
- php 7.1
- php 7.2
- php 7.2 with future mode:
requires:
Expand All @@ -141,18 +134,25 @@ workflows:
- php 7.3 with lowest dependencies:
requires:
- php 7.3
- php 7.4
- php 7.4 with future mode:
requires:
- php 7.4
- php 7.4 with lowest dependencies:
requires:
- php 7.4
- release:
requires:
- documentation is up to date
- php 7.1
- php 7.1 with future mode
- php 7.1 with lowest dependencies
- php 7.2
- php 7.2 with future mode
- php 7.2 with lowest dependencies
- php 7.3
- php 7.3 with future mode
- php 7.3 with lowest dependencies
- php 7.4
- php 7.4 with future mode
- php 7.4 with lowest dependencies
filters:
branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ return PhpCsFixer\Config::create()
->setRules(
RuleSetFactory::create()
->phpCsFixer(true)
->php(7.1, true)
->php(7.2, true)
->pedrotroller(true)
->enable('ordered_imports')
->enable('ordered_interfaces')
Expand Down
4 changes: 2 additions & 2 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ plugins:
release: minor
- type: fix
scope: deps-dev
release: patch
release: false
- type: refactor
release: patch
release: false
- scope: chore
release: false
- '@semantic-release/release-notes-generator'
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"description": "PHP-CS-FIXER : my custom fixers",
"license": "MIT",
"require": {
"php": ">=7.1",
"friendsofphp/php-cs-fixer": "^2.15.0"
"php": ">=7.2",
"friendsofphp/php-cs-fixer": "^2.16.1"
},
"require-dev": {
"phpspec/phpspec": "^5.1.0",
"rector/rector": "^0.5.19",
"phpspec/phpspec": "^6.1",
"rector/rector": "^0.7.1",
"twig/twig": "^2.11.3",
"webmozart/assert": "^1.3.0"
},
Expand Down
19 changes: 11 additions & 8 deletions rector.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
parameters:
auto_import_names: true

exclude_rectors:
- Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector

imports:
- resource: vendor/rector/rector/config/set/code-quality/*
- resource: vendor/rector/rector/config/set/php/php71.yaml
- resource: vendor/rector/rector/config/set/phpspec/*
- resource: vendor/rector/rector/config/set/psr-4/*
- resource: vendor/rector/rector/config/set/solid/*
paths:
- src
- tests
- spec
sets:
- code-quality
- php71
- php72
- phpspec
- psr-4
- solid
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class LineBreakBetweenStatementsFixer extends AbstractFixer
/**
* @var array<int, string>
*/
private $handlers = [
private const HANDLERS = [
T_DO => 'do',
T_FOR => 'common',
T_FOREACH => 'common',
Expand Down Expand Up @@ -68,8 +68,8 @@ public function getDocumentation()

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);
foreach ($tokens->findGivenKind(array_keys(self::HANDLERS)) as $kind => $matchedTokens) {
$this->{'handle'.ucfirst(self::HANDLERS[$kind])}($matchedTokens, $tokens);
}
}

Expand Down Expand Up @@ -127,7 +127,7 @@ private function fixSpaces($index, Tokens $tokens): void
return;
}

if (false === \array_key_exists($tokens[$nextMeaningful]->getId(), $this->handlers)) {
if (false === \array_key_exists($tokens[$nextMeaningful]->getId(), self::HANDLERS)) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/PedroTroller/CS/Fixer/Comment/SingleLineCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ final class SingleLineCommentFixer extends AbstractFixer implements Configuratio
/**
* @var string
*/
private $collapseRegex = '/( *)\/[*]{1,2}\n( *)[*]{1,2} %s (.+)\n( *)\*\//';
private const COLLAPSE_REGEX = '/( *)\/[*]{1,2}\n( *)[*]{1,2} %s (.+)\n( *)\*\//';

/**
* @var string
*/
private $expandRegex = '/( *)\/[*]{1,2} %s (.+) \*\//';
private const EXPAND_REGEX = '/( *)\/[*]{1,2} %s (.+) \*\//';

/**
* {@inheritdoc}
Expand Down Expand Up @@ -129,7 +129,7 @@ private function expandedComment(Tokens $tokens): void
}

foreach ($this->configuration['types'] as $variable) {
$regex = sprintf($this->expandRegex, $variable);
$regex = sprintf(self::EXPAND_REGEX, $variable);
$replace = sprintf("/**\n%s * %s $2\n%s */", $space, $variable, $space);
$comment = preg_replace($regex, $replace, $token->getContent());
$tokens[$index] = new Token([T_COMMENT, $comment]);
Expand All @@ -141,7 +141,7 @@ private function collapsedComment(Tokens $tokens): void
{
foreach ($this->getComments($tokens) as $index => $token) {
foreach ($this->configuration['types'] as $variable) {
$regex = sprintf($this->collapseRegex, $variable);
$regex = sprintf(self::COLLAPSE_REGEX, $variable);
$replace = sprintf('$1/** %s $3 */', $variable);
$comment = preg_replace($regex, $replace, $token->getContent());
$tokens[$index] = new Token([T_COMMENT, $comment]);
Expand Down
17 changes: 10 additions & 7 deletions src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@

final class DoctrineMigrationsFixer extends AbstractFixer implements ConfigurationDefinitionFixerInterface
{
/**
* @var string[]
*/
private const BLACKLIST = [
'Auto-generated Migration: Please modify to your needs!',
'this up() migration is auto-generated, please modify it to your needs',
'this down() migration is auto-generated, please modify it to your needs',
];

public function getSampleConfigurations()
{
return [
Expand Down Expand Up @@ -161,18 +170,12 @@ private function removeUselessComments(Tokens $tokens): void
{
$comments = $this->getComments($tokens);

$blackList = [
'Auto-generated Migration: Please modify to your needs!',
'this up() migration is auto-generated, please modify it to your needs',
'this down() migration is auto-generated, please modify it to your needs',
];

foreach ($comments as $position => $comment) {
$lines = explode("\n", $comment->getContent());
$changed = false;

foreach ($lines as $index => $line) {
if (\in_array(trim($line, '/* '), $blackList, true)) {
if (\in_array(trim($line, '/* '), self::BLACKLIST, true)) {
unset($lines[$index]);
$changed = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/PedroTroller/CS/Fixer/Priority.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ private function __construct()
}

/**
* @param array<int,mixed> $classes
* @param array<int, mixed> $classes
*
* @return int
*/
Expand All @@ -28,7 +28,7 @@ function ($class) {
}

/**
* @param array<int,mixed> $classes
* @param array<int, mixed> $classes
*
* @return int
*/
Expand Down
2 changes: 0 additions & 2 deletions src/PedroTroller/CS/Fixer/RuleSetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ private function migration($package, $version, $risky)
$rules = array_combine($rules, $rules);

$rules = array_map(function ($name) {
$matches = [];

preg_match('/^@([A-Za-z]+)(\d+)Migration(:risky|)$/', $name, $matches);

return $matches;
Expand Down
6 changes: 3 additions & 3 deletions src/PedroTroller/CS/Fixer/TokensAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public function endOfTheStatement($index)
/**
* @param int $index
*
* @return int | null
* @return null|int
*/
public function getClosingParenthesis($index)
{
Expand Down Expand Up @@ -339,7 +339,7 @@ public function getClosingParenthesis($index)
/**
* @param int $index
*
* @return int | null
* @return null|int
*/
public function getClosingBracket($index)
{
Expand Down Expand Up @@ -367,7 +367,7 @@ public function getClosingBracket($index)
/**
* @param int $index
*
* @return int | null
* @return null|int
*/
public function getClosingCurlyBracket($index)
{
Expand Down

0 comments on commit b72957d

Please sign in to comment.