Skip to content

Commit

Permalink
Upgrade PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 3, 2024
1 parent 0e9cad7 commit f1b7647
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/php_cs.dist export-ignore
/.php-cs-fixer.dist.php export-ignore
6 changes: 3 additions & 3 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', 'latest']
type: ['Phpunit']
include:
- php: '8.0'
- php: 'latest'
type: 'CodingStyle'
- php: '8.3'
- php: 'latest'
type: 'StaticAnalysis'
steps:
- name: Checkout
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/.idea
/.php_cs
/.phpunit.result.cache
/vendor
/composer.lock
/phpunit.xml
/.phpunit.result.cache
107 changes: 107 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in([__DIR__])
->exclude(['vendor']);

return (new Config())
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,

// required by PSR-12
'concat_space' => [
'spacing' => 'one',
],

// disable some too strict rules
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
'single_line_throw' => false,
'yoda_style' => [
'equal' => false,
'identical' => false,
],
'native_constant_invocation' => true,
'native_function_invocation' => false,
'void_return' => false,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'],
],
'final_internal_class' => false,
'combine_consecutive_issets' => false,
'combine_consecutive_unsets' => false,
'multiline_whitespace_before_semicolons' => false,
'no_superfluous_elseif' => false,
'ordered_class_elements' => false,
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
'phpdoc_add_missing_param_annotation' => false,
'return_assignment' => false,
'comment_to_phpdoc' => false,
'general_phpdoc_annotation_remove' => [
'annotations' => ['author', 'copyright', 'throws'],
],

// fn => without curly brackets is less readable,
// also prevent bounding of unwanted variables for GC
'use_arrow_functions' => false,

// TODO disable too strict rules for now - remove once the CS is updated
'binary_operator_spaces' => false,
'blank_line_after_opening_tag' => false,
'blank_line_before_statement' => false,
'cast_spaces' => false,
'declare_strict_types' => false,
'explicit_string_variable' => false,
'fully_qualified_strict_types' => false,
'general_phpdoc_annotation_remove' => false,
'global_namespace_import' => false,
'increment_style' => false,
'is_null' => false,
'method_chaining_indentation' => false,
'modernize_types_casting' => false,
'native_constant_invocation' => false,
'no_extra_blank_lines' => false,
'no_superfluous_phpdoc_tags' => false,
'no_trailing_whitespace' => false,
'no_unused_imports' => false,
'no_useless_else' => false,
'operator_linebreak' => false,
'php_unit_data_provider_name' => false,
'php_unit_data_provider_return_type' => false,
'php_unit_data_provider_static' => false,
'php_unit_strict' => false,
'php_unit_test_case_static_method_calls' => false,
'phpdoc_align' => false,
'phpdoc_annotation_without_dot' => false,
'phpdoc_no_alias_tag' => false,
'phpdoc_no_empty_return' => false,
'phpdoc_order' => false,
'phpdoc_scalar' => false,
'phpdoc_separation' => false,
'phpdoc_summary' => false,
'phpdoc_to_comment' => false,
'phpdoc_trim' => false,
'phpdoc_var_without_name' => false,
'single_line_comment_style' => false,
'single_line_empty_body' => false,
'statement_indentation' => false,
'static_lambda' => false,
'strict_comparison' => false,
'trailing_comma_in_multiline' => false,
'visibility_required' => false,
'yoda_style' => false,
])
->setFinder($finder)
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');
60 changes: 0 additions & 60 deletions .php_cs.dist

This file was deleted.

9 changes: 2 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@
"ext-sysvsem": "*",
"eloquent/liberator": "^2.0",
"ergebnis/composer-normalize": "^2.13",
"friendsofphp/php-cs-fixer": "^2.16",
"johnkary/phpunit-speedtrap": "^3.0",
"friendsofphp/php-cs-fixer": "^3.0",
"mikey179/vfsstream": "^1.6.7",
"php-mock/php-mock-phpunit": "^2.1",
"phpstan/phpstan": "^0.12.58",
"phpunit/phpunit": "^9.4",
"predis/predis": "^1.1",
"spatie/async": "^1.5",
"squizlabs/php_codesniffer": "^3.3"
"spatie/async": "^1.5"
},
"suggest": {
"ext-igbinary": "To use this library with PHP Redis igbinary serializer enabled.",
Expand Down Expand Up @@ -82,8 +80,5 @@
"phpstan/extension-installer": true
},
"sort-packages": true
},
"scripts": {
"fix-cs": "vendor/bin/phpcbf --standard=PSR2 src/ tests/"
}
}
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
</listeners>
</phpunit>

0 comments on commit f1b7647

Please sign in to comment.