diff --git a/.github/workflows/buid_release.yaml b/.github/workflows/buid_release.yaml index 945a240dac..64502109af 100644 --- a/.github/workflows/buid_release.yaml +++ b/.github/workflows/buid_release.yaml @@ -50,7 +50,7 @@ jobs: - run: rm -rf tests ecs-build/packages/coding-standard/tests ecs-build/ecs.php ecs-build/phpstan.neon ecs-build/phpunit.xml ecs-build/.gitignore ecs-build/.editorconfig # 2. downgrade via Rector - - run: rector-local/vendor/bin/rector process ecs-build/bin ecs-build/config/config.php ecs-build/packages ecs-build/src ecs-build/vendor --config build/config/config-downgrade.php --ansi --no-diffs + - run: rector-local/vendor/bin/rector process ecs-build/bin ecs-build/config/config.php ecs-build/packages ecs-build/src ecs-build/stubs ecs-build/vendor --config build/config/config-downgrade.php --ansi --no-diffs # 3. prefix classes - run: | @@ -59,8 +59,8 @@ jobs: # download php-scoper wget https://github.com/humbug/php-scoper/releases/download/0.18.17/php-scoper.phar -N --no-verbose - # scope /bin, /config, /packages, /src, /vendor and composer.json - php -d memory_limit=-1 php-scoper.phar add-prefix bin config packages/coding-standard/src src vendor composer.json --output-dir ../ecs-prefixed-downgraded --config scoper.php --force --ansi --working-dir ecs-build + # scope /bin, /config, /packages, /src, /stubs, /vendor and composer.json + php -d memory_limit=-1 php-scoper.phar add-prefix bin config packages/coding-standard/src src stubs vendor composer.json --output-dir ../ecs-prefixed-downgraded --config scoper.php --force --ansi --working-dir ecs-build # dump composer autoload composer dump-autoload --working-dir ecs-prefixed-downgraded --ansi --classmap-authoritative --no-dev diff --git a/.github/workflows/configured_fixer.yaml b/.github/workflows/configured_fixer.yaml new file mode 100644 index 0000000000..35883dffe7 --- /dev/null +++ b/.github/workflows/configured_fixer.yaml @@ -0,0 +1,53 @@ +name: Configured Fixer + +# verifies https://github.com/ecsphp/ecs-src/issues/44 +# configuring a PHP-CS-Fixer fixer runs ConfigurableFixerTrait::configure(), which calls +# PhpCsFixer\Console\Application::getMajorVersion(). That class extends the Symfony console +# Application, which ECS replaces and does not ship - so the run must not fatal there. + +on: + pull_request: + push: + branches: + - main + +jobs: + configured_fixer: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + coverage: none + + - run: composer install --no-progress --ansi + + - + name: "Create a config with a configured PHP-CS-Fixer fixer" + run: | + mkdir -p build/nested + printf ' build/nested/some_file.php + cat > build/configured-fixer-ecs.php <<'PHP' + withPaths([__DIR__ . '/nested']) + ->withPreparedSets(psr12: true) + ->withConfiguredRule( + \PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer::class, + ['use_nullable_type_declaration' => false] + ); + PHP + + - + name: "ecs check must run without a fatal error" + run: | + OUTPUT="$(bin/ecs check --config=build/configured-fixer-ecs.php --no-progress-bar --ansi 2>&1 || true)" + echo "$OUTPUT" + echo "$OUTPUT" | grep -q 'some_file.php' + ! echo "$OUTPUT" | grep -q 'Fatal error' + ! echo "$OUTPUT" | grep -q 'Console\\Application" not found' diff --git a/composer.json b/composer.json index 5121355024..1ce82ecbca 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,10 @@ "psr-4": { "Symplify\\EasyCodingStandard\\": "src", "Symplify\\CodingStandard\\": "packages/coding-standard/src" - } + }, + "classmap": [ + "stubs" + ] }, "autoload-dev": { "psr-4": { diff --git a/stubs/symfony-console-application.php b/stubs/symfony-console-application.php new file mode 100644 index 0000000000..ffd4b5700c --- /dev/null +++ b/stubs/symfony-console-application.php @@ -0,0 +1,22 @@ +