From 6526acc5ab96adb1f6e331e772a515b773f67f3e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 6 Oct 2025 04:19:58 +0700 Subject: [PATCH 1/5] Manual install ocramius/package-versions on build downgrade --- bin/add-phpstan-self-replace.php | 5 +++++ build/build-rector-scoped.sh | 3 +++ composer.json | 1 - 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/add-phpstan-self-replace.php b/bin/add-phpstan-self-replace.php index c95c190d496..9d002b2a05c 100644 --- a/bin/add-phpstan-self-replace.php +++ b/bin/add-phpstan-self-replace.php @@ -10,6 +10,11 @@ require __DIR__ . '/../vendor/autoload.php'; +if (! class_exists(Versions::class)) { + echo 'You need to run `composer require ocramius/package-versions` first' . PHP_EOL; + exit(1); +} + $composerJsonFileContents = FileSystem::read(__DIR__ . '/../composer.json'); $composerJson = Json::decode($composerJsonFileContents, forceArrays: true); diff --git a/build/build-rector-scoped.sh b/build/build-rector-scoped.sh index 6ece2cf91e8..bf1e3456297 100644 --- a/build/build-rector-scoped.sh +++ b/build/build-rector-scoped.sh @@ -32,6 +32,9 @@ wget https://github.com/humbug/php-scoper/releases/download/0.18.17/php-scoper.p # avoid phpstan/phpstan dependency duplicate note "Remove PHPStan to avoid duplicating it" + +composer require ocramius/package-versions --working-dir "$BUILD_DIRECTORY" + php "$BUILD_DIRECTORY/bin/add-phpstan-self-replace.php" composer remove phpstan/phpstan -W --update-no-dev --working-dir "$BUILD_DIRECTORY" diff --git a/composer.json b/composer.json index 4308326a3f3..135e20db25f 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,6 @@ "illuminate/container": "^11.46", "nette/utils": "^4.0", "nikic/php-parser": "^5.6.1", - "ocramius/package-versions": "^2.10", "ondram/ci-detector": "^4.2", "phpstan/phpdoc-parser": "^2.3", "phpstan/phpstan": "^2.1.26", From 3bb9f991e1cce0a75f9a651481c755099d3dfb6c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 6 Oct 2025 04:58:18 +0700 Subject: [PATCH 2/5] fix phpstan --- phpstan.neon | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index 1d142cab5b7..457698c14fe 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -92,6 +92,10 @@ parameters: message: '#Function "var_dump\(\)" cannot be used/left in the code#' path: src/functions/node_helper.php + - + message: '#Function "class_exists\(\)" cannot be used/left in the code#' + path: bin/add-phpstan-self-replace.php + # lack of generic array in nikic/php-parser - '#Method (.*?) should return array but returns array#' From 6fabd3a8aeb99c871cf1a22b41852b664f01db05 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 6 Oct 2025 04:58:47 +0700 Subject: [PATCH 3/5] add php 8.5 to tests workflow --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 92a68854f63..cd1a0c804b0 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - php-versions: ['8.2', '8.3', '8.4'] + php-versions: ['8.2', '8.3', '8.4', '8.5'] runs-on: ${{ matrix.os }} timeout-minutes: 3 From 07d57ec4629518c996cdf9700142b9e512b555ce Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 6 Oct 2025 05:01:20 +0700 Subject: [PATCH 4/5] fix analyse --- composer-dependency-analyser.php | 1 + 1 file changed, 1 insertion(+) diff --git a/composer-dependency-analyser.php b/composer-dependency-analyser.php index ab40195069f..817df7532d3 100644 --- a/composer-dependency-analyser.php +++ b/composer-dependency-analyser.php @@ -21,6 +21,7 @@ __DIR__ . '/stubs', __DIR__ . '/tests', __DIR__ . '/rules-tests', + __DIR__ . '/bin/add-phpstan-self-replace.php', ], [ErrorType::UNKNOWN_CLASS]) ->disableExtensionsAnalysis(); From c451f2e6e0fc93488f16dc3c4b15a042f4e73a4c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 11 Oct 2025 05:17:36 +0700 Subject: [PATCH 5/5] Add note for use of package-versions on downgrade --- build/build-rector-scoped.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/build/build-rector-scoped.sh b/build/build-rector-scoped.sh index bf1e3456297..ee285970f7e 100644 --- a/build/build-rector-scoped.sh +++ b/build/build-rector-scoped.sh @@ -30,16 +30,27 @@ note "Starts" note "Downloading php-scoper.phar" wget https://github.com/humbug/php-scoper/releases/download/0.18.17/php-scoper.phar -N --no-verbose -# avoid phpstan/phpstan dependency duplicate -note "Remove PHPStan to avoid duplicating it" - +# make PackageVersions exists +# here while wait for PHP 8.5 compatible code +# see https://github.com/Ocramius/PackageVersions/pull/270 +# to allow us on rector to create downgrade PHP 8.5 rules with define +# +# #[RequiresPhp('>= 8.5')] +# +# On Downgrade PHP 8.5 rule, see https://github.com/rectorphp/rector-downgrade-php/pull/337 +# composer require ocramius/package-versions --working-dir "$BUILD_DIRECTORY" php "$BUILD_DIRECTORY/bin/add-phpstan-self-replace.php" +# avoid phpstan/phpstan and ocramius/package-versions dependency duplicate +note "Remove PHPStan and PackageVersions to avoid duplicating it" + composer remove phpstan/phpstan -W --update-no-dev --working-dir "$BUILD_DIRECTORY" composer remove ocramius/package-versions -W --update-no-dev --working-dir "$BUILD_DIRECTORY" +note "PHPStan and PackageVersions now removed, safe to start php-scoper from here" + # Work around possible PHP memory limits note "Running php-scoper on /bin, /config, /src, /rules and /vendor" php -d memory_limit=-1 php-scoper.phar add-prefix bin config src rules vendor composer.json UPGRADING.md --output-dir "../$RESULT_DIRECTORY" --config scoper.php --force --ansi --working-dir "$BUILD_DIRECTORY";