Skip to content

Commit

Permalink
adding php 8.0 and 8.1 fixer classes,, upgraded php-cs-fixer (#2)
Browse files Browse the repository at this point in the history
* adding php 8.0 and 8.1 fixer classes,, upgraded php-cs-fixer

* allowing 2.x version of ergebnis library for code that still needs php-cs-fixer 2.x
  • Loading branch information
jaydiablo authored Dec 6, 2021
1 parent 7aadf72 commit 09e2d6d
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor
composer.lock
.php_cs.cache
.php_cs.cache
.php-cs-fixer.cache
4 changes: 2 additions & 2 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

use Ergebnis\PhpCsFixer\Config;
use DiabloMedia\PhpCsFixer\Config\RuleSet\Php71;
use DiabloMedia\PhpCsFixer\Config\RuleSet\Php74;

$config = Config\Factory::fromRuleSet(new Php71());
$config = Config\Factory::fromRuleSet(new Php74());

$config->setCacheFile(__DIR__ . '/.php_cs.cache');
$config->getFinder()
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "library",
"description": "Convenient collection of our php-cs-fixer configs for different PHP versions",
"require": {
"ergebnis/php-cs-fixer-config": "^2.0"
"ergebnis/php-cs-fixer-config": "^2.0 || ^3.0"
},
"autoload": {
"psr-4": {
Expand All @@ -18,6 +18,6 @@
}
],
"require-dev": {
"friendsofphp/php-cs-fixer": "2.18.3"
"friendsofphp/php-cs-fixer": "3.3.2"
}
}
3 changes: 1 addition & 2 deletions src/RuleSet/Php71.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class Php71 extends AbstractRuleSet
'method_protected',
'method_private',
],
'sortAlgorithm' => 'alpha',
'sort_algorithm' => 'alpha',
],
'ordered_imports' => [
'imports_order' => [
Expand All @@ -65,7 +65,6 @@ final class Php71 extends AbstractRuleSet
'sort_algorithm' => 'alpha',
],
'php_unit_construct' => true,
'psr0' => true,
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => false,
'ternary_to_null_coalescing' => true,
Expand Down
3 changes: 1 addition & 2 deletions src/RuleSet/Php74.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class Php74 extends AbstractRuleSet
'method_protected',
'method_private',
],
'sortAlgorithm' => 'alpha',
'sort_algorithm' => 'alpha',
],
'ordered_imports' => [
'imports_order' => [
Expand All @@ -69,7 +69,6 @@ final class Php74 extends AbstractRuleSet
'sort_algorithm' => 'alpha',
],
'php_unit_construct' => true,
'psr0' => true,
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => false,
'ternary_to_null_coalescing' => true,
Expand Down
81 changes: 81 additions & 0 deletions src/RuleSet/Php80.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace DiabloMedia\PhpCsFixer\Config\RuleSet;

use Ergebnis\PhpCsFixer\Config\RuleSet\AbstractRuleSet;

final class Php80 extends AbstractRuleSet
{
protected $name = 'diablomedia (PHP 8.0)';

protected $rules = [
// Pre-defined rule sets
'@PSR2' => true,
'@PSR12' => true,
'@PSR12:risky' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHP73Migration' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,
'@PHP80Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
// Individual rules
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'align_single_space_minimal',
'operators' => ['||' => null, '&&' => null, '==' => null, '===' => null, '+' => null],
],
'class_attributes_separation' => true,
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => false,
'dir_constant' => true,
'lowercase_static_reference' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_leading_import_slash' => true,
'no_mixed_echo_print' => ['use' => 'echo'],
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unused_imports' => true,
'no_useless_return' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
],
'sort_algorithm' => 'alpha',
],
'ordered_imports' => [
'imports_order' => [
'const',
'class',
'function',
],
'sort_algorithm' => 'alpha',
],
'php_unit_construct' => true,
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => false,
'ternary_to_null_coalescing' => true,
];

protected $targetPhpVersion = 80000;
}
82 changes: 82 additions & 0 deletions src/RuleSet/Php81.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

namespace DiabloMedia\PhpCsFixer\Config\RuleSet;

use Ergebnis\PhpCsFixer\Config\RuleSet\AbstractRuleSet;

final class Php81 extends AbstractRuleSet
{
protected $name = 'diablomedia (PHP 8.1)';

protected $rules = [
// Pre-defined rule sets
'@PSR2' => true,
'@PSR12' => true,
'@PSR12:risky' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHP73Migration' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,
'@PHP80Migration' => true,
'@PHP80Migration:risky' => true,
'@PHP81Migration' => true,
'@PHPUnit60Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
// Individual rules
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'align_single_space_minimal',
'operators' => ['||' => null, '&&' => null, '==' => null, '===' => null, '+' => null],
],
'class_attributes_separation' => true,
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => false,
'dir_constant' => true,
'lowercase_static_reference' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_leading_import_slash' => true,
'no_mixed_echo_print' => ['use' => 'echo'],
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unused_imports' => true,
'no_useless_return' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
],
'sort_algorithm' => 'alpha',
],
'ordered_imports' => [
'imports_order' => [
'const',
'class',
'function',
],
'sort_algorithm' => 'alpha',
],
'php_unit_construct' => true,
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => false,
'ternary_to_null_coalescing' => true,
];

protected $targetPhpVersion = 80100;
}

0 comments on commit 09e2d6d

Please sign in to comment.