Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/buid_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/configured_fixer.yaml
Original file line number Diff line number Diff line change
@@ -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 '<?php $%s=1;\n' 'x' > build/nested/some_file.php
cat > build/configured-fixer-ecs.php <<'PHP'
<?php
declare(strict_types=1);
return \Symplify\EasyCodingStandard\Config\ECSConfig::configure()
->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'
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
"psr-4": {
"Symplify\\EasyCodingStandard\\": "src",
"Symplify\\CodingStandard\\": "packages/coding-standard/src"
}
},
"classmap": [
"stubs"
]
},
"autoload-dev": {
"psr-4": {
Expand Down
22 changes: 22 additions & 0 deletions stubs/symfony-console-application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\Console;

/**
* ECS replaces "symfony/console" with its own console, so this class is never installed.
* Yet php-cs-fixer's Application extends it, and PHP must resolve the parent class before
* PhpCsFixer\Console\Application::getMajorVersion() can be called - which ConfigurableFixerTrait
* does for every fixer configured with a deprecated option.
*
* Only the class declaration is needed, as ECS never runs the php-cs-fixer console.
*
* @see https://github.com/ecsphp/ecs-src/issues/44
*/
class Application
{
public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
{
}
}
Loading