Skip to content

Commit

Permalink
fix(global): Allow Symfony 7 (#17)
Browse files Browse the repository at this point in the history
* fix (global): Allow Symfony 7

* fix(global): Psalm fixes

* only check code standards in latest php version

* fixed deprecated set-output
  • Loading branch information
deluxetom authored Jan 9, 2024
1 parent f6020d9 commit 86ef910
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 124 deletions.
59 changes: 44 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:

strategy:
matrix:
php-version: [8.0, 8.1]
php-version: [8.0, 8.1, 8.2, 8.3]
dependency-version: [prefer-lowest, prefer-stable]
steps:
- name: 'Checkout'
uses: 'actions/checkout@v2'
uses: 'actions/checkout@v4'

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

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

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

- name: 'Install dependencies'
Expand All @@ -41,12 +40,12 @@ jobs:

strategy:
matrix:
php-version: [ 8.0, 8.1 ]
php-version: [8.0, 8.1, 8.2, 8.3]
dependency-version: [ prefer-lowest, prefer-stable ]

steps:
- name: 'Checkout'
uses: 'actions/checkout@v2'
uses: 'actions/checkout@v4'

- name: 'Install PHP'
uses: 'shivammathur/setup-php@v2'
Expand All @@ -56,20 +55,50 @@ jobs:
tools: cs2pr

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

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

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

- name: 'Check code standards'
run: ./vendor/bin/ecs check

- name: 'Psalm'
run: ./vendor/bin/psalm

code-standards:
runs-on: ubuntu-latest

strategy:
matrix:
php-version: [8.3]
dependency-version: [ prefer-lowest, prefer-stable ]

steps:
- name: 'Checkout'
uses: 'actions/checkout@v4'

- name: 'Install PHP'
uses: 'shivammathur/setup-php@v2'
with:
coverage: 'none'
php-version: '${{ matrix.php-version }}'
tools: cs2pr

- name: 'Get composer cache directory'
run: echo "composer_cache=$(composer config cache-files-dir)" >> $GITHUB_ENV

- name: 'Cache dependencies'
uses: actions/cache@v3
with:
path: ${{ env.composer_cache }}
key: deps-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}-dep-${{ matrix.dependency-version }}

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

- name: 'Check code standards'
run: ./vendor/bin/ecs check
31 changes: 18 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
"description": "Monorepo for Secretary's PHP implementation",
"type": "library",
"require-dev": {
"aws/aws-sdk-php": "^3.91",
"php": "^8.0",
"ext-json": "*",
"aws/aws-sdk-php": "^3.91",
"guzzlehttp/guzzle": "^7.0",
"mockery/mockery": "^1.4",
"php": "^8.0",
"phpunit/phpunit": "^9.0",
"psr/simple-cache": "^1.0 || ^2.0",
"symfony/config": "^5.3 || ^6.0",
"symfony/dependency-injection": "^5.0 || ^6.0",
"symfony/framework-bundle": "^5.0 || ^6.0",
"symfony/http-kernel": "^5.0 || ^6.0",
"symfony/options-resolver": "^5.4 || ^6.0",
"symfony/yaml": "^5.0 || ^6.0",
"symplify/easy-coding-standard": "^10.0.10",
"vimeo/psalm": "^4.20"
"phpunit/phpunit": "^9.0 || ^10.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"symfony/config": "^5.3 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.0 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.0 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.0 || ^6.0 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^5.0 || ^6.0 || ^7.0",
"symplify/easy-coding-standard": "^12",
"vimeo/psalm": "^5"
},
"license": "MIT",
"authors": [
Expand All @@ -36,9 +36,14 @@
"**/Tests/"
]
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"scripts": {
"ecs": "ecs check",
"ecs:show": "ecs show",
"ecs:fix": "ecs check --fix",
"psalm": "psalm --show-info"
}
Expand Down
93 changes: 51 additions & 42 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,34 @@
use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer;
use PhpCsFixer\Fixer\ControlStructure\{NoUselessElseFixer, YodaStyleFixer};
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer;
use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer;
use PhpCsFixer\Fixer\ReturnNotation\ReturnAssignmentFixer;
use PhpCsFixer\Fixer\Semicolon\MultilineWhitespaceBeforeSemicolonsFixer;
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

/**
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/list.rst
* @see https://github.com/symplify/easy-coding-standard
*/
return function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::CACHE_DIRECTORY, __DIR__.'/.ecs_cache');
$parameters->set(Option::PATHS, [
return function (ECSConfig $ecsConfig): void {
$ecsConfig->cacheDirectory(__DIR__.'/.ecs_cache');
$ecsConfig->parallel();

$ecsConfig->paths([
__DIR__.'/src',
]);
$parameters->set(Option::SKIP, [

$ecsConfig->skip([
IsNullFixer::class,
MultilineWhitespaceBeforeSemicolonsFixer::class,
NativeFunctionInvocationFixer::class,
Expand All @@ -38,50 +43,54 @@
PhpdocNoPackageFixer::class,
]);

$containerConfigurator->import(SetList::PSR_12);
$containerConfigurator->import(SetList::SYMFONY);
$containerConfigurator->import(SetList::PHP_CS_FIXER);
$containerConfigurator->import(SetList::SYMFONY_RISKY);
$ecsConfig->sets([
SetList::PSR_12,
]);

$services = $containerConfigurator->services();
$services->set(NoUselessReturnFixer::class);
$services->set(NoUselessElseFixer::class);
$services->set(ModernizeStrposFixer::class);
$services->set(IncrementStyleFixer::class)
->call('configure', [[
'style' => 'post',
]]);
$ecsConfig->rules([
NoUselessReturnFixer::class,
NoUselessElseFixer::class,
ModernizeStrposFixer::class,
NoUnusedImportsFixer::class,
NoSuperfluousPhpdocTagsFixer::class,
ReturnTypeDeclarationFixer::class,
]);

$services->set(ClassAttributesSeparationFixer::class)
->call('configure', [[
'elements' => ['const' => 'only_if_meta', 'method' => 'one', 'property' => 'one', 'trait_import' => 'only_if_meta'],
]]);
$ecsConfig->ruleWithConfiguration(ConcatSpaceFixer::class, [
'spacing' => 'none',
]);

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

$services->set(BinaryOperatorSpacesFixer::class)
->call('configure', [[
'default' => 'align_single_space_minimal',
'operators' => [
'|' => 'no_space',
'/' => null,
'*' => null,
'||' => null,
'&&' => null,
],
]]);
$ecsConfig->ruleWithConfiguration(ClassAttributesSeparationFixer::class, [
'elements' => ['const' => 'only_if_meta', 'method' => 'one', 'property' => 'one', 'trait_import' => 'only_if_meta'],
]);


$ecsConfig->ruleWithConfiguration(BlankLineBeforeStatementFixer::class, [
'statements' => ['if', 'break', 'continue', 'declare', 'return', 'throw', 'try', 'switch'],
]);

$ecsConfig->ruleWithConfiguration(BinaryOperatorSpacesFixer::class, [
'default' => 'align_single_space_minimal',
'operators' => [
'|' => 'no_space',
'/' => null,
'*' => null,
'||' => null,
'&&' => null,
],
]);

$header = <<<'EOF'
@author Aaron Scherer <[email protected]>
@date 2019
@license https://opensource.org/licenses/MIT
EOF;

$services->set(HeaderCommentFixer::class)
->call('configure', [
['header' => $header,
]]);
$ecsConfig->ruleWithConfiguration(HeaderCommentFixer::class, [
'header' => $header
]);
};
4 changes: 2 additions & 2 deletions src/Adapter/AWS/SecretsManager/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"secretary/core": "self.version"
},
"require-dev": {
"mockery/mockery": "^1.4",
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^9.0 || ^10.0",
"mockery/mockery": "^1.4"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/Cache/PSR16Cache/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"minimum-stability": "stable",
"require": {
"php": "^8.0",
"psr/simple-cache": "^1.0 || ^2.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"secretary/core": "self.version"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^9.0 || ^10.0",
"mockery/mockery": "^1.4"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/Cache/PSR6Cache/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"minimum-stability": "stable",
"require": {
"php": "^8.0",
"psr/cache": "^1.0 || ^2.0",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"secretary/core": "self.version"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^9.0 || ^10.0",
"mockery/mockery": "^1.4"
},
"autoload": {
Expand Down
Loading

0 comments on commit 86ef910

Please sign in to comment.