Skip to content

Commit bb7cecf

Browse files
authored
Manual install ocramius/package-versions on build downgrade to test php 8.5 (#7434)
* Manual install ocramius/package-versions on build downgrade * fix phpstan * add php 8.5 to tests workflow * fix analyse * Add note for use of package-versions on downgrade
1 parent 0e8e070 commit bb7cecf

File tree

6 files changed

+27
-4
lines changed

6 files changed

+27
-4
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
os: [ubuntu-latest, windows-latest]
21-
php-versions: ['8.2', '8.3', '8.4']
21+
php-versions: ['8.2', '8.3', '8.4', '8.5']
2222

2323
runs-on: ${{ matrix.os }}
2424
timeout-minutes: 3

bin/add-phpstan-self-replace.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
require __DIR__ . '/../vendor/autoload.php';
1212

13+
if (! class_exists(Versions::class)) {
14+
echo 'You need to run `composer require ocramius/package-versions` first' . PHP_EOL;
15+
exit(1);
16+
}
17+
1318
$composerJsonFileContents = FileSystem::read(__DIR__ . '/../composer.json');
1419

1520
$composerJson = Json::decode($composerJsonFileContents, forceArrays: true);

build/build-rector-scoped.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,27 @@ note "Starts"
3030
note "Downloading php-scoper.phar"
3131
wget https://github.com/humbug/php-scoper/releases/download/0.18.17/php-scoper.phar -N --no-verbose
3232

33-
# avoid phpstan/phpstan dependency duplicate
34-
note "Remove PHPStan to avoid duplicating it"
33+
# make PackageVersions exists
34+
# here while wait for PHP 8.5 compatible code
35+
# see https://github.com/Ocramius/PackageVersions/pull/270
36+
# to allow us on rector to create downgrade PHP 8.5 rules with define
37+
#
38+
# #[RequiresPhp('>= 8.5')]
39+
#
40+
# On Downgrade PHP 8.5 rule, see https://github.com/rectorphp/rector-downgrade-php/pull/337
41+
#
42+
composer require ocramius/package-versions --working-dir "$BUILD_DIRECTORY"
43+
3544
php "$BUILD_DIRECTORY/bin/add-phpstan-self-replace.php"
3645

46+
# avoid phpstan/phpstan and ocramius/package-versions dependency duplicate
47+
note "Remove PHPStan and PackageVersions to avoid duplicating it"
48+
3749
composer remove phpstan/phpstan -W --update-no-dev --working-dir "$BUILD_DIRECTORY"
3850
composer remove ocramius/package-versions -W --update-no-dev --working-dir "$BUILD_DIRECTORY"
3951

52+
note "PHPStan and PackageVersions now removed, safe to start php-scoper from here"
53+
4054
# Work around possible PHP memory limits
4155
note "Running php-scoper on /bin, /config, /src, /rules and /vendor"
4256
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";

composer-dependency-analyser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
__DIR__ . '/stubs',
2222
__DIR__ . '/tests',
2323
__DIR__ . '/rules-tests',
24+
__DIR__ . '/bin/add-phpstan-self-replace.php',
2425
], [ErrorType::UNKNOWN_CLASS])
2526

2627
->disableExtensionsAnalysis();

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"illuminate/container": "^11.46",
2222
"nette/utils": "^4.0",
2323
"nikic/php-parser": "^5.6.1",
24-
"ocramius/package-versions": "^2.10",
2524
"ondram/ci-detector": "^4.2",
2625
"phpstan/phpdoc-parser": "^2.3",
2726
"phpstan/phpstan": "^2.1.26",

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ parameters:
9292
message: '#Function "var_dump\(\)" cannot be used/left in the code#'
9393
path: src/functions/node_helper.php
9494

95+
-
96+
message: '#Function "class_exists\(\)" cannot be used/left in the code#'
97+
path: bin/add-phpstan-self-replace.php
98+
9599
# lack of generic array in nikic/php-parser
96100
- '#Method (.*?) should return array<PhpParser\\Node\\(.*?)\> but returns array<PhpParser\\Node\>#'
97101

0 commit comments

Comments
 (0)