From a7201e5e1131d28c2b16291ff0fa368d21a3b6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20J=C3=BCrisoo?= Date: Tue, 25 Aug 2026 12:45:04 +0200 Subject: [PATCH 1/5] Maintenance release 2.0.1 Support PHP 8.2-8.4 and Laravel 10-12, and prove it in CI. v2.0.0 shipped the php-parser 5 port having never been tested against any PHP or Laravel version currently in use; the workflow still targeted PHP 7.4/8.0 with Laravel 6/7/8 and had not run since May 2024. No API changes. Nothing here can break existing usage. Testing - Pin the application skeleton the suite asserts against into tests/fixtures/laravel instead of copying one out of vendor/laravel/laravel at runtime. Laravel 11 deleted most of the files the suite relied on (app/Console/Kernel.php, app/Exceptions/Handler.php, RouteServiceProvider, the middleware), so the old approach could not run on current Laravel at all. Drops the laravel/laravel dev dependency. - Stop defining a global context() helper in tests/Pest.php. Laravel 11 ships its own, and the collision took the suite down before a single test ran. - Rebuild the CI matrix: ten PHP x Laravel combinations, checkout@v4, cache@v4, and no more of GitHub's disabled ::set-output. Add a PHPStan job. - Migrate phpunit.xml to the PHPUnit 10+ schema. Fixes - Map the 'throw' AST node to Expr\Throw_. php-parser 5 removed Stmt\Throw_, so ->throw() had silently matched nothing since 2.0.0. Caught by PHPStan, now covered by a test. - Catch Throwable rather than Exception in getReflection(). A file whose parent class or trait cannot be autoloaded raises an Error, which escaped and killed the whole query instead of skipping that one file. Affects LaravelFile::models(), controllers() and serviceProviders(). - Declare seven implicit-nullable parameters explicitly, silencing the deprecation notices they raise on PHP 8.4. - Correct commands_root and controllers_root in the shipped config, which both pointed at app/HTTP/Controllers. Packaging - Declare a php requirement. There was none. - Add LICENSE.md. The package has always been MIT; the file was missing. - Add CHANGELOG.md and .github/dependabot.yml. - Move Archetype\Tests\ out of the production autoloader. - Set minimum-stability to stable. - Refresh .gitattributes, which referenced files that no longer exist and missed ones that do. Readme now states supported versions and tells 1.x users why Composer refuses to resolve for them. Co-Authored-By: Claude Opus 5 (1M context) --- .gitattributes | 21 +-- .github/dependabot.yml | 22 +++ .github/workflows/tests.yml | 125 +++++++----------- .gitignore | 1 + CHANGELOG.md | 69 ++++++++++ LICENSE.md | 21 +++ composer.json | 36 +++-- phpstan.neon | 6 +- phpunit.xml | 19 ++- readme.md | 14 +- src/Drivers/FileInput.php | 2 +- src/Drivers/InputInterface.php | 2 +- src/Endpoints/EndpointProvider.php | 2 +- src/Endpoints/PHP/Namespace_.php | 2 +- src/Endpoints/PHP/ReflectionProxy.php | 8 +- src/PHPFile.php | 2 +- src/Support/AST/ASTQueryBuilder.php | 2 +- src/Traits/PHPParserClassMap.php | 3 +- src/Traits/PHPParserPropertyMap.php | 2 +- src/config/archetype.php | 4 +- tests/Pest.php | 16 +-- tests/Support/TestablePHPFile.php | 14 +- tests/TestCase.php | 15 ++- .../Unit/Support/AST/ASTQueryBuilderTest.php | 11 +- tests/fixtures/laravel/app/Console/Kernel.php | 32 +++++ .../laravel/app/Exceptions/Handler.php | 41 ++++++ .../app/Http/Controllers/Controller.php | 13 ++ tests/fixtures/laravel/app/Http/Kernel.php | 67 ++++++++++ .../app/Http/Middleware/Authenticate.php | 21 +++ .../app/Http/Middleware/EncryptCookies.php | 17 +++ .../PreventRequestsDuringMaintenance.php | 17 +++ .../Middleware/RedirectIfAuthenticated.php | 32 +++++ .../app/Http/Middleware/TrimStrings.php | 19 +++ .../app/Http/Middleware/TrustHosts.php | 20 +++ .../app/Http/Middleware/TrustProxies.php | 28 ++++ .../app/Http/Middleware/VerifyCsrfToken.php | 17 +++ tests/fixtures/laravel/app/Models/User.php | 44 ++++++ .../app/Providers/AppServiceProvider.php | 28 ++++ .../app/Providers/AuthServiceProvider.php | 30 +++++ .../Providers/BroadcastServiceProvider.php | 21 +++ .../app/Providers/EventServiceProvider.php | 32 +++++ .../app/Providers/RouteServiceProvider.php | 63 +++++++++ .../2014_10_12_000000_create_users_table.php | 36 +++++ ...12_100000_create_password_resets_table.php | 32 +++++ ..._08_19_000000_create_failed_jobs_table.php | 36 +++++ ...01_create_personal_access_tokens_table.php | 36 +++++ tests/fixtures/laravel/public/index.php | 55 ++++++++ tests/stubs/laravel-sanctum.php | 16 +++ 48 files changed, 1026 insertions(+), 146 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 tests/fixtures/laravel/app/Console/Kernel.php create mode 100644 tests/fixtures/laravel/app/Exceptions/Handler.php create mode 100644 tests/fixtures/laravel/app/Http/Controllers/Controller.php create mode 100644 tests/fixtures/laravel/app/Http/Kernel.php create mode 100644 tests/fixtures/laravel/app/Http/Middleware/Authenticate.php create mode 100644 tests/fixtures/laravel/app/Http/Middleware/EncryptCookies.php create mode 100644 tests/fixtures/laravel/app/Http/Middleware/PreventRequestsDuringMaintenance.php create mode 100644 tests/fixtures/laravel/app/Http/Middleware/RedirectIfAuthenticated.php create mode 100644 tests/fixtures/laravel/app/Http/Middleware/TrimStrings.php create mode 100644 tests/fixtures/laravel/app/Http/Middleware/TrustHosts.php create mode 100644 tests/fixtures/laravel/app/Http/Middleware/TrustProxies.php create mode 100644 tests/fixtures/laravel/app/Http/Middleware/VerifyCsrfToken.php create mode 100644 tests/fixtures/laravel/app/Models/User.php create mode 100644 tests/fixtures/laravel/app/Providers/AppServiceProvider.php create mode 100644 tests/fixtures/laravel/app/Providers/AuthServiceProvider.php create mode 100644 tests/fixtures/laravel/app/Providers/BroadcastServiceProvider.php create mode 100644 tests/fixtures/laravel/app/Providers/EventServiceProvider.php create mode 100644 tests/fixtures/laravel/app/Providers/RouteServiceProvider.php create mode 100644 tests/fixtures/laravel/database/migrations/2014_10_12_000000_create_users_table.php create mode 100644 tests/fixtures/laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php create mode 100644 tests/fixtures/laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php create mode 100644 tests/fixtures/laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php create mode 100644 tests/fixtures/laravel/public/index.php create mode 100644 tests/stubs/laravel-sanctum.php diff --git a/.gitattributes b/.gitattributes index ddd8e046..5cd84a18 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,13 +1,14 @@ # Path-based git attributes # https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html -# Ignore all test and documentation with "export-ignore". -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yml export-ignore -/phpunit.xml.dist export-ignore -/.scrutinizer.yml export-ignore -/tests export-ignore -/docs export-ignore -/.github export-ignore -/.editorconfig export-ignore +# Keep development-only files out of the distributed package. +/.editorconfig export-ignore +/.gitattributes export-ignore +/.github export-ignore +/.gitignore export-ignore +/.phpunit-watcher.yml export-ignore +/CHANGELOG.md export-ignore +/docs.md export-ignore +/phpstan.neon export-ignore +/phpunit.xml export-ignore +/tests export-ignore diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..332e83f2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,22 @@ +version: 2 + +updates: + - package-ecosystem: composer + directory: "/" + schedule: + interval: monthly + open-pull-requests-limit: 5 + labels: + - dependencies + # The library itself only requires php-parser. Everything else here is test + # tooling, and the CI matrix already pins the Laravel versions it exercises. + ignore: + - dependency-name: "orchestra/testbench" + update-types: ["version-update:semver-major"] + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: monthly + labels: + - dependencies diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d3d7758f..c0449774 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,105 +1,82 @@ name: tests -on: [push, pull_request] - -env: - COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist -o -n" +on: + push: + branches: [master] + pull_request: + workflow_dispatch: jobs: - laravel-tests: + tests: strategy: fail-fast: false matrix: - php-version: [7.4, 8.0] - laravel-version: [6, 7, 8] - os: [ubuntu-latest] - experimental: [false] - dependencies: [locked] include: - - php-version: 7.4 - laravel-version: 8 - dependencies: highest - os: ubuntu-latest - experimental: false - - # - php-version: 7.4 - # laravel-version: 8 - # os: windows-latest - # dependencies: locked - # experimental: false - - - php-version: 7.4 - laravel-version: 8 - os: macos-latest - dependencies: locked - experimental: false - - name: PHP ${{ matrix.php-version }} - L${{ matrix.laravel-version }} - ${{ matrix.os }} - ${{ matrix.dependencies }} + # Laravel 10 (testbench 8) + - { php: '8.1', laravel: '10.*', testbench: '8.*', os: ubuntu-latest } + - { php: '8.2', laravel: '10.*', testbench: '8.*', os: ubuntu-latest } + - { php: '8.3', laravel: '10.*', testbench: '8.*', os: ubuntu-latest } + # Laravel 11 (testbench 9) + - { php: '8.2', laravel: '11.*', testbench: '9.*', os: ubuntu-latest } + - { php: '8.3', laravel: '11.*', testbench: '9.*', os: ubuntu-latest } + - { php: '8.4', laravel: '11.*', testbench: '9.*', os: ubuntu-latest } + # Laravel 12 (testbench 10) + - { 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 } + # Keep an eye on the other host we claim to work on + - { php: '8.4', laravel: '12.*', testbench: '10.*', os: macos-latest } + + name: PHP ${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.experimental }} - steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd coverage: none - ini-values: "memory_limit=-1" - tools: composer + ini-values: memory_limit=-1, error_reporting=E_ALL + tools: composer:v2 - name: Determine composer cache directory - id: determine-composer-cache-directory - run: 'echo "::set-output name=directory::$(composer config cache-dir)"' + id: composer-cache + run: echo "directory=$(composer config cache-dir)" >> "$GITHUB_OUTPUT" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: - path: ${{ steps.determine-composer-cache-directory.outputs.directory }} - key: dependencies-os-${{ matrix.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: dependencies-os-${{ matrix.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-composer- - - - name: Setup problem matchers for PHP - run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + path: ${{ steps.composer-cache.outputs.directory }} + key: composer-${{ matrix.os }}-php${{ matrix.php }}-laravel${{ matrix.laravel }}-${{ hashFiles('composer.json') }} + restore-keys: composer-${{ matrix.os }}-php${{ matrix.php }}-laravel${{ matrix.laravel }}- - - name: Setup problem matchers for PHPUnit - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Install dependencies + run: | + composer require --dev --no-update --no-interaction \ + "laravel/framework:${{ matrix.laravel }}" \ + "orchestra/testbench:${{ matrix.testbench }}" + composer update --prefer-dist --no-interaction --no-progress - - name: Install highest dependencies from composer.json - if: matrix.dependencies == 'highest' - uses: nick-invision/retry@v1 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }} + - name: Run tests + run: vendor/bin/pest - - name: Install lowest dependencies from composer.json - if: matrix.dependencies == 'lowest' - uses: nick-invision/retry@v1 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer install ${{ env.COMPOSER_FLAGS }} --prefer-lowest + static-analysis: + name: PHPStan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - - name: Install dependencies from composer.lock - if: matrix.dependencies == 'locked' - uses: nick-invision/retry@v1 + - uses: shivammathur/setup-php@v2 with: - timeout_minutes: 5 - max_attempts: 5 - command: composer install ${{ env.COMPOSER_FLAGS }} + php-version: '8.3' + coverage: none + tools: composer:v2 - - name: Select Laravel version - uses: nick-invision/retry@v1 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer require "laravel/framework:${{ matrix.laravel-version }}.*" --no-update + - run: composer update --prefer-dist --no-interaction --no-progress - - name: Run tests - run: vendor/bin/pest --verbose + - run: vendor/bin/phpstan analyse --no-progress diff --git a/.gitignore b/.gitignore index 310c8bcb..cf7d6e5c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ sketches/ .vscode/ vendor/ .phpunit.result.cache +.phpunit.cache/ logs composer.lock \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..483ead3c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,69 @@ +# Changelog + +All notable changes to `ajthinking/archetype` are documented here. + +This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [2.0.1] - 2026-08-25 + +Maintenance only. No API changes, and nothing here can break existing usage. + +### Added + +- Support for PHP 8.2, 8.3 and 8.4, and for Laravel 10, 11 and 12 — now verified + in CI across ten combinations rather than assumed. +- A `php` requirement (`>=7.4`) in `composer.json`. The package never declared + one, so Composer could not warn anybody. +- `LICENSE.md`. The package has always been MIT; the file was missing. +- This changelog. +- `.github/dependabot.yml`, so dependency updates are configured rather than + running on defaults. + +### Changed + +- The test suite now runs against a pinned application skeleton in + `tests/fixtures/laravel` instead of copying one out of `vendor/laravel/laravel` + at runtime. Laravel 11 removed most of the files the suite relied on + (`app/Console/Kernel.php`, `app/Exceptions/Handler.php`, `RouteServiceProvider` + and the middleware), which made the old approach untestable on current Laravel. + `laravel/laravel` is no longer a dev dependency. +- CI runs on `actions/checkout@v4` and `actions/cache@v4`, and no longer uses the + `::set-output` command that GitHub has disabled. +- `phpunit.xml` migrated to the PHPUnit 10+ schema. +- `Archetype\Tests\` moved out of the production autoloader into `autoload-dev`. +- `minimum-stability` is now `stable`. + +### Fixed + +- Six implicit-nullable parameters that raised deprecation notices on PHP 8.4 + (`PHPFile::namespace()`, `Namespace_::namespace()`, `FileInput::load()`, + `InputInterface::load()`, `EndpointProvider::__construct()`, + `PHPParserPropertyMap::propertyMap()` and `ASTQueryBuilder::traverseIntoClass()`). +- `getReflection()` now catches `Throwable` rather than `Exception`. A file whose + parent class or trait cannot be autoloaded raises an `Error`, which previously + escaped and killed the entire query instead of skipping that one file. This + affects `LaravelFile::models()`, `controllers()` and `serviceProviders()`. +- `tests/Pest.php` no longer defines a global `context()` helper. Laravel 11 ships + its own `context()`, and the collision brought the whole suite down before a + single test could run. + +## [2.0.0] - 2024-05-11 + +### Changed + +- **Breaking:** upgraded to `nikic/php-parser` ^5.0. Thanks to @jasonvarga (#85). + +## [1.1.5] - 2022-08-24 + +Last release of the 1.x line, which requires `nikic/php-parser` ^4.11. + +1.x cannot be installed alongside anything that needs php-parser 5 — including +Pest 3 and newer. If Composer refuses to resolve `ajthinking/archetype`, upgrade +to 2.x. + +[Unreleased]: https://github.com/ajthinking/archetype/compare/v2.0.1...HEAD +[2.0.1]: https://github.com/ajthinking/archetype/compare/v2.0.0...v2.0.1 +[2.0.0]: https://github.com/ajthinking/archetype/compare/v1.1.5...v2.0.0 +[1.1.5]: https://github.com/ajthinking/archetype/releases/tag/v1.1.5 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..23253196 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) Anders Jürisoo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/composer.json b/composer.json index 9cf66098..50ffd980 100644 --- a/composer.json +++ b/composer.json @@ -17,14 +17,13 @@ } ], "require": { + "php": ">=7.4", "nikic/php-parser": "^5.0" }, "require-dev": { - "laravel/laravel": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "orchestra/testbench": "^4.0 || ^5.0 || ^6.0", - "pestphp/pest": "^1.21", - "phpstan/phpstan": "^1.6", - "phpunit/phpunit": "^8.0 || ^9.5" + "orchestra/testbench": "^8.0 || ^9.0 || ^10.0", + "pestphp/pest": "^2.0 || ^3.0", + "phpstan/phpstan": "^1.11 || ^2.0" }, "config": { "optimize-autoloader": true, @@ -44,15 +43,30 @@ }, "autoload": { "psr-4": { - "Archetype\\": "src/", - "Archetype\\Tests\\": "tests/" - } + "Archetype\\": "src/" + }, + "exclude-from-classmap": [ + "src/snippets/" + ] }, "autoload-dev": { "psr-4": { - "Tests\\": "tests/" - } + "Archetype\\Tests\\": "tests/", + "App\\": "tests/fixtures/laravel/app/" + }, + "files": [ + "tests/stubs/laravel-sanctum.php" + ], + "exclude-from-classmap": [ + "tests/fixtures/laravel/database/", + "tests/fixtures/laravel/public/", + "tests/stubs/" + ] + }, + "scripts": { + "test": "pest", + "analyse": "phpstan analyse" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "prefer-stable": true } diff --git a/phpstan.neon b/phpstan.neon index f3cb1ef7..3c5177a2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,5 +3,9 @@ parameters: paths: - src - tests + excludePaths: + # A pinned copy of a Laravel application skeleton, used as test input. + # It is data for the parser, not code we maintain. + - tests/fixtures/* ignoreErrors: - - '#Dummy not found#' \ No newline at end of file + - '#Dummy not found#' diff --git a/phpunit.xml b/phpunit.xml index 7f1309d8..c1aa23ca 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,15 +1,12 @@ + stopOnFailure="false" + cacheDirectory=".phpunit.cache"> ./tests/Unit @@ -19,9 +16,9 @@ ./tests/Feature - - + + ./src - - + + diff --git a/readme.md b/readme.md index 9d413118..95df41b9 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ ### Enabling Rapid-Application-Development-tools, PR-bots, code analyzers and other things -![tests](https://github.com/ajthinking/archetype/workflows/tests/badge.svg) +[![tests](https://github.com/ajthinking/archetype/actions/workflows/tests.yml/badge.svg)](https://github.com/ajthinking/archetype/actions/workflows/tests.yml) ![version](https://img.shields.io/packagist/v/ajthinking/archetype?color=blue) [![Total Downloads](https://img.shields.io/packagist/dt/ajthinking/archetype.svg)](https://packagist.org/packages/ajthinking/archetype) @@ -16,6 +16,18 @@ composer require ajthinking/archetype > That's it! Check out introduction of concepts below or review the [API examples](docs.md) + +## Supported versions + +| Archetype | PHP | Laravel | php-parser | +| --------- | ------- | -------- | ---------- | +| 2.x | 8.1–8.4 | 10, 11, 12 | ^5.0 | +| 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 +> cannot be installed alongside anything that needs php-parser 5 — Pest 3 and +> newer included. If Composer refuses to resolve `ajthinking/archetype`, that is +> why. The 1.x → 2.x upgrade requires no changes to your own code. ## `PHPFile` read/write API diff --git a/src/Drivers/FileInput.php b/src/Drivers/FileInput.php index dabf4fb8..f0e470ee 100644 --- a/src/Drivers/FileInput.php +++ b/src/Drivers/FileInput.php @@ -30,7 +30,7 @@ public function readPath($path = null): self return $this; } - public function load(string $location = null) + public function load(?string $location = null) { $this->extractPathProperties($location); diff --git a/src/Drivers/InputInterface.php b/src/Drivers/InputInterface.php index 97692094..93a3f0d8 100644 --- a/src/Drivers/InputInterface.php +++ b/src/Drivers/InputInterface.php @@ -4,5 +4,5 @@ interface InputInterface { - public function load(string $path = null); + public function load(?string $path = null); } diff --git a/src/Endpoints/EndpointProvider.php b/src/Endpoints/EndpointProvider.php index c83a7933..113842ed 100644 --- a/src/Endpoints/EndpointProvider.php +++ b/src/Endpoints/EndpointProvider.php @@ -13,7 +13,7 @@ abstract class EndpointProvider protected $directives; - public function __construct(PHPFile $file = null) + public function __construct(?PHPFile $file = null) { $this->file = $file; diff --git a/src/Endpoints/PHP/Namespace_.php b/src/Endpoints/PHP/Namespace_.php index bbf36d58..9eb93b40 100644 --- a/src/Endpoints/PHP/Namespace_.php +++ b/src/Endpoints/PHP/Namespace_.php @@ -20,7 +20,7 @@ class Namespace_ extends EndpointProvider * @param string $value * @return mixed */ - public function namespace(string $value = null) + public function namespace(?string $value = null) { if ($this->file->directive('remove')) { return $this->remove(); diff --git a/src/Endpoints/PHP/ReflectionProxy.php b/src/Endpoints/PHP/ReflectionProxy.php index d40041eb..c9e9f8ef 100644 --- a/src/Endpoints/PHP/ReflectionProxy.php +++ b/src/Endpoints/PHP/ReflectionProxy.php @@ -4,7 +4,7 @@ use Archetype\Endpoints\EndpointProvider; use ReflectionClass; -use Exception; +use Throwable; class ReflectionProxy extends EndpointProvider { @@ -20,7 +20,11 @@ public function getReflection() try { return $class ? new ReflectionClass($class) : null; - } catch (Exception $e) { + } catch (Throwable $e) { + // Autoloading the class can fail outright rather than just miss — + // a missing parent class or trait raises an Error, not an Exception. + // A file we cannot reflect on is one we skip, never one that kills + // the whole query. return null; } } diff --git a/src/PHPFile.php b/src/PHPFile.php index ff23c762..722a05e3 100644 --- a/src/PHPFile.php +++ b/src/PHPFile.php @@ -123,7 +123,7 @@ public function useTrait($value = null) return $handler->useTrait($value); } - public function namespace(string $value = null) + public function namespace(?string $value = null) { $handler = new Namespace_($this); return $handler->namespace($value); diff --git a/src/Support/AST/ASTQueryBuilder.php b/src/Support/AST/ASTQueryBuilder.php index 1195e62b..5efd8620 100644 --- a/src/Support/AST/ASTQueryBuilder.php +++ b/src/Support/AST/ASTQueryBuilder.php @@ -72,7 +72,7 @@ public function __get(string $name) throw new Exception("Could not find a property $property in the ASTQueryBuilder!"); } - public function traverseIntoClass($expectedClass, string $path = null): self + public function traverseIntoClass($expectedClass, ?string $path = null): self { $steps = $path ? collect(explode('->', $path)) : collect(); diff --git a/src/Traits/PHPParserClassMap.php b/src/Traits/PHPParserClassMap.php index 0711c915..12a57404 100644 --- a/src/Traits/PHPParserClassMap.php +++ b/src/Traits/PHPParserClassMap.php @@ -90,7 +90,8 @@ trait PHPParserClassMap 'string' => \PhpParser\Node\Scalar\String_::class, 'switch' => \PhpParser\Node\Stmt\Switch_::class, 'ternary' => \PhpParser\Node\Expr\Ternary::class, - 'throw' => \PhpParser\Node\Stmt\Throw_::class, + // php-parser 5 dropped Stmt\Throw_; throw is only ever an expression now. + 'throw' => \PhpParser\Node\Expr\Throw_::class, 'trait' => \PhpParser\Node\Stmt\Trait_::class, 'traitUse' => \PhpParser\Node\Stmt\TraitUse::class, 'traitUseAdaptation' => \PhpParser\Node\Stmt\TraitUseAdaptation::class, diff --git a/src/Traits/PHPParserPropertyMap.php b/src/Traits/PHPParserPropertyMap.php index 530718fd..34befe45 100644 --- a/src/Traits/PHPParserPropertyMap.php +++ b/src/Traits/PHPParserPropertyMap.php @@ -4,7 +4,7 @@ trait PHPParserPropertyMap { - public function propertyMap(string $property = null) + public function propertyMap(?string $property = null) { $map = [ 'expr', diff --git a/src/config/archetype.php b/src/config/archetype.php index 3e974153..28a9992d 100644 --- a/src/config/archetype.php +++ b/src/config/archetype.php @@ -59,8 +59,8 @@ 'class_root' => '', // Laravel - 'commands_root' => 'app/HTTP/Controllers', - 'controllers_root' => 'app/HTTP/Controllers', + 'commands_root' => 'app/Console/Commands', + 'controllers_root' => 'app/Http/Controllers', 'factories_root' => 'database/factories', 'migrations_root' => 'database/migrations', 'models_root' => 'app/Models', diff --git a/tests/Pest.php b/tests/Pest.php index fe9c17a7..85c43afc 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -4,18 +4,4 @@ use Archetype\Tests\TestCase; -if (!function_exists('context')) { - function context(string $description, Closure $closure) - { - $closure(); - } -} - -if (!function_exists('describe')) { - function describe(string $description, Closure $closure) - { - $closure(); - } -} - -uses(TestCase::class)->in(__DIR__); \ No newline at end of file +uses(TestCase::class)->in(__DIR__); diff --git a/tests/Support/TestablePHPFile.php b/tests/Support/TestablePHPFile.php index 66e5f586..1d39c2b3 100644 --- a/tests/Support/TestablePHPFile.php +++ b/tests/Support/TestablePHPFile.php @@ -32,7 +32,7 @@ public function assertDirectives($expectedMap) return $this; } - public function assertExtends(string $expected = null) + public function assertExtends(?string $expected = null) { assertEquals($expected, $this->extends()); @@ -58,21 +58,21 @@ public function assertClassConstant(string $name, $value) return $this; } - public function assertImplements(array $expected = null) + public function assertImplements(?array $expected = null) { assertEquals($expected, $this->implements()); return $this; } - public function assertClassName(string $name = null) + public function assertClassName(?string $name = null) { assertEquals($name, $this->className()); return $this; } - public function assertMethodNames(array $expected = null) + public function assertMethodNames(?array $expected = null) { assertEquals($expected, $this->methodNames()); @@ -137,14 +137,14 @@ public function assertContains(string $string) return $this; } - public function assertUse(array $expected = null) + public function assertUse(?array $expected = null) { assertEquals($expected, $this->use()); return $this; } - public function assertUseTrait(array $expected = null) + public function assertUseTrait(?array $expected = null) { assertEquals($expected, $this->useTrait()); @@ -183,7 +183,7 @@ public function assertMultilineArray($name) return $this; } - public function assertNamespace(string $expected = null) + public function assertNamespace(?string $expected = null) { assertEquals($expected, $this->namespace()); diff --git a/tests/TestCase.php b/tests/TestCase.php index 7af7863c..b4c3780c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -43,11 +43,20 @@ protected function registerTestFacades() protected function setupLaravelDirectories() { + $package = dirname(__DIR__); + $fixtures = __DIR__.'/fixtures/laravel'; + File::ensureDirectoryExists(base_path('vendor/ajthinking/archetype/src/snippets')); - File::copyDirectory(base_path('./../../../../src/snippets/'), base_path('vendor/ajthinking/archetype/src/snippets')); + File::copyDirectory($package.'/src/snippets', base_path('vendor/ajthinking/archetype/src/snippets')); + + // The suite asserts on exact file counts and on the contents of the + // application skeleton. Testbench ships its own skeleton, and Laravel + // reshapes it every major version, so replace it wholesale with the + // pinned fixture app to keep those assertions meaningful. + File::deleteDirectory(base_path('app')); - collect(['app', 'database/migrations','public'])->each(function ($path) { - File::copyDirectory(base_path('./../../../../vendor/laravel/laravel/' . $path), base_path($path)); + collect(['app', 'database/migrations', 'public'])->each(function ($path) use ($fixtures) { + File::copyDirectory($fixtures.'/'.$path, base_path($path)); }); } diff --git a/tests/Unit/Support/AST/ASTQueryBuilderTest.php b/tests/Unit/Support/AST/ASTQueryBuilderTest.php index 5687269f..3a65bd53 100644 --- a/tests/Unit/Support/AST/ASTQueryBuilderTest.php +++ b/tests/Unit/Support/AST/ASTQueryBuilderTest.php @@ -59,6 +59,15 @@ ->assertMatchCount(1); }); +it('can query throw expressions', function() { + // php-parser 5 removed Stmt\Throw_ in favour of Expr\Throw_, so the short + // name has to resolve to the expression node. + PHPFile::fromString('throw new Exception("nope");') + ->astQuery() + ->throw() + ->assertMatchCount(1); +}); + it('can traverse into property when result is an array', function() { PHPFile::fromString('1;2;')->astQuery() // Two(!) Expression:s ->expr @@ -73,7 +82,7 @@ ->assertMatchCount(1); }); -context('when searching method chains', function() { +describe('when searching method chains', function() { it('will match all methodCalls by default', function() { PHPFile::fromString('$lets->go()->go()->go()') ->astQuery() diff --git a/tests/fixtures/laravel/app/Console/Kernel.php b/tests/fixtures/laravel/app/Console/Kernel.php new file mode 100644 index 00000000..d8bc1d29 --- /dev/null +++ b/tests/fixtures/laravel/app/Console/Kernel.php @@ -0,0 +1,32 @@ +command('inspire')->hourly(); + } + + /** + * Register the commands for the application. + * + * @return void + */ + protected function commands() + { + $this->load(__DIR__.'/Commands'); + + require base_path('routes/console.php'); + } +} diff --git a/tests/fixtures/laravel/app/Exceptions/Handler.php b/tests/fixtures/laravel/app/Exceptions/Handler.php new file mode 100644 index 00000000..8e7fbd1b --- /dev/null +++ b/tests/fixtures/laravel/app/Exceptions/Handler.php @@ -0,0 +1,41 @@ +> + */ + protected $dontReport = [ + // + ]; + + /** + * A list of the inputs that are never flashed for validation exceptions. + * + * @var array + */ + protected $dontFlash = [ + 'current_password', + 'password', + 'password_confirmation', + ]; + + /** + * Register the exception handling callbacks for the application. + * + * @return void + */ + public function register() + { + $this->reportable(function (Throwable $e) { + // + }); + } +} diff --git a/tests/fixtures/laravel/app/Http/Controllers/Controller.php b/tests/fixtures/laravel/app/Http/Controllers/Controller.php new file mode 100644 index 00000000..a0a2a8a3 --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Controllers/Controller.php @@ -0,0 +1,13 @@ + + */ + protected $middleware = [ + // \App\Http\Middleware\TrustHosts::class, + \App\Http\Middleware\TrustProxies::class, + \Fruitcake\Cors\HandleCors::class, + \App\Http\Middleware\PreventRequestsDuringMaintenance::class, + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, + \App\Http\Middleware\TrimStrings::class, + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + ]; + + /** + * The application's route middleware groups. + * + * @var array> + */ + protected $middlewareGroups = [ + 'web' => [ + \App\Http\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + // \Illuminate\Session\Middleware\AuthenticateSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + + 'api' => [ + // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, + 'throttle:api', + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + ]; + + /** + * The application's route middleware. + * + * These middleware may be assigned to groups or used individually. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, + 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + ]; +} diff --git a/tests/fixtures/laravel/app/Http/Middleware/Authenticate.php b/tests/fixtures/laravel/app/Http/Middleware/Authenticate.php new file mode 100644 index 00000000..704089a7 --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Middleware/Authenticate.php @@ -0,0 +1,21 @@ +expectsJson()) { + return route('login'); + } + } +} diff --git a/tests/fixtures/laravel/app/Http/Middleware/EncryptCookies.php b/tests/fixtures/laravel/app/Http/Middleware/EncryptCookies.php new file mode 100644 index 00000000..867695bd --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Middleware/EncryptCookies.php @@ -0,0 +1,17 @@ + + */ + protected $except = [ + // + ]; +} diff --git a/tests/fixtures/laravel/app/Http/Middleware/PreventRequestsDuringMaintenance.php b/tests/fixtures/laravel/app/Http/Middleware/PreventRequestsDuringMaintenance.php new file mode 100644 index 00000000..74cbd9a9 --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -0,0 +1,17 @@ + + */ + protected $except = [ + // + ]; +} diff --git a/tests/fixtures/laravel/app/Http/Middleware/RedirectIfAuthenticated.php b/tests/fixtures/laravel/app/Http/Middleware/RedirectIfAuthenticated.php new file mode 100644 index 00000000..a2813a06 --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Middleware/RedirectIfAuthenticated.php @@ -0,0 +1,32 @@ +check()) { + return redirect(RouteServiceProvider::HOME); + } + } + + return $next($request); + } +} diff --git a/tests/fixtures/laravel/app/Http/Middleware/TrimStrings.php b/tests/fixtures/laravel/app/Http/Middleware/TrimStrings.php new file mode 100644 index 00000000..88cadcaa --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Middleware/TrimStrings.php @@ -0,0 +1,19 @@ + + */ + protected $except = [ + 'current_password', + 'password', + 'password_confirmation', + ]; +} diff --git a/tests/fixtures/laravel/app/Http/Middleware/TrustHosts.php b/tests/fixtures/laravel/app/Http/Middleware/TrustHosts.php new file mode 100644 index 00000000..7186414c --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Middleware/TrustHosts.php @@ -0,0 +1,20 @@ + + */ + public function hosts() + { + return [ + $this->allSubdomainsOfApplicationUrl(), + ]; + } +} diff --git a/tests/fixtures/laravel/app/Http/Middleware/TrustProxies.php b/tests/fixtures/laravel/app/Http/Middleware/TrustProxies.php new file mode 100644 index 00000000..3391630e --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Middleware/TrustProxies.php @@ -0,0 +1,28 @@ +|string|null + */ + protected $proxies; + + /** + * The headers that should be used to detect proxies. + * + * @var int + */ + protected $headers = + Request::HEADER_X_FORWARDED_FOR | + Request::HEADER_X_FORWARDED_HOST | + Request::HEADER_X_FORWARDED_PORT | + Request::HEADER_X_FORWARDED_PROTO | + Request::HEADER_X_FORWARDED_AWS_ELB; +} diff --git a/tests/fixtures/laravel/app/Http/Middleware/VerifyCsrfToken.php b/tests/fixtures/laravel/app/Http/Middleware/VerifyCsrfToken.php new file mode 100644 index 00000000..9e865217 --- /dev/null +++ b/tests/fixtures/laravel/app/Http/Middleware/VerifyCsrfToken.php @@ -0,0 +1,17 @@ + + */ + protected $except = [ + // + ]; +} diff --git a/tests/fixtures/laravel/app/Models/User.php b/tests/fixtures/laravel/app/Models/User.php new file mode 100644 index 00000000..89963686 --- /dev/null +++ b/tests/fixtures/laravel/app/Models/User.php @@ -0,0 +1,44 @@ + + */ + protected $fillable = [ + 'name', + 'email', + 'password', + ]; + + /** + * The attributes that should be hidden for serialization. + * + * @var array + */ + protected $hidden = [ + 'password', + 'remember_token', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'email_verified_at' => 'datetime', + ]; +} diff --git a/tests/fixtures/laravel/app/Providers/AppServiceProvider.php b/tests/fixtures/laravel/app/Providers/AppServiceProvider.php new file mode 100644 index 00000000..ee8ca5bc --- /dev/null +++ b/tests/fixtures/laravel/app/Providers/AppServiceProvider.php @@ -0,0 +1,28 @@ + + */ + protected $policies = [ + // 'App\Models\Model' => 'App\Policies\ModelPolicy', + ]; + + /** + * Register any authentication / authorization services. + * + * @return void + */ + public function boot() + { + $this->registerPolicies(); + + // + } +} diff --git a/tests/fixtures/laravel/app/Providers/BroadcastServiceProvider.php b/tests/fixtures/laravel/app/Providers/BroadcastServiceProvider.php new file mode 100644 index 00000000..395c518b --- /dev/null +++ b/tests/fixtures/laravel/app/Providers/BroadcastServiceProvider.php @@ -0,0 +1,21 @@ +> + */ + protected $listen = [ + Registered::class => [ + SendEmailVerificationNotification::class, + ], + ]; + + /** + * Register any events for your application. + * + * @return void + */ + public function boot() + { + // + } +} diff --git a/tests/fixtures/laravel/app/Providers/RouteServiceProvider.php b/tests/fixtures/laravel/app/Providers/RouteServiceProvider.php new file mode 100644 index 00000000..3bd3c81e --- /dev/null +++ b/tests/fixtures/laravel/app/Providers/RouteServiceProvider.php @@ -0,0 +1,63 @@ +configureRateLimiting(); + + $this->routes(function () { + Route::prefix('api') + ->middleware('api') + ->namespace($this->namespace) + ->group(base_path('routes/api.php')); + + Route::middleware('web') + ->namespace($this->namespace) + ->group(base_path('routes/web.php')); + }); + } + + /** + * Configure the rate limiters for the application. + * + * @return void + */ + protected function configureRateLimiting() + { + RateLimiter::for('api', function (Request $request) { + return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); + }); + } +} diff --git a/tests/fixtures/laravel/database/migrations/2014_10_12_000000_create_users_table.php b/tests/fixtures/laravel/database/migrations/2014_10_12_000000_create_users_table.php new file mode 100644 index 00000000..621a24eb --- /dev/null +++ b/tests/fixtures/laravel/database/migrations/2014_10_12_000000_create_users_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('name'); + $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); + $table->string('password'); + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('users'); + } +} diff --git a/tests/fixtures/laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php b/tests/fixtures/laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php new file mode 100644 index 00000000..0ee0a36a --- /dev/null +++ b/tests/fixtures/laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -0,0 +1,32 @@ +string('email')->index(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('password_resets'); + } +} diff --git a/tests/fixtures/laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/tests/fixtures/laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php new file mode 100644 index 00000000..6aa6d743 --- /dev/null +++ b/tests/fixtures/laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('uuid')->unique(); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('failed_jobs'); + } +} diff --git a/tests/fixtures/laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/tests/fixtures/laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php new file mode 100644 index 00000000..4315e16a --- /dev/null +++ b/tests/fixtures/laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -0,0 +1,36 @@ +id(); + $table->morphs('tokenable'); + $table->string('name'); + $table->string('token', 64)->unique(); + $table->text('abilities')->nullable(); + $table->timestamp('last_used_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('personal_access_tokens'); + } +} diff --git a/tests/fixtures/laravel/public/index.php b/tests/fixtures/laravel/public/index.php new file mode 100644 index 00000000..1d69f3a2 --- /dev/null +++ b/tests/fixtures/laravel/public/index.php @@ -0,0 +1,55 @@ +make(Kernel::class); + +$response = $kernel->handle( + $request = Request::capture() +)->send(); + +$kernel->terminate($request, $response); diff --git a/tests/stubs/laravel-sanctum.php b/tests/stubs/laravel-sanctum.php new file mode 100644 index 00000000..f6860cd6 --- /dev/null +++ b/tests/stubs/laravel-sanctum.php @@ -0,0 +1,16 @@ + Date: Tue, 25 Aug 2026 12:51:45 +0200 Subject: [PATCH 2/5] CI: allow installing EOL Laravel branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Composer 2.9 refuses to install any package with an open security advisory. Laravel 10 and 11 are both past security support, so every release in those branches is flagged and the whole matrix leg fails at dependency resolution — before a single test runs. Only Laravel 12 installs unmodified. Turn the policy off for the 10 and 11 legs. This is a compatibility matrix rather than a deployment, and enough applications are still on those versions that we want the coverage. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/tests.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c0449774..50b510c1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,6 +55,15 @@ jobs: key: composer-${{ matrix.os }}-php${{ matrix.php }}-laravel${{ matrix.laravel }}-${{ hashFiles('composer.json') }} restore-keys: composer-${{ matrix.os }}-php${{ matrix.php }}-laravel${{ matrix.laravel }}- + - name: Allow installing EOL Laravel branches + # Laravel 10 and 11 are past security support, so every release in those + # branches carries an open advisory and Composer 2.9+ declines to install + # them at all. This is a compatibility matrix rather than a deployment, + # and plenty of applications are still on those versions, so we want to + # know whether Archetype works there. Laravel 12 installs unmodified. + if: matrix.laravel != '12.*' + run: composer config policy.advisories.block false + - name: Install dependencies run: | composer require --dev --no-update --no-interaction \ From bcc3d5373a4c3a8a0f84699538c0b4cbda44c7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20J=C3=BCrisoo?= Date: Tue, 25 Aug 2026 16:44:31 +0200 Subject: [PATCH 3/5] Address review: raise php floor to ^8.1, fix changelog count Copilot was right that ">=7.4" was untrue. HasIO calls str_contains(), which is PHP 8.0, and nothing below 8.1 is tested or even installable for the dev tooling. Set "php": "^8.1" rather than ">=8.1". The upper bound is deliberate: PHP 9 removes dynamic properties, and the AST node-identity mechanism in HashInserter still writes $node->__object_hash. Better for Composer to decline the install than to hand someone a package that fatals. Verified this excludes nobody downstream. The earliest statamic/cms release allowing archetype ^2.0 is v5.1.0, which requires Laravel ^10.40 || ^11.0 and therefore PHP 8.1 at the lowest. A real statamic/cms ^5.1 resolution against this branch locks archetype 2.0.1. Also corrects the changelog, which said "Six" implicit-nullable parameters while listing seven, and updates the readme requirements section, which still claimed PHP 7.4 and Laravel 7. Co-Authored-By: Claude Opus 5 (1M context) --- CHANGELOG.md | 9 ++++++--- composer.json | 2 +- readme.md | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 483ead3c..533b4a09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,11 @@ Maintenance only. No API changes, and nothing here can break existing usage. - Support for PHP 8.2, 8.3 and 8.4, and for Laravel 10, 11 and 12 — now verified in CI across ten combinations rather than assumed. -- A `php` requirement (`>=7.4`) in `composer.json`. The package never declared - one, so Composer could not warn anybody. +- A `php` requirement (`^8.1`) in `composer.json`. The package never declared + one, so Composer could not warn anybody. 8.1 is the floor the code actually + needs and the whole range CI exercises; the upper bound is deliberate, because + PHP 9 removes dynamic properties and the AST node-identity mechanism still + relies on them. - `LICENSE.md`. The package has always been MIT; the file was missing. - This changelog. - `.github/dependabot.yml`, so dependency updates are configured rather than @@ -37,7 +40,7 @@ Maintenance only. No API changes, and nothing here can break existing usage. ### Fixed -- Six implicit-nullable parameters that raised deprecation notices on PHP 8.4 +- Seven implicit-nullable parameters that raised deprecation notices on PHP 8.4 (`PHPFile::namespace()`, `Namespace_::namespace()`, `FileInput::load()`, `InputInterface::load()`, `EndpointProvider::__construct()`, `PHPParserPropertyMap::propertyMap()` and `ASTQueryBuilder::traverseIntoClass()`). diff --git a/composer.json b/composer.json index 50ffd980..7fc56eaa 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": ">=7.4", + "php": "^8.1", "nikic/php-parser": "^5.0" }, "require-dev": { diff --git a/readme.md b/readme.md index 95df41b9..8c0184cf 100644 --- a/readme.md +++ b/readme.md @@ -206,10 +206,10 @@ To see *all* offending files run `php artisan archetype:errors`. To ignore files php artisan vendor:publish --provider="Archetype\ServiceProvider" ``` -## Requirmenst +## Requirements * UNIX filesystem -* PHP >= 7.4 -* Laravel >= 7 +* PHP >= 8.1 +* Laravel >= 10 ## Contributing PRs and issues are welcome :pray: Feel free to take a stab at an [incomplete test](https://github.com/ajthinking/archetype/search?q=%24this-%3EmarkTestIncomplete). From b1c32d2cae195241b6783b888ffb5353d69b7f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20J=C3=BCrisoo?= Date: Tue, 25 Aug 2026 17:02:47 +0200 Subject: [PATCH 4/5] Remove Twitter and GitHub Sponsors links from readme Co-Authored-By: Claude Opus 5 (1M context) --- readme.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/readme.md b/readme.md index 8c0184cf..7e884c8e 100644 --- a/readme.md +++ b/readme.md @@ -233,7 +233,3 @@ MIT ## Like this package? Star it :star: - -[Say hi: @ajthinking :gem:](https://twitter.com/ajthinking) - -[Github Sponsors :octocat::heart:](https://github.com/sponsors/ajthinking) From da61e3c19b7c7d7928f5cbcafa4d940fac1c014e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20J=C3=BCrisoo?= Date: Tue, 25 Aug 2026 17:11:29 +0200 Subject: [PATCH 5/5] Add Laravel 13 to the test matrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit statamic/cms 6 requires laravel/framework "^12.40.0 || ^13.0", and a real statamic/cms ^6.0 install resolves to Laravel 13.27.0 — so downstream users are already running Archetype there, untested. Verified it works before adding: 163 passing on Laravel 13 with testbench 11, same as every other leg. Widens the testbench dev constraint to allow ^11.0 and adds two legs (PHP 8.3 and 8.4; testbench 11 requires 8.3+). Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/tests.yml | 4 ++++ CHANGELOG.md | 5 +++-- composer.json | 2 +- readme.md | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 50b510c1..9cbdb025 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,6 +24,10 @@ 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 } + # 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 } # 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 533b4a09..2d5fa210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,9 @@ Maintenance only. No API changes, and nothing here can break existing usage. ### Added -- Support for PHP 8.2, 8.3 and 8.4, and for Laravel 10, 11 and 12 — now verified - in CI across ten combinations rather than assumed. +- Support for PHP 8.1 through 8.4, and for Laravel 10, 11, 12 and 13 — now + verified in CI across twelve combinations rather than assumed. Laravel 13 is + included because `statamic/cms` 6 already allows it. - A `php` requirement (`^8.1`) in `composer.json`. The package never declared one, so Composer could not warn anybody. 8.1 is the floor the code actually needs and the whole range CI exercises; the upper bound is deliberate, because diff --git a/composer.json b/composer.json index 7fc56eaa..3795160b 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "nikic/php-parser": "^5.0" }, "require-dev": { - "orchestra/testbench": "^8.0 || ^9.0 || ^10.0", + "orchestra/testbench": "^8.0 || ^9.0 || ^10.0 || ^11.0", "pestphp/pest": "^2.0 || ^3.0", "phpstan/phpstan": "^1.11 || ^2.0" }, diff --git a/readme.md b/readme.md index 7e884c8e..e900a389 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 | ^5.0 | +| 2.x | 8.1–8.4 | 10, 11, 12, 13 | ^5.0 | | 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