diff --git a/composer.json b/composer.json index 33d5173..e9a2db2 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,8 @@ ], "require": { "php": "^8.2", - "a9f/fractor": "^0.3", - "rector/rector": "^1.0", + "a9f/fractor": "^0.4", + "rector/rector": "^2.0", "symfony/config": "^6.4 || ^7.0", "symfony/console": "^6.4 || ^7.0", "symfony/dependency-injection": "^6.4 || ^7.0", @@ -23,11 +23,11 @@ }, "require-dev": { "ergebnis/composer-normalize": "^2.42", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan": "^1.10", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^11.0", "symplify/easy-coding-standard": "^12.1", - "thecodingmachine/phpstan-safe-rule": "^1.2" + "thecodingmachine/phpstan-safe-rule": "^2.0-dev" }, "autoload": { "psr-4": { diff --git a/e2e/composer.json b/e2e/composer.json index 0f49140..95d68c0 100644 --- a/e2e/composer.json +++ b/e2e/composer.json @@ -3,10 +3,10 @@ "type": "project", "require": { "a9f/lifter": "@dev", - "a9f/fractor": "^0.3", - "a9f/fractor-composer-json": "^0.3", - "a9f/fractor-doc-generator": "^0.3", - "a9f/fractor-extension-installer": "^0.3", + "a9f/fractor": "^0.4", + "a9f/fractor-composer-json": "^0.4", + "a9f/fractor-doc-generator": "^0.4", + "a9f/fractor-extension-installer": "^0.4", "symplify/rule-doc-generator-contracts": "^11.2" }, "require-dev": { diff --git a/e2e/fractor/fractor.php b/e2e/fractor/fractor.php index 61e6515..3682131 100644 --- a/e2e/fractor/fractor.php +++ b/e2e/fractor/fractor.php @@ -1,7 +1,6 @@ withPaths([__DIR__ . '/result/**']); \ No newline at end of file diff --git a/e2e/fractor/lifter.php b/e2e/fractor/lifter.php index 8711ed7..40133d9 100644 --- a/e2e/fractor/lifter.php +++ b/e2e/fractor/lifter.php @@ -17,13 +17,13 @@ new FractorStep( 'Update phpunit/phpunit to 11.x', static function (FractorConfigurationBuilder $fractorConfig) { - $fractorConfig->withPaths([__DIR__ . '/result/**']); - $fractorConfig->withConfiguredRule( - ChangePackageVersionComposerJsonFractor::class, - [ - new PackageAndVersion('phpunit/phpunit', '^11.2') - ] - ); + return $fractorConfig + ->withConfiguredRule( + ChangePackageVersionComposerJsonFractor::class, + [ + new PackageAndVersion('phpunit/phpunit', '^11.2') + ] + ); } ) ]); diff --git a/e2e/rector/expected-output.txt b/e2e/rector/expected-output.txt index 632fde4..6d093dc 100644 --- a/e2e/rector/expected-output.txt +++ b/e2e/rector/expected-output.txt @@ -1,3 +1,3 @@ RECTOR: RECTOR: [OK] 1 file has been changed by Rector - +RECTOR: diff --git a/phpstan.neon b/phpstan.neon index fb53f61..df2971a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,4 +8,6 @@ parameters: # this is required because of our generic interface StepExecutor that we use w/o specifying a concrete subtype, # e.g. in UpgradeRunner - checkGenericClassInNonGenericObjectType: false + ignoreErrors: + - + identifier: missingType.generics diff --git a/res/run_fractor.php b/res/run_fractor.php index e05981a..4a11068 100644 --- a/res/run_fractor.php +++ b/res/run_fractor.php @@ -4,7 +4,6 @@ use a9f\Lifter\Configuration\LifterConfigFactory; use a9f\Lifter\Upgrade\Step\FractorStep; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Webmozart\Assert\Assert; return static function (ContainerConfigurator $configurator) { $fractorConfig = FractorConfiguration::configure(); @@ -14,9 +13,7 @@ if (!is_string($fractorConfigFile)) { throw new \RuntimeException('No file passed in env variable FRACTOR_CONFIG_FILE', 1712507292); } - $fractorConfigClosure = (require $fractorConfigFile); - Assert::isCallable($fractorConfigClosure, 'FRACTOR_CONFIG_FILE did not yield a callable'); - $fractorConfigClosure($fractorConfig); + $fractorConfig->import($fractorConfigFile); $lifterConfigFile = getenv('LIFTER_CONFIG_FILE'); if (!is_string($lifterConfigFile)) { diff --git a/src/Upgrade/Step/FractorStepExecutor.php b/src/Upgrade/Step/FractorStepExecutor.php index c9d3499..3c41fe4 100644 --- a/src/Upgrade/Step/FractorStepExecutor.php +++ b/src/Upgrade/Step/FractorStepExecutor.php @@ -56,11 +56,17 @@ public function run(int $index, UpgradeStep $step): void ], timeout: 3600 ); - $process->run(static function ($type, $data) { + $firstLine = true; + $process->run(static function ($type, $data) use (&$firstLine) { $data = trim($data); // TODO do we need to handle CRLF separately here? $lines = explode("\n", $data); + if (!$firstLine) { + echo array_shift($lines); + } else { + $firstLine = false; + } $lines = array_map( static fn (string $line) => "FRACTOR: $line", $lines diff --git a/src/Upgrade/Step/RectorStepExecutor.php b/src/Upgrade/Step/RectorStepExecutor.php index 0d11ef7..60d70cb 100644 --- a/src/Upgrade/Step/RectorStepExecutor.php +++ b/src/Upgrade/Step/RectorStepExecutor.php @@ -56,8 +56,22 @@ public function run(int $index, UpgradeStep $step): void ], timeout: 3600 ); - $process->run(static function ($type, $data) { - echo 'RECTOR: ' . $data; + $firstLine = true; + $process->run(static function ($type, $data) use (&$firstLine) { + $data = trim($data); + + // TODO do we need to handle CRLF separately here? + $lines = explode("\n", $data); + if (!$firstLine) { + echo array_shift($lines); + } else { + $firstLine = false; + } + $lines = array_map( + static fn (string $line) => "RECTOR: $line", + $lines + ); + echo implode("\n", $lines), "\n"; }); } }