Skip to content

Commit 86ef910

Browse files
authored
fix(global): Allow Symfony 7 (#17)
* fix (global): Allow Symfony 7 * fix(global): Psalm fixes * only check code standards in latest php version * fixed deprecated set-output
1 parent f6020d9 commit 86ef910

File tree

12 files changed

+159
-124
lines changed

12 files changed

+159
-124
lines changed

.github/workflows/main.yml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php-version: [8.0, 8.1]
11+
php-version: [8.0, 8.1, 8.2, 8.3]
1212
dependency-version: [prefer-lowest, prefer-stable]
1313
steps:
1414
- name: 'Checkout'
15-
uses: 'actions/checkout@v2'
15+
uses: 'actions/checkout@v4'
1616

1717
- name: 'Install PHP'
1818
uses: 'shivammathur/setup-php@v2'
@@ -21,13 +21,12 @@ jobs:
2121
php-version: '${{ matrix.php-version }}'
2222

2323
- name: 'Get composer cache directory'
24-
id: composercache
25-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
24+
run: echo "composer_cache=$(composer config cache-files-dir)" >> $GITHUB_ENV
2625

2726
- name: 'Cache dependencies'
28-
uses: actions/cache@v2
27+
uses: actions/cache@v3
2928
with:
30-
path: ${{ steps.composercache.outputs.dir }}
29+
path: ${{ env.composer_cache }}
3130
key: deps-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}-dep-${{ matrix.dependency-version }}
3231

3332
- name: 'Install dependencies'
@@ -41,12 +40,12 @@ jobs:
4140

4241
strategy:
4342
matrix:
44-
php-version: [ 8.0, 8.1 ]
43+
php-version: [8.0, 8.1, 8.2, 8.3]
4544
dependency-version: [ prefer-lowest, prefer-stable ]
4645

4746
steps:
4847
- name: 'Checkout'
49-
uses: 'actions/checkout@v2'
48+
uses: 'actions/checkout@v4'
5049

5150
- name: 'Install PHP'
5251
uses: 'shivammathur/setup-php@v2'
@@ -56,20 +55,50 @@ jobs:
5655
tools: cs2pr
5756

5857
- name: 'Get composer cache directory'
59-
id: composercache
60-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
58+
run: echo "composer_cache=$(composer config cache-files-dir)" >> $GITHUB_ENV
6159

6260
- name: 'Cache dependencies'
63-
uses: actions/cache@v2
61+
uses: actions/cache@v3
6462
with:
65-
path: ${{ steps.composercache.outputs.dir }}
63+
path: ${{ env.composer_cache }}
6664
key: deps-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}-dep-${{ matrix.dependency-version }}
6765

6866
- name: 'Install dependencies'
6967
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
7068

71-
- name: 'Check code standards'
72-
run: ./vendor/bin/ecs check
73-
7469
- name: 'Psalm'
7570
run: ./vendor/bin/psalm
71+
72+
code-standards:
73+
runs-on: ubuntu-latest
74+
75+
strategy:
76+
matrix:
77+
php-version: [8.3]
78+
dependency-version: [ prefer-lowest, prefer-stable ]
79+
80+
steps:
81+
- name: 'Checkout'
82+
uses: 'actions/checkout@v4'
83+
84+
- name: 'Install PHP'
85+
uses: 'shivammathur/setup-php@v2'
86+
with:
87+
coverage: 'none'
88+
php-version: '${{ matrix.php-version }}'
89+
tools: cs2pr
90+
91+
- name: 'Get composer cache directory'
92+
run: echo "composer_cache=$(composer config cache-files-dir)" >> $GITHUB_ENV
93+
94+
- name: 'Cache dependencies'
95+
uses: actions/cache@v3
96+
with:
97+
path: ${{ env.composer_cache }}
98+
key: deps-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}-dep-${{ matrix.dependency-version }}
99+
100+
- name: 'Install dependencies'
101+
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
102+
103+
- name: 'Check code standards'
104+
run: ./vendor/bin/ecs check

composer.json

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
"description": "Monorepo for Secretary's PHP implementation",
44
"type": "library",
55
"require-dev": {
6-
"aws/aws-sdk-php": "^3.91",
6+
"php": "^8.0",
77
"ext-json": "*",
8+
"aws/aws-sdk-php": "^3.91",
89
"guzzlehttp/guzzle": "^7.0",
910
"mockery/mockery": "^1.4",
10-
"php": "^8.0",
11-
"phpunit/phpunit": "^9.0",
12-
"psr/simple-cache": "^1.0 || ^2.0",
13-
"symfony/config": "^5.3 || ^6.0",
14-
"symfony/dependency-injection": "^5.0 || ^6.0",
15-
"symfony/framework-bundle": "^5.0 || ^6.0",
16-
"symfony/http-kernel": "^5.0 || ^6.0",
17-
"symfony/options-resolver": "^5.4 || ^6.0",
18-
"symfony/yaml": "^5.0 || ^6.0",
19-
"symplify/easy-coding-standard": "^10.0.10",
20-
"vimeo/psalm": "^4.20"
11+
"phpunit/phpunit": "^9.0 || ^10.0",
12+
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
13+
"symfony/config": "^5.3 || ^6.0 || ^7.0",
14+
"symfony/dependency-injection": "^5.0 || ^6.0 || ^7.0",
15+
"symfony/framework-bundle": "^5.0 || ^6.0 || ^7.0",
16+
"symfony/http-kernel": "^5.0 || ^6.0 || ^7.0",
17+
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0",
18+
"symfony/yaml": "^5.0 || ^6.0 || ^7.0",
19+
"symplify/easy-coding-standard": "^12",
20+
"vimeo/psalm": "^5"
2121
},
2222
"license": "MIT",
2323
"authors": [
@@ -36,9 +36,14 @@
3636
"**/Tests/"
3737
]
3838
},
39+
"config": {
40+
"preferred-install": {
41+
"*": "dist"
42+
},
43+
"sort-packages": true
44+
},
3945
"scripts": {
4046
"ecs": "ecs check",
41-
"ecs:show": "ecs show",
4247
"ecs:fix": "ecs check --fix",
4348
"psalm": "psalm --show-info"
4449
}

ecs.php

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,34 @@
66
use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer;
77
use PhpCsFixer\Fixer\ControlStructure\{NoUselessElseFixer, YodaStyleFixer};
88
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
9+
use PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer;
10+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
911
use PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer;
1012
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
13+
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
1114
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
15+
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
1216
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer;
1317
use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer;
1418
use PhpCsFixer\Fixer\ReturnNotation\ReturnAssignmentFixer;
1519
use PhpCsFixer\Fixer\Semicolon\MultilineWhitespaceBeforeSemicolonsFixer;
1620
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
17-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
18-
use Symplify\EasyCodingStandard\ValueObject\Option;
21+
use Symplify\EasyCodingStandard\Config\ECSConfig;
1922
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
2023

2124
/**
2225
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/list.rst
2326
* @see https://github.com/symplify/easy-coding-standard
2427
*/
25-
return function (ContainerConfigurator $containerConfigurator): void {
26-
$parameters = $containerConfigurator->parameters();
27-
$parameters->set(Option::CACHE_DIRECTORY, __DIR__.'/.ecs_cache');
28-
$parameters->set(Option::PATHS, [
28+
return function (ECSConfig $ecsConfig): void {
29+
$ecsConfig->cacheDirectory(__DIR__.'/.ecs_cache');
30+
$ecsConfig->parallel();
31+
32+
$ecsConfig->paths([
2933
__DIR__.'/src',
3034
]);
31-
$parameters->set(Option::SKIP, [
35+
36+
$ecsConfig->skip([
3237
IsNullFixer::class,
3338
MultilineWhitespaceBeforeSemicolonsFixer::class,
3439
NativeFunctionInvocationFixer::class,
@@ -38,50 +43,54 @@
3843
PhpdocNoPackageFixer::class,
3944
]);
4045

41-
$containerConfigurator->import(SetList::PSR_12);
42-
$containerConfigurator->import(SetList::SYMFONY);
43-
$containerConfigurator->import(SetList::PHP_CS_FIXER);
44-
$containerConfigurator->import(SetList::SYMFONY_RISKY);
46+
$ecsConfig->sets([
47+
SetList::PSR_12,
48+
]);
4549

46-
$services = $containerConfigurator->services();
47-
$services->set(NoUselessReturnFixer::class);
48-
$services->set(NoUselessElseFixer::class);
49-
$services->set(ModernizeStrposFixer::class);
50-
$services->set(IncrementStyleFixer::class)
51-
->call('configure', [[
52-
'style' => 'post',
53-
]]);
50+
$ecsConfig->rules([
51+
NoUselessReturnFixer::class,
52+
NoUselessElseFixer::class,
53+
ModernizeStrposFixer::class,
54+
NoUnusedImportsFixer::class,
55+
NoSuperfluousPhpdocTagsFixer::class,
56+
ReturnTypeDeclarationFixer::class,
57+
]);
5458

55-
$services->set(ClassAttributesSeparationFixer::class)
56-
->call('configure', [[
57-
'elements' => ['const' => 'only_if_meta', 'method' => 'one', 'property' => 'one', 'trait_import' => 'only_if_meta'],
58-
]]);
59+
$ecsConfig->ruleWithConfiguration(ConcatSpaceFixer::class, [
60+
'spacing' => 'none',
61+
]);
5962

60-
$services->set(BlankLineBeforeStatementFixer::class)
61-
->call('configure', [[
62-
'statements' => ['if', 'break', 'continue', 'declare', 'return', 'throw', 'try', 'switch'],
63-
]]);
63+
$ecsConfig->ruleWithConfiguration(IncrementStyleFixer::class, [
64+
'style' => 'post'
65+
]);
6466

65-
$services->set(BinaryOperatorSpacesFixer::class)
66-
->call('configure', [[
67-
'default' => 'align_single_space_minimal',
68-
'operators' => [
69-
'|' => 'no_space',
70-
'/' => null,
71-
'*' => null,
72-
'||' => null,
73-
'&&' => null,
74-
],
75-
]]);
67+
$ecsConfig->ruleWithConfiguration(ClassAttributesSeparationFixer::class, [
68+
'elements' => ['const' => 'only_if_meta', 'method' => 'one', 'property' => 'one', 'trait_import' => 'only_if_meta'],
69+
]);
70+
71+
72+
$ecsConfig->ruleWithConfiguration(BlankLineBeforeStatementFixer::class, [
73+
'statements' => ['if', 'break', 'continue', 'declare', 'return', 'throw', 'try', 'switch'],
74+
]);
75+
76+
$ecsConfig->ruleWithConfiguration(BinaryOperatorSpacesFixer::class, [
77+
'default' => 'align_single_space_minimal',
78+
'operators' => [
79+
'|' => 'no_space',
80+
'/' => null,
81+
'*' => null,
82+
'||' => null,
83+
'&&' => null,
84+
],
85+
]);
7686

7787
$header = <<<'EOF'
7888
@author Aaron Scherer <aequasi@gmail.com>
7989
@date 2019
8090
@license https://opensource.org/licenses/MIT
8191
EOF;
8292

83-
$services->set(HeaderCommentFixer::class)
84-
->call('configure', [
85-
['header' => $header,
86-
]]);
93+
$ecsConfig->ruleWithConfiguration(HeaderCommentFixer::class, [
94+
'header' => $header
95+
]);
8796
};

src/Adapter/AWS/SecretsManager/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"secretary/core": "self.version"
2424
},
2525
"require-dev": {
26-
"mockery/mockery": "^1.4",
27-
"phpunit/phpunit": "^9.0"
26+
"phpunit/phpunit": "^9.0 || ^10.0",
27+
"mockery/mockery": "^1.4"
2828
},
2929
"autoload": {
3030
"psr-4": {

src/Adapter/Cache/PSR16Cache/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"minimum-stability": "stable",
1919
"require": {
2020
"php": "^8.0",
21-
"psr/simple-cache": "^1.0 || ^2.0",
21+
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
2222
"secretary/core": "self.version"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^9.0",
25+
"phpunit/phpunit": "^9.0 || ^10.0",
2626
"mockery/mockery": "^1.4"
2727
},
2828
"autoload": {

src/Adapter/Cache/PSR6Cache/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"minimum-stability": "stable",
1919
"require": {
2020
"php": "^8.0",
21-
"psr/cache": "^1.0 || ^2.0",
21+
"psr/cache": "^1.0 || ^2.0 || ^3.0",
2222
"secretary/core": "self.version"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^9.0",
25+
"phpunit/phpunit": "^9.0 || ^10.0",
2626
"mockery/mockery": "^1.4"
2727
},
2828
"autoload": {

0 commit comments

Comments
 (0)