Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Code Analysis

on:
pull_request: null
push:
branches:
- main

jobs:
rector_analysis:
name: Rector analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: 8.4
extensions: json, mbstring, pdo, curl, pdo_sqlite
coverage: none
tools: symfony-cli, composer:v2.8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: composer install --no-progress --ansi

- run: vendor/bin/rector process -n --no-progress-bar --ansi

code_analysis:
strategy:
fail-fast: false
matrix:
php-version: ['8.2', '8.3', '8.4']
actions:
-
name: Coding Standard
# tip: add "--ansi" to commands in CI to make them full of colors
run: vendor/bin/ecs check src --ansi

-
name: PHPStan
run: vendor/bin/phpstan analyse --ansi

-
name: Check composer.json and composer.lock
run: composer validate --strict --ansi

name: ${{ matrix.actions.name }} - PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
# see https://github.com/shivammathur/setup-php
- uses: shivammathur/setup-php@v2
with:
# test the lowest version, to make sure checks pass on it
php-version: ${{ matrix.php-version }}
extensions: json, mbstring, pdo, curl, pdo_sqlite
coverage: none
tools: symfony-cli, composer:v2.8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: composer install --no-progress --ansi

- run: ${{ matrix.actions.run }}
20 changes: 17 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
}
],
"require": {
"php": ">=7.2.9"
"php": ">=8.2"
},
"require-dev": {
"bolt/core": "^5.0",
"symplify/easy-coding-standard": "^7.0"
"bolt/core": "^6.0",
"phpstan/extension-installer": "1.4.3",
"phpstan/phpstan": "2.1.31",
"phpstan/phpstan-deprecation-rules": "2.0.3",
"rector/rector": "2.2.7",
"symplify/easy-coding-standard": "^13.0"
},
"autoload": {
"psr-4": {
Expand All @@ -24,9 +28,19 @@
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-main": "3.0.x-dev"
},
"entrypoint": "Bolt\\Article\\Extension",
"screenshots": [
"screenshots/article.png"
]
},
"config": {
"allow-plugins": {
"symfony/flex": false,
"drupol/composer-packages": false,
"phpstan/extension-installer": true
}
}
}
2 changes: 1 addition & 1 deletion config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
article_extension_controllers:
resource: '../../vendor/bolt/article/src/Controller/'
prefix: '%bolt.backend_url%/async'
type: annotation
type: attribute
2 changes: 1 addition & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ doctrine:
mappings:
Article:
is_bundle: false
type: annotation
type: attribute
dir: '%kernel.project_dir%/vendor/bolt/article/src/Entity'
prefix: 'Bolt\Article'
alias: Article
103 changes: 0 additions & 103 deletions easy-coding-standard.yml

This file was deleted.

127 changes: 127 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use PhpCsFixer\Fixer\Alias\MbStrFunctionsFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer;
use PhpCsFixer\Fixer\Basic\BracesFixer;
use PhpCsFixer\Fixer\CastNotation\LowercaseCastFixer;
use PhpCsFixer\Fixer\CastNotation\ShortScalarCastFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\ClassNotation\FinalInternalClassFixer;
use PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer;
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer;
use PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer;
use PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer;
use PhpCsFixer\Fixer\Import\NoLeadingImportSlashFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
use PhpCsFixer\Fixer\Operator\NewWithBracesFixer;
use PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer;
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMethodCasingFixer;
use PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer;
use PhpCsFixer\Fixer\Whitespace\NoTrailingWhitespaceFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer;
use Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDefaultCommentFixer;
use Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/ecs.php',
])
->withCache('var/cache/ecs')
->withPreparedSets(psr12: true, common: true, cleanCode: true)
->withSkip([
OrderedClassElementsFixer::class => null,
YodaStyleFixer::class => null,
IncrementStyleFixer::class => null,
PhpdocAnnotationWithoutDotFixer::class => null,
PhpdocSummaryFixer::class => null,
PhpdocAlignFixer::class => null,
NativeConstantInvocationFixer::class => null,
NativeFunctionInvocationFixer::class => null,
UnaryOperatorSpacesFixer::class => null,
ArrayOpenerAndCloserNewlineFixer::class => null,
ArrayListItemNewlineFixer::class => null,
])
->withRules([
StandaloneLineInMultilineArrayFixer::class,
BlankLineAfterStrictTypesFixer::class,
RemoveUselessDefaultCommentFixer::class,
PhpUnitMethodCasingFixer::class,
FinalInternalClassFixer::class,
MbStrFunctionsFixer::class,
LowercaseCastFixer::class,
ShortScalarCastFixer::class,
BlankLineAfterOpeningTagFixer::class,
NoLeadingImportSlashFixer::class,
NewWithBracesFixer::class,
NoBlankLinesAfterClassOpeningFixer::class,
TernaryOperatorSpacesFixer::class,
ReturnTypeDeclarationFixer::class,
NoTrailingWhitespaceFixer::class,
NoSinglelineWhitespaceBeforeSemicolonsFixer::class,
NoWhitespaceBeforeCommaInArrayFixer::class,
WhitespaceAfterCommaInArrayFixer::class,
FullyQualifiedStrictTypesFixer::class,
])
->withConfiguredRule(PhpdocToReturnTypeFixer::class, ['union_types' => false])
->withConfiguredRule(NoSuperfluousPhpdocTagsFixer::class, ['remove_inheritdoc' => false])
->withConfiguredRule(
ConcatSpaceFixer::class,
['spacing' => 'one']
)
->withConfiguredRule(
OrderedImportsFixer::class,
[
'imports_order' => ['class', 'const', 'function'],
]
)
->withConfiguredRule(
DeclareEqualNormalizeFixer::class,
['space' => 'none']
)
->withConfiguredRule(
BracesFixer::class,
[
'allow_single_line_closure' => false,
'position_after_functions_and_oop_constructs' => 'next',
'position_after_control_structures' => 'same',
'position_after_anonymous_constructs' => 'same',
]
)
->withConfiguredRule(
VisibilityRequiredFixer::class,
[
'elements' => ['const', 'method', 'property'],
]
)
->withConfiguredRule(
PhpdocLineSpanFixer::class,
['property' => 'single']
)
->withConfiguredRule(
ClassAttributesSeparationFixer::class,
['elements' => ['property' => 'none', 'method' => 'one', 'const' => 'none']]
);
8 changes: 8 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
level: 8

paths:
- src

treatPhpDocTypesAsCertain: false
reportUnmatchedIgnoredErrors: true
26 changes: 26 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withCache('./var/cache/rector', FileCacheStorage::class)
->withPaths(['./src'])
->withImportNames()
->withParallel(timeoutSeconds: 180, jobSize: 10)
->withPhpSets()
->withPreparedSets(
typeDeclarations: true,
symfonyCodeQuality: true,
)
->withComposerBased(
twig: true,
doctrine: true,
phpunit: true,
symfony: true,
)
->withSkip([
Rector\Symfony\CodeQuality\Rector\Class_\InlineClassRoutePrefixRector::class
]);
Loading