Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpstan-src: Require PHP 8.1 #1767

Merged
merged 8 commits into from Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/backward-compatibility.yml
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"
php-version: "8.1"

- name: "Install dependencies"
run: "composer install --no-dev --no-interaction --no-progress"
Expand All @@ -44,7 +44,7 @@ jobs:
run: |
composer global config minimum-stability dev
composer global config prefer-stable true
composer global require --dev ondrejmirtes/backward-compatibility-check:^5.0.9
composer global require --dev ondrejmirtes/backward-compatibility-check:^7.1.0

- name: "Check"
run: "$(composer global config bin-dir --absolute)/roave-backward-compatibility-check"
6 changes: 2 additions & 4 deletions .github/workflows/e2e-tests.yml
Expand Up @@ -33,8 +33,6 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
operating-system: [ubuntu-latest, windows-latest]

steps:
Expand All @@ -45,7 +43,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
php-version: "8.1"
extensions: mbstring
ini-values: memory_limit=256M

Expand Down Expand Up @@ -82,7 +80,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"
php-version: "8.1"
tools: ${{ matrix.tools }}
extensions: ${{ matrix.extensions }}

Expand Down
30 changes: 10 additions & 20 deletions .github/workflows/lint.yml
Expand Up @@ -49,34 +49,34 @@ jobs:
run: "composer install --no-interaction --no-progress"

- name: "Install PHP for code transform"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: 8.0
php-version: 8.1
extensions: mbstring, intl

- name: "Rector downgrade cache key"
id: rector-cache-key
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
run: |
echo "::set-output name=sha::$(php build/rector-cache-files-hash.php)"

- name: "Rector downgrade cache"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: actions/cache@v3
with:
path: ./tmp/rectorCache.php
key: "rector-v1-lint-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-${{ steps.rector-cache-key.outputs.sha }}"
key: "rector-v2-lint-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-${{ steps.rector-cache-key.outputs.sha }}"
restore-keys: |
rector-v1-lint-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-
rector-v2-lint-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-

- name: "Transform source code"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
run: "build/transform-source ${{ matrix.php-version }}"

- name: "Reinstall matrix PHP version"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
Expand All @@ -91,11 +91,6 @@ jobs:
runs-on: "ubuntu-latest"
timeout-minutes: 60

strategy:
matrix:
php-version:
- "8.0"

steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand All @@ -104,7 +99,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
php-version: "8.1"

- name: "Validate Composer"
run: "composer validate"
Expand All @@ -124,11 +119,6 @@ jobs:
runs-on: "ubuntu-latest"
timeout-minutes: 60

strategy:
matrix:
php-version:
- "8.0"

steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand All @@ -137,7 +127,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
php-version: "8.1"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phar.yml
Expand Up @@ -60,9 +60,9 @@ jobs:
uses: actions/cache@v3
with:
path: ./tmp/rectorCache.php
key: "rector-v1-phar-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ steps.rector-cache-key.outputs.sha }}"
key: "rector-v2-phar-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ steps.rector-cache-key.outputs.sha }}"
restore-keys: |
rector-v1-phar-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-
rector-v2-phar-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-
- name: "Prepare for PHAR compilation"
working-directory: "compiler"
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/static-analysis.yml
Expand Up @@ -56,35 +56,35 @@ jobs:
run: "composer install --no-interaction --no-progress"

- name: "Install PHP for code transform"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: 8.0
php-version: 8.1
extensions: mbstring, intl

- name: "Rector downgrade cache key"
id: rector-cache-key
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
run: |
echo "::set-output name=sha::$(php build/rector-cache-files-hash.php)"

- name: "Rector downgrade cache"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: actions/cache@v3
with:
path: ./tmp/rectorCache.php
key: "rector-v1-sa-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-${{ steps.rector-cache-key.outputs.sha }}"
key: "rector-v2-sa-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-${{ steps.rector-cache-key.outputs.sha }}"
restore-keys: |
rector-v1-sa-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-
rector-v2-sa-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-

- name: "Transform source code"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
shell: bash
run: "build/transform-source ${{ matrix.php-version }}"

- name: "Reinstall matrix PHP version"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
Expand All @@ -108,7 +108,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"

Expand Down Expand Up @@ -153,11 +152,6 @@ jobs:
runs-on: "ubuntu-latest"
timeout-minutes: 60

strategy:
matrix:
php-version:
- "8.0"

steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand All @@ -166,7 +160,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
php-version: "8.1"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/tests.yml
Expand Up @@ -57,35 +57,35 @@ jobs:
run: "composer install --no-interaction --no-progress"

- name: "Install PHP for code transform"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: 8.0
php-version: 8.1
extensions: mbstring, intl

- name: "Rector downgrade cache key"
id: rector-cache-key
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
run: |
echo "::set-output name=sha::$(php build/rector-cache-files-hash.php)"

- name: "Rector downgrade cache"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: actions/cache@v3
with:
path: ./tmp/rectorCache.php
key: "rector-v1-tests-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-${{ steps.rector-cache-key.outputs.sha }}"
key: "rector-v2-tests-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-${{ steps.rector-cache-key.outputs.sha }}"
restore-keys: |
rector-v1-tests-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-
rector-v2-tests-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-

- name: "Transform source code"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
shell: bash
run: "build/transform-source ${{ matrix.php-version }}"

- name: "Reinstall matrix PHP version"
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
Expand Down Expand Up @@ -182,22 +182,22 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"
php-version: "8.1"
extensions: mbstring, intl

- name: "Rector downgrade cache key"
id: rector-cache-key
if: matrix.php-version != '8.0' && matrix.php-version != '8.1' && matrix.php-version != '8.2'
if: matrix.php-version != '8.1' && matrix.php-version != '8.2'
run: |
echo "::set-output name=sha::$(php build/rector-cache-files-hash.php)"

- name: "Rector downgrade cache"
uses: actions/cache@v3
with:
path: ./tmp/rectorCache.php
key: "rector-v1-tests-old-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-${{ steps.rector-cache-key.outputs.sha }}"
key: "rector-v2-tests-old-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-${{ steps.rector-cache-key.outputs.sha }}"
restore-keys: |
rector-v1-tests-old-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-
rector-v2-tests-old-${{ matrix.script }}-${{ matrix.operating-system }}-${{ hashFiles('composer.lock', 'build/rector-downgrade.php') }}-${{ matrix.php-version }}-

- name: "Transform source code"
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-phpstorm-stubs.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"
php-version: "8.1"
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"
- name: "Checkout stubs"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -13,7 +13,7 @@ Any contributions are welcome.

### Building

PHPStan's source code is developed on PHP 8.0. For distribution in `phpstan/phpstan` package and as a PHAR file, the source code is transformed to run on PHP 7.2 and higher.
PHPStan's source code is developed on PHP 8.1. For distribution in `phpstan/phpstan` package and as a PHAR file, the source code is transformed to run on PHP 7.2 and higher.

Initially you need to run `composer install` in case you aren't working in a directory which was built before.

Expand Down
18 changes: 9 additions & 9 deletions build-cs/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions build/rector-downgrade.php
Expand Up @@ -12,6 +12,7 @@
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector;

return static function (RectorConfig $config): void {
$parsePhpVersion = static function (string $version, int $defaultPatch = 0): int {
Expand All @@ -27,6 +28,10 @@
$config->phpVersion($targetPhpVersionId);
$config->skip(RectorCache::SKIP_PATHS);

if ($targetPhpVersionId < 80100) {
$config->rule(DowngradeReadonlyPropertyRector::class);
}

if ($targetPhpVersionId < 80000) {
$config->rule(DowngradeTrailingCommasInParamUseRector::class);
$config->rule(DowngradeNonCapturingCatchesRector::class);
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -5,7 +5,7 @@
"MIT"
],
"require": {
"php": "^8.0",
"php": "^8.1",
"composer-runtime-api": "^2.0",
"clue/ndjson-react": "^1.0",
"composer/ca-bundle": "^1.2",
Expand Down Expand Up @@ -63,7 +63,7 @@
},
"config": {
"platform": {
"php": "8.0.99"
"php": "8.1.99"
},
"platform-check": false,
"sort-packages": true,
Expand Down