From 11cd8b2addbd93535585a619f4c09ba8d8169b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20J=C3=BCrisoo?= Date: Tue, 27 Oct 2026 08:29:10 +0000 Subject: [PATCH] Support PHP 8.5: CI, docs, php-parser ^5.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP 8.5.12 is the current security release, and CI only went up to 8.4. - CI: add PHP 8.5 to the matrix against Laravel 12 (testbench 10) and Laravel 13 (testbench 11). Laravel 10/11 are EOL and never supported 8.5, so they are not included. The suite passes unmodified on 8.5.12 in Docker (php:8.5-cli) for both combinations: 164 passed, plus the same 1 risky and 4 incomplete tests as before. - composer.json: nikic/php-parser ^5.0 -> ^5.6. Archetype parses with createForNewestSupportedVersion(), so the parser version, not the host PHP, decides which syntax it can read. Tested in isolation: 5.4 and 5.5 reject 8.5 code (`final` promoted properties give "unexpected T_FINAL"), and 5.6.0 is the first version that parses and prints it, including `|>` and `(void)`. With dev tooling (Pest 3.8) installed, nothing below 5.7 resolves on 8.5 anyway. - tests: Php85SyntaxTest loads a class that uses the pipe operator, a (void) cast, a final promoted property and #[\NoDiscard]/#[\Deprecated], renames it, adds a property, and checks that the 8.5 constructs survive rendering. It runs on every PHP version in the matrix, because parsing does not depend on the host. - readme/CHANGELOG: the support table now says PHP 8.1–8.5 and php-parser ^5.6, plus an Unreleased entry. src/ was scanned for constructs PHP 8.5 deprecates (non-canonical casts, backticks, __sleep/__wakeup, `case x;`) and has none. There are no open Dependabot alerts or security advisories on the repo. Proposed version: 2.1.0 (minor). The public API does not change, but raising a dependency floor deserves more than a patch. Co-Authored-By: t-1000 (Claude Code) Claude-Session: https://claude.ai/code/session_01Rae8mwrqWEfCaUAbtmXZTp --- .github/workflows/tests.yml | 2 ++ CHANGELOG.md | 17 +++++++++++ composer.json | 2 +- readme.md | 2 +- tests/Feature/Php85SyntaxTest.php | 49 +++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/Php85SyntaxTest.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index df20875..0ee6a05 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,10 +24,12 @@ jobs: - { php: '8.2', laravel: '12.*', testbench: '10.*', os: ubuntu-latest } - { php: '8.3', laravel: '12.*', testbench: '10.*', os: ubuntu-latest } - { php: '8.4', laravel: '12.*', testbench: '10.*', os: ubuntu-latest } + - { php: '8.5', laravel: '12.*', testbench: '10.*', os: ubuntu-latest } # Laravel 13 (testbench 11, PHP 8.3+). statamic/cms 6 allows ^13.0, # so this is a version real downstream users are already on. - { php: '8.3', laravel: '13.*', testbench: '11.*', os: ubuntu-latest } - { php: '8.4', laravel: '13.*', testbench: '11.*', os: ubuntu-latest } + - { php: '8.5', laravel: '13.*', testbench: '11.*', os: ubuntu-latest } # Keep an eye on the other host we claim to work on - { php: '8.4', laravel: '12.*', testbench: '10.*', os: macos-latest } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d5fa21..941e067 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,23 @@ This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +Proposed as 2.1.0: no API changes, but the php-parser floor rises. + +### Added + +- Support for PHP 8.5 (CI runs 8.5 against Laravel 12 and 13). The suite + passes unmodified on PHP 8.5.12, the current security release. +- Files written in PHP 8.5 syntax (pipe operator `|>`, `(void)` casts, + `final` promoted properties, `#[\NoDiscard]`) can be loaded, edited and + rendered. A round-trip test covers this. + +### Changed + +- `nikic/php-parser` is now required at `^5.6` instead of `^5.0`. Archetype + parses with php-parser's newest supported version, and 5.5 and older reject + PHP 8.5 syntax with a parse error. Composer upgrades php-parser within 5.x, + and nothing changes in your own code. + ## [2.0.1] - 2026-08-25 Maintenance only. No API changes, and nothing here can break existing usage. diff --git a/composer.json b/composer.json index 3795160..6e73891 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": "^8.1", - "nikic/php-parser": "^5.0" + "nikic/php-parser": "^5.6" }, "require-dev": { "orchestra/testbench": "^8.0 || ^9.0 || ^10.0 || ^11.0", diff --git a/readme.md b/readme.md index e900a38..918f2b7 100644 --- a/readme.md +++ b/readme.md @@ -21,7 +21,7 @@ That's it! Check out introduction of concepts below or review the [API examples] | Archetype | PHP | Laravel | php-parser | | --------- | ------- | -------- | ---------- | -| 2.x | 8.1–8.4 | 10, 11, 12, 13 | ^5.0 | +| 2.x | 8.1–8.5 | 10, 11, 12, 13 | ^5.6 | | 1.x | 7.4–8.1 | 6–9 | ^4.11 | > **On 1.x?** Upgrade to 2.x. Version 1 pins `nikic/php-parser` to `^4.11`, which diff --git a/tests/Feature/Php85SyntaxTest.php b/tests/Feature/Php85SyntaxTest.php new file mode 100644 index 0000000..e3eeb14 --- /dev/null +++ b/tests/Feature/Php85SyntaxTest.php @@ -0,0 +1,49 @@ +input |> trim(...) |> strtolower(...); + } + + public function run(): void + { + (void) $this->slug(); + } +} +PHP; + +it('can load and edit a file using php 8.5 syntax', function() use ($php85) { + $output = PHPFile::fromString($php85) + ->className('RenamedPipeline') + ->add()->property('extra', 1) + ->assertValidPhp() + ->render(); + + expect($output) + ->toContain('class RenamedPipeline') + ->toContain('|> trim(...) |> strtolower(...)') + ->toContain('(void) $this->slug()') + ->toContain('final public string $input') + ->toContain('#[\NoDiscard]'); +});