Skip to content

Commit

Permalink
feat: upgrade to php 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeojhx committed Feb 16, 2022
1 parent 55c27ac commit d39b247
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
/vendor
/phpunit.xml
/coverage.xml
/.php_cs.cache
/.php-cs-fixer.cache
/composer.lock
.phpunit.result.cache
30 changes: 25 additions & 5 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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;
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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": [
Expand Down
7 changes: 3 additions & 4 deletions src/Type/Collection/FixedTypedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d39b247

Please sign in to comment.