From d39b247f2c653c136b2bcf451db36829b8a30f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Olvera=20Ju=C3=A1rez=20=28jeojhx=29?= Date: Wed, 16 Feb 2022 16:56:24 -0600 Subject: [PATCH] feat: upgrade to php 8.0 --- .gitignore | 2 +- .php_cs => .php-cs-fixer.php | 30 ++++++++++++++++---- composer.json | 8 +++--- src/Type/Collection/FixedTypedCollection.php | 7 ++--- 4 files changed, 33 insertions(+), 14 deletions(-) rename .php_cs => .php-cs-fixer.php (63%) diff --git a/.gitignore b/.gitignore index 63f7776..e0448b0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ /vendor /phpunit.xml /coverage.xml -/.php_cs.cache +/.php-cs-fixer.cache /composer.lock .phpunit.result.cache diff --git a/.php_cs b/.php-cs-fixer.php similarity index 63% rename from .php_cs rename to .php-cs-fixer.php index 8a105b4..fba9b86 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -4,7 +4,8 @@ ->in(__DIR__ . '/src') ->in(__DIR__ . '/tests'); -return PhpCsFixer\Config::create() +$config = new PhpCsFixer\Config(); +$config ->setRules([ '@Symfony' => true, '@PHP71Migration:risky' => true, @@ -13,15 +14,14 @@ 'array_syntax' => ['syntax' => 'short'], 'blank_line_after_opening_tag' => true, 'concat_space' => ['spacing' => 'one'], - 'class_attributes_separation' => ['elements' => ['method']], + 'class_attributes_separation' => ['elements' => ['method'=>'one']], 'declare_strict_types' => true, 'increment_style' => ['style' => 'post'], - 'is_null' => ['use_yoda_style' => false], 'list_syntax' => ['syntax' => 'short'], - 'method_argument_space' => ['ensure_fully_multiline' => true], + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 'method_chaining_indentation' => true, 'modernize_types_casting' => true, - 'no_multiline_whitespace_before_semicolons' => true, + 'multiline_whitespace_before_semicolons' => true, 'no_superfluous_elseif' => true, 'no_superfluous_phpdoc_tags' => false, 'no_useless_else' => true, @@ -41,3 +41,23 @@ ->setFinder($finder) ->setUsingCache(true) ->setRiskyAllowed(true); +; + +// special handling of fabbot.io service if it's using too old PHP CS Fixer version +if (false !== getenv('FABBOT_IO')) { + try { + PhpCsFixer\FixerFactory::create() + ->registerBuiltInFixers() + ->registerCustomFixers($config->getCustomFixers()) + ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules())) + ; + } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) { + $config->setRules([]); + } catch (UnexpectedValueException $e) { + $config->setRules([]); + } catch (InvalidArgumentException $e) { + $config->setRules([]); + } +} + +return $config; diff --git a/composer.json b/composer.json index 629cf83..d5fe5e9 100644 --- a/composer.json +++ b/composer.json @@ -5,11 +5,11 @@ "type": "library", "license": "BSD-3-Clause", "require": { - "php": "^7.4", + "php": "^7.4 || ^8.0", "doctrine/collections": "^1.6" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", + "friendsofphp/php-cs-fixer": "^3.6", "monolog/monolog": "^2.0", "phpstan/phpstan": "^0.12", "phpunit/phpunit": "^8.5" @@ -25,8 +25,8 @@ } }, "scripts": { - "lint": "php-cs-fixer fix --verbose --show-progress=estimating", - "lint:check": "php-cs-fixer fix --dry-run --verbose --show-progress=estimating", + "lint": "php-cs-fixer fix --verbose --show-progress=dots", + "lint:check": "php-cs-fixer fix --dry-run --verbose --show-progress=dots", "phpunit": "phpunit", "phpstan": "phpstan analyze", "test": [ diff --git a/src/Type/Collection/FixedTypedCollection.php b/src/Type/Collection/FixedTypedCollection.php index 5de60b3..482a948 100644 --- a/src/Type/Collection/FixedTypedCollection.php +++ b/src/Type/Collection/FixedTypedCollection.php @@ -104,12 +104,11 @@ public function matching(Criteria $criteria) if ($orderings = $criteria->getOrderings()) { $next = null; foreach (array_reverse($orderings) as $field => $ordering) { - $next = ClosureExpressionVisitor::sortByField((string) $field, $ordering == 'DESC' ? -1 : 1, $next); + $ordering = $ordering == 'DESC' ? -1 : 1; + $next = ClosureExpressionVisitor::sortByField((string) $field, $ordering, $next); } - if ($next) { - usort($filtered, $next); - } + usort($filtered, $next); } $offset = $criteria->getFirstResult();