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

Test PHP-Parser 5 #2839

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c2b576c
Open 2.0.x-dev
ondrejmirtes Dec 20, 2023
88ef6d5
Drop support for PHP 7.2 and 7.3
ondrejmirtes Dec 20, 2023
778af2f
Update nikic/php-parser to v5
ondrejmirtes Dec 22, 2023
46e8f1b
Compatibility with PHP-Parser v5
ondrejmirtes Dec 20, 2023
8a47713
PHP-Parser 5 - compiler
ondrejmirtes Dec 20, 2023
f056972
Scope changes
ondrejmirtes Dec 22, 2023
4d7d6ed
Rest of src/ changes
ondrejmirtes Dec 20, 2023
71c1790
Tests changes
ondrejmirtes Dec 20, 2023
33f3ce9
Fixes
ondrejmirtes Dec 20, 2023
e7f9a77
Fix deprecations
ondrejmirtes Dec 20, 2023
d68e55c
Fix phar.yml
ondrejmirtes Dec 22, 2023
1620cab
Fix ThrowExprTypeRuleTest
ondrejmirtes Dec 29, 2023
78c1b40
Remove obsolete ThrowTypeRule because it targeted Stmt\Throw_
ondrejmirtes Dec 29, 2023
7f515bb
Fix ThrowExpressionRule
ondrejmirtes Dec 30, 2023
a23e389
Fixes
ondrejmirtes Dec 30, 2023
21bb404
ParserFactory to correctly create Php7/Php8
ondrejmirtes Dec 30, 2023
5849a84
This hack is no longer needed because there is now clear separation b…
ondrejmirtes Dec 30, 2023
59747b6
Fix NeverRuleHelper
ondrejmirtes Dec 30, 2023
d6983c0
Get rid of more Stmt\Throw_ instances
ondrejmirtes Dec 30, 2023
3884d2e
Fixes
ondrejmirtes Dec 30, 2023
65368e3
Fixes
ondrejmirtes Dec 30, 2023
4178be1
Simplify TypehintHelper and use ParserNodeTypeToPHPStanType
ondrejmirtes Dec 30, 2023
58f630e
Stub validator - always use latest PHP 8 parser
ondrejmirtes Dec 30, 2023
94c9bce
Fix PHPStan errors
ondrejmirtes Jan 1, 2024
e131739
Fix
ondrejmirtes Jan 1, 2024
8b462d2
Fix
ondrejmirtes Sep 4, 2024
598a82d
Handle Block statement
ondrejmirtes Sep 4, 2024
f13af95
Fix standalone Throw_ expr handling
ondrejmirtes Sep 4, 2024
a22ed83
Remove obsolete NoBleedingEdge tests
ondrejmirtes Sep 4, 2024
cbd3fd7
Fix detecting invalid PHPDocs
ondrejmirtes Sep 4, 2024
7d1fec9
Fix minor change
ondrejmirtes Sep 4, 2024
c7e9e3e
Fix baseline
ondrejmirtes Sep 4, 2024
e2f0c77
Preparing PHAR - fix php constraint
ondrejmirtes Sep 4, 2024
987009a
Fix tests
ondrejmirtes Sep 4, 2024
644dbbc
Update PHPUnit
ondrejmirtes Sep 4, 2024
4ce29a7
Fix anonymous class
ondrejmirtes Sep 4, 2024
b4c231b
Fix RichParser
ondrejmirtes Sep 4, 2024
151896f
Fix
ondrejmirtes Sep 4, 2024
2f9c8d4
Fixes
ondrejmirtes Sep 4, 2024
a1ad423
Remove deprecated rule NoopRule
ondrejmirtes Sep 4, 2024
29345c2
Update BetterReflection
ondrejmirtes Sep 4, 2024
0dcb5dc
Fix
ondrejmirtes Sep 4, 2024
88560b6
Remove deprecated rule ImplodeFunctionRule
ondrejmirtes Sep 4, 2024
069d6e9
Fix tests
ondrejmirtes Sep 4, 2024
02fab88
Skip `mixed` tests on PHP < 8.0
ondrejmirtes Sep 4, 2024
3e3b051
Fix lint
ondrejmirtes Sep 4, 2024
6cfeb23
Skip more `mixed` tests
ondrejmirtes Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/backward-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
push:
branches:
- "1.12.x"
- "2.0.x"
paths:
- 'src/**'
- '.github/workflows/backward-compatibility.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-issue-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- '.github/workflows/build-issue-bot.yml'
push:
branches:
- "1.12.x"
- "2.0.x"
paths:
- 'issue-bot/**'
- '.github/workflows/build-issue-bot.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- '.github/workflows/changelog-generator.yml'
push:
branches:
- "1.12.x"
- "2.0.x"
paths:
- 'changelog-generator/**'
- '.github/workflows/changelog-generator.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checksum-phar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- '.github/workflows/checksum-phar.yml'
push:
branches:
- "1.12.x"
- "2.0.x"
paths:
- 'compiler/**'
- '.github/workflows/checksum-phar.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- 'issue-bot/**'
push:
branches:
- "1.12.x"
- "2.0.x"
paths-ignore:
- 'compiler/**'
- 'apigen/**'
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
push:
branches:
- "1.12.x"
- "2.0.x"

env:
COMPOSER_ROOT_VERSION: "1.12.x-dev"
Expand All @@ -25,8 +25,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/phar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:
pull_request:
push:
branches:
- "1.12.x"
- "2.0.x"
tags:
- '1.12.*'
- '2.0.*'

env:
COMPOSER_ROOT_VERSION: "1.12.x-dev"

concurrency:
group: phar-${{ github.ref }} # will be canceled on subsequent pushes in both branches and pull requests
Expand Down Expand Up @@ -76,15 +79,12 @@ jobs:

- name: "Composer dump"
run: "composer install --no-interaction --no-progress"
env:
COMPOSER_ROOT_VERSION: "1.12.x-dev"

- name: "Compile PHAR for checksum"
working-directory: "compiler/build"
run: "php box.phar compile --no-parallel"
env:
PHAR_CHECKSUM: "1"
COMPOSER_ROOT_VERSION: "1.12.x-dev"

- name: "Re-sign PHAR"
run: "php compiler/build/resign.php tmp/phpstan.phar"
Expand All @@ -107,25 +107,25 @@ jobs:
integration-tests:
if: github.event_name == 'pull_request'
needs: compiler-tests
uses: phpstan/phpstan/.github/workflows/integration-tests.yml@1.12.x
uses: phpstan/phpstan/.github/workflows/integration-tests.yml@2.0.x
with:
ref: 1.12.x
ref: 2.0.x
phar-checksum: ${{needs.compiler-tests.outputs.checksum}}

extension-tests:
if: github.event_name == 'pull_request'
needs: compiler-tests
uses: phpstan/phpstan/.github/workflows/extension-tests.yml@1.12.x
uses: phpstan/phpstan/.github/workflows/extension-tests.yml@2.0.x
with:
ref: 1.12.x
ref: 2.0.x
phar-checksum: ${{needs.compiler-tests.outputs.checksum}}

other-tests:
if: github.event_name == 'pull_request'
needs: compiler-tests
uses: phpstan/phpstan/.github/workflows/other-tests.yml@1.12.x
uses: phpstan/phpstan/.github/workflows/other-tests.yml@2.0.x
with:
ref: 1.12.x
ref: 2.0.x
phar-checksum: ${{needs.compiler-tests.outputs.checksum}}

commit:
Expand All @@ -152,7 +152,7 @@ jobs:
repository: phpstan/phpstan
path: phpstan-dist
token: ${{ secrets.PHPSTAN_BOT_TOKEN }}
ref: 1.12.x
ref: 2.0.x

- name: "Get previous pushed dist commit"
id: previous-commit
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-base-on-previous-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
- name: Comment PR
uses: peter-evans/create-or-update-comment@v4
with:
body: "You've opened the pull request against the latest branch 2.0.x. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x."
body: "You've opened the pull request against the latest branch 2.0.x. PHPStan 2.0 is not going to be released for months. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x."
token: ${{ secrets.PHPSTAN_BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
3 changes: 1 addition & 2 deletions .github/workflows/reflection-golden-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- 'issue-bot/**'
push:
branches:
- "1.12.x"
- "2.0.x"
paths-ignore:
- 'compiler/**'
- 'apigen/**'
Expand Down Expand Up @@ -65,7 +65,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
push:
branches:
- "1.12.x"
- "2.0.x"

jobs:
typos:
Expand Down
25 changes: 7 additions & 18 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- 'apigen/**'
push:
branches:
- "1.12.x"
- "2.0.x"
paths-ignore:
- 'compiler/**'
- 'apigen/**'
Expand All @@ -31,8 +31,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand Down Expand Up @@ -61,18 +59,12 @@ jobs:
shell: bash
run: "vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}"

- name: "Paratest patch"
if: matrix.php-version == '7.2'
run: composer config extra.patches.brianium/paratest --json --merge '["patches/paratest.patch"]'
shell: bash

- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.2'
run: "composer require --dev phpunit/phpunit:^8.5.31 brianium/paratest:^4.0 composer/semver:^1.2 --update-with-dependencies --ignore-platform-reqs"

- name: "Update PHPUnit"
if: matrix.php-version != '7.2' && matrix.php-version != '7.3'
run: "composer update phpunit/phpunit -W"
- name: "Upload transformed sources"
if: matrix.php-version == '7.4'
uses: actions/upload-artifact@v3
with:
name: transformed-src
path: src

- name: "PHPStan"
run: "make phpstan"
Expand Down Expand Up @@ -107,9 +99,6 @@ jobs:
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Update PHPUnit"
run: "composer update phpunit/phpunit -W"

- name: "Cache Result cache"
uses: actions/cache@v4
with:
Expand Down
50 changes: 1 addition & 49 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- 'issue-bot/**'
push:
branches:
- "1.12.x"
- "2.0.x"
paths-ignore:
- 'compiler/**'
- 'apigen/**'
Expand All @@ -35,7 +35,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand Down Expand Up @@ -66,10 +65,6 @@ jobs:
shell: bash
run: "vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}"

- name: "Update PHPUnit"
if: matrix.php-version != '7.3'
run: "composer update phpunit/phpunit -W"

- name: "Tests"
run: "make tests"

Expand Down Expand Up @@ -162,46 +157,3 @@ jobs:

- name: "Tests"
run: "${{ matrix.script }}"

tests-old-phpunit:
name: "Tests with old PHPUnit"
runs-on: ${{ matrix.operating-system }}
timeout-minutes: 60

strategy:
fail-fast: false
matrix:
php-version:
- "7.2"
operating-system: [ ubuntu-latest ]

steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: pecl
extensions: ds,mbstring
ini-file: development
ini-values: memory_limit=2G

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Transform source code"
shell: bash
run: "vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}"

- name: "Paratest patch"
run: composer config extra.patches.brianium/paratest --json --merge '["patches/paratest.patch"]'
shell: bash

- name: "Downgrade PHPUnit"
run: "composer require --dev phpunit/phpunit:^8.5.31 brianium/paratest:^4.0 composer/semver:^1.2 --update-with-dependencies --ignore-platform-reqs"

- name: "Tests"
run: "make tests-coverage"
2 changes: 1 addition & 1 deletion build/composer-dependency-analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
)
->ignoreErrorsOnPackage('phpunit/phpunit', [ErrorType::DEV_DEPENDENCY_IN_PROD]) // prepared test tooling
->ignoreErrorsOnPackage('jetbrains/phpstorm-stubs', [ErrorType::PROD_DEPENDENCY_ONLY_IN_DEV]) // there is no direct usage, but we need newer version then required by ondrejmirtes/BetterReflection
->ignoreErrorsOnPath(__DIR__ . '/../tests', [ErrorType::UNKNOWN_CLASS, ErrorType::UNKNOWN_FUNCTION]) // to be able to test invalid symbols
->ignoreErrorsOnPath(__DIR__ . '/../tests', [ErrorType::UNKNOWN_CLASS, ErrorType::UNKNOWN_FUNCTION, ErrorType::SHADOW_DEPENDENCY]) // to be able to test invalid symbols
->ignoreUnknownClasses([
'JetBrains\PhpStorm\Pure', // not present on composer's classmap
'PHPStan\ExtensionInstaller\GeneratedConfig', // generated
Expand Down
17 changes: 16 additions & 1 deletion compiler/src/Console/PrepareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use function file_get_contents;
use function file_put_contents;
use function implode;
use function in_array;
use function is_dir;
use function json_decode;
use function json_encode;
Expand Down Expand Up @@ -64,7 +65,7 @@ private function fixComposerJson(string $buildDir): void

unset($json['replace']);
$json['name'] = 'phpstan/phpstan';
$json['require']['php'] = '^7.2|^8.0';
$json['require']['php'] = '^7.4|^8.0';

// simplify autoload (remove not packed build directory]
$json['autoload']['psr-4']['PHPStan\\'] = 'src/';
Expand Down Expand Up @@ -184,6 +185,20 @@ private function buildPreloadScript(): void
if ($realPath === false) {
return;
}
if (in_array($realPath, [
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php',
$vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php',
], true)) {
continue;
}
$path = substr($realPath, strlen($root));
$output .= 'require_once __DIR__ . ' . var_export($path, true) . ';' . "\n";
}
Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"nette/php-generator": "3.6.9",
"nette/schema": "^1.2.2",
"nette/utils": "^3.2.5",
"nikic/php-parser": "^4.17.1",
"nikic/php-parser": "^5.1.0",
"ondram/ci-detector": "^3.4.0",
"ondrejmirtes/better-reflection": "6.25.0.17",
"ondrejmirtes/better-reflection": "6.42.0.6",
"phpstan/php-8-stubs": "0.3.101",
"phpstan/phpdoc-parser": "1.30.0",
"psr/http-message": "^1.1",
Expand Down Expand Up @@ -55,14 +55,13 @@
"require-dev": {
"brianium/paratest": "^6.5",
"cweagans/composer-patches": "^1.7.3",
"nette/finder": "^2.5",
"ondrejmirtes/simple-downgrader": "^1.0",
"ondrejmirtes/simple-downgrader": "^2.0",
"php-parallel-lint/php-parallel-lint": "^1.2.0",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-nette": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^9.5.4",
"phpunit/phpunit": "^9.6",
"shipmonk/composer-dependency-analyser": "^1.5",
"shipmonk/name-collision-detector": "^2.0"
},
Expand Down
Loading
Loading