Skip to content

Commit

Permalink
Bump to php-cs-fixer v3.43
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Dec 29, 2023
1 parent bd16b8e commit ff0d62d
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 60 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
jobs:
main:
name: Build [PHP ${{ matrix.php-version }}]
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand All @@ -46,22 +46,25 @@ jobs:
run: composer validate --strict

- name: Get composer cache directory
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV
id: composer-cache
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_FILES_DIR }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_DIR }}
key: composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-${{ matrix.php-version }}
composer-
- name: Install dependencies
run: |
composer config --global github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
composer update --ansi
- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --using-cache=no
run: vendor/bin/php-cs-fixer check --ansi --verbose --diff

- name: Run PHPStan Static Analysis Check
run: vendor/bin/phpstan analyse --ansi --verbose
Expand Down
6 changes: 4 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

$finder = Finder::create()
->files()
->in(__DIR__)
->exclude(['build'])
->in([
__DIR__.'/src',
__DIR__.'/tests',
])
->append([__FILE__])
;

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"php": "^8.1",
"ext-tokenizer": "*",
"friendsofphp/php-cs-fixer": "^3.35"
"friendsofphp/php-cs-fixer": "^3.43"
},
"require-dev": {
"nexusphp/tachycardia": "^1.4",
Expand Down
52 changes: 24 additions & 28 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
<?php

declare(strict_types=1);

/**
* This file is part of Nexus CS Config.
*
* (c) 2020 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
'message' => '#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with arguments "\\\\n", string and string will always evaluate to true\\.$#',
'count' => 1,
'path' => __DIR__.'/src/Test/AbstractCustomFixerTestCase.php',
'message' => '#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with arguments "\\\\n", string and string will always evaluate to true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Test/AbstractCustomFixerTestCase.php',
];
$ignoreErrors[] = [
'message' => '#^Method Nexus\\\\CsConfig\\\\Test\\\\AbstractCustomFixerTestCase\\:\\:getLinter\\(\\) should return PhpCsFixer\\\\Linter\\\\LinterInterface but returns mixed\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Test/AbstractCustomFixerTestCase.php',
];
$ignoreErrors[] = [
'message' => '#^Method Nexus\\\\CsConfig\\\\Test\\\\AbstractCustomFixerTestCase\\:\\:getLinter\\(\\) should return PhpCsFixer\\\\Linter\\\\LinterInterface but returns mixed\\.$#',
'count' => 1,
'path' => __DIR__.'/src/Test/AbstractCustomFixerTestCase.php',
'message' => '#^Cannot access offset \'header\' on array\\<string, mixed\\>\\|bool\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/FactoryTest.php',
];
$ignoreErrors[] = [
'message' => '#^Only numeric types are allowed in pre\\-increment, int\\<0, max\\>\\|false given\\.$#',
'count' => 1,
'path' => __DIR__.'/src/Test/AbstractCustomFixerTestCase.php',
'message' => '#^Method Nexus\\\\CsConfig\\\\Tests\\\\Fixer\\\\Comment\\\\NoCodeSeparatorCommentFixerTest\\:\\:provideFixCases\\(\\) return type has no value type specified in iterable type iterable\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/Fixer/Comment/NoCodeSeparatorCommentFixerTest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'header\' on array\\<string, mixed\\>\\|bool\\.$#',
'count' => 1,
'path' => __DIR__.'/tests/FactoryTest.php',
'message' => '#^Method Nexus\\\\CsConfig\\\\Tests\\\\Fixer\\\\Comment\\\\SpaceAfterCommentStartFixerTest\\:\\:provideFixCases\\(\\) return type has no value type specified in iterable type iterable\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/Fixer/Comment/SpaceAfterCommentStartFixerTest.php',
];
$ignoreErrors[] = [
'message' => '#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEmpty\\(\\) with non\\-empty\\-array will always evaluate to false\\.$#',
'count' => 1,
'path' => __DIR__.'/tests/Test/FixerProviderTest.php',
'message' => '#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEmpty\\(\\) with non\\-empty\\-array will always evaluate to false\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/Test/FixerProviderTest.php',
];
$ignoreErrors[] = [
'message' => '#^Method \\S+Test\\:\\:\\S+ return type has no value type specified in iterable type iterable\\.$#',
'message' => '#^Method Nexus\\\\CsConfig\\\\Tests\\\\Test\\\\FixerProviderTest\\:\\:provideCreateMethodGivesNoDeprecatedBuiltInFixersCases\\(\\) return type has no value type specified in iterable type iterable\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/Test/FixerProviderTest.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
33 changes: 26 additions & 7 deletions src/Ruleset/Nexus80.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function __construct()
'space_before_parenthesis' => true,
'inline_constructor_arguments' => true,
],
'class_keyword' => true,
'class_reference_name_casing' => true,
'clean_namespace' => true,
'combine_consecutive_issets' => true,
Expand Down Expand Up @@ -151,7 +152,25 @@ public function __construct()
'fopen_flag_order' => true,
'fopen_flags' => ['b_mode' => true],
'full_opening_tag' => true,
'fully_qualified_strict_types' => ['leading_backslash_in_global_namespace' => false],
'fully_qualified_strict_types' => [
'import_symbols' => false,
'leading_backslash_in_global_namespace' => false,
'phpdoc_tags' => [
'param',
'phpstan-param',
'phpstan-property',
'phpstan-property-read',
'phpstan-property-write',
'phpstan-return',
'phpstan-var',
'property',
'property-read',
'property-write',
'return',
'throws',
'var',
],
],
'function_declaration' => [
'closure_function_spacing' => 'one',
'closure_fn_spacing' => 'none',
Expand Down Expand Up @@ -518,10 +537,10 @@ public function __construct()
'phpdoc_summary' => true,
'phpdoc_tag_casing' => ['tags' => ['inheritDoc']],
'phpdoc_tag_type' => ['tags' => ['inheritDoc' => 'inline']],
'phpdoc_to_comment' => ['ignored_tags' => [
'phpstan-var',
'phpstan-return',
]],
'phpdoc_to_comment' => [
'allow_before_return_statement' => true,
'ignored_tags' => [],
],
'phpdoc_to_param_type' => ['scalar_types' => true],
'phpdoc_to_property_type' => ['scalar_types' => true],
'phpdoc_to_return_type' => ['scalar_types' => true],
Expand Down Expand Up @@ -638,7 +657,7 @@ public function __construct()
'spaces_inside_parentheses' => ['space' => 'none'],
'standardize_increment' => true,
'standardize_not_equals' => true,
'statement_indentation' => true,
'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => true],
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
Expand All @@ -657,7 +676,7 @@ public function __construct()
'trim_array_spaces' => true,
'type_declaration_spaces' => ['elements' => ['function', 'property']],
'types_spaces' => ['space' => 'none', 'space_multiple_catch' => null],
'unary_operator_spaces' => true,
'unary_operator_spaces' => ['only_dec_inc' => false],
'use_arrow_functions' => true,
'visibility_required' => ['elements' => ['const', 'method', 'property']],
'void_return' => true,
Expand Down
33 changes: 26 additions & 7 deletions src/Ruleset/Nexus81.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function __construct()
'space_before_parenthesis' => true,
'inline_constructor_arguments' => true,
],
'class_keyword' => true,
'class_reference_name_casing' => true,
'clean_namespace' => true,
'combine_consecutive_issets' => true,
Expand Down Expand Up @@ -151,7 +152,25 @@ public function __construct()
'fopen_flag_order' => true,
'fopen_flags' => ['b_mode' => true],
'full_opening_tag' => true,
'fully_qualified_strict_types' => ['leading_backslash_in_global_namespace' => false],
'fully_qualified_strict_types' => [
'import_symbols' => false,
'leading_backslash_in_global_namespace' => false,
'phpdoc_tags' => [
'param',
'phpstan-param',
'phpstan-property',
'phpstan-property-read',
'phpstan-property-write',
'phpstan-return',
'phpstan-var',
'property',
'property-read',
'property-write',
'return',
'throws',
'var',
],
],
'function_declaration' => [
'closure_function_spacing' => 'one',
'closure_fn_spacing' => 'none',
Expand Down Expand Up @@ -518,10 +537,10 @@ public function __construct()
'phpdoc_summary' => true,
'phpdoc_tag_casing' => ['tags' => ['inheritDoc']],
'phpdoc_tag_type' => ['tags' => ['inheritDoc' => 'inline']],
'phpdoc_to_comment' => ['ignored_tags' => [
'phpstan-var',
'phpstan-return',
]],
'phpdoc_to_comment' => [
'allow_before_return_statement' => true,
'ignored_tags' => [],
],
'phpdoc_to_param_type' => ['scalar_types' => true],
'phpdoc_to_property_type' => ['scalar_types' => true],
'phpdoc_to_return_type' => ['scalar_types' => true],
Expand Down Expand Up @@ -638,7 +657,7 @@ public function __construct()
'spaces_inside_parentheses' => ['space' => 'none'],
'standardize_increment' => true,
'standardize_not_equals' => true,
'statement_indentation' => true,
'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => true],
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
Expand All @@ -657,7 +676,7 @@ public function __construct()
'trim_array_spaces' => true,
'type_declaration_spaces' => ['elements' => ['function', 'property']],
'types_spaces' => ['space' => 'none', 'space_multiple_catch' => null],
'unary_operator_spaces' => true,
'unary_operator_spaces' => ['only_dec_inc' => false],
'use_arrow_functions' => true,
'visibility_required' => ['elements' => ['const', 'method', 'property']],
'void_return' => true,
Expand Down
33 changes: 26 additions & 7 deletions src/Ruleset/Nexus82.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function __construct()
'space_before_parenthesis' => true,
'inline_constructor_arguments' => true,
],
'class_keyword' => true,
'class_reference_name_casing' => true,
'clean_namespace' => true,
'combine_consecutive_issets' => true,
Expand Down Expand Up @@ -151,7 +152,25 @@ public function __construct()
'fopen_flag_order' => true,
'fopen_flags' => ['b_mode' => true],
'full_opening_tag' => true,
'fully_qualified_strict_types' => ['leading_backslash_in_global_namespace' => false],
'fully_qualified_strict_types' => [
'import_symbols' => false,
'leading_backslash_in_global_namespace' => false,
'phpdoc_tags' => [
'param',
'phpstan-param',
'phpstan-property',
'phpstan-property-read',
'phpstan-property-write',
'phpstan-return',
'phpstan-var',
'property',
'property-read',
'property-write',
'return',
'throws',
'var',
],
],
'function_declaration' => [
'closure_function_spacing' => 'one',
'closure_fn_spacing' => 'none',
Expand Down Expand Up @@ -518,10 +537,10 @@ public function __construct()
'phpdoc_summary' => true,
'phpdoc_tag_casing' => ['tags' => ['inheritDoc']],
'phpdoc_tag_type' => ['tags' => ['inheritDoc' => 'inline']],
'phpdoc_to_comment' => ['ignored_tags' => [
'phpstan-var',
'phpstan-return',
]],
'phpdoc_to_comment' => [
'allow_before_return_statement' => true,
'ignored_tags' => [],
],
'phpdoc_to_param_type' => ['scalar_types' => true],
'phpdoc_to_property_type' => ['scalar_types' => true],
'phpdoc_to_return_type' => ['scalar_types' => true],
Expand Down Expand Up @@ -638,7 +657,7 @@ public function __construct()
'spaces_inside_parentheses' => ['space' => 'none'],
'standardize_increment' => true,
'standardize_not_equals' => true,
'statement_indentation' => true,
'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => true],
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
Expand All @@ -657,7 +676,7 @@ public function __construct()
'trim_array_spaces' => true,
'type_declaration_spaces' => ['elements' => ['function', 'property']],
'types_spaces' => ['space' => 'none', 'space_multiple_catch' => null],
'unary_operator_spaces' => true,
'unary_operator_spaces' => ['only_dec_inc' => false],
'use_arrow_functions' => true,
'visibility_required' => ['elements' => ['const', 'method', 'property']],
'void_return' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Test/AbstractCustomFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ final public function testFixerDefinitions(): void

self::assertFalse(
$duplicatedCodeSample,
sprintf('[%s] Sample #%d duplicates #%d.', $fixerName, $counter, ++$duplicatedCodeSample),
sprintf('[%s] Sample #%d duplicates #%d.', $fixerName, $counter, (int) $duplicatedCodeSample + 1),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testFactoryThrowsExceptionOnIncompatibleVersionId(): void
->willReturn(\PHP_VERSION_ID + 2)
;

$this->expectException('RuntimeException');
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage(sprintf(
'The "%s" ruleset requires a minimum PHP_VERSION_ID of "%d" but current PHP_VERSION_ID is "%d".',
$ruleset->getName(),
Expand Down

0 comments on commit ff0d62d

Please sign in to comment.