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 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..ee285970f7e 100644 --- a/build/build-rector-scoped.sh +++ b/build/build-rector-scoped.sh @@ -30,13 +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"; 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(); 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", 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#'