Skip to content

Fix PHPStan CI by restoring Larastan on the PHPStan 2 / Laravel 12 stack#255

Closed
freekmurze wants to merge 1 commit into
mainfrom
fix-ci
Closed

Fix PHPStan CI by restoring Larastan on the PHPStan 2 / Laravel 12 stack#255
freekmurze wants to merge 1 commit into
mainfrom
fix-ci

Conversation

@freekmurze

Copy link
Copy Markdown
Member

Problem

PHPStan CI on main is red. main was left in a mid-upgrade state: Larastan was dropped from require-dev (it was incompatible with Laravel 12), but phpstan.neon.dist still referenced Larastan-only options:

Invalid configuration:
Unexpected item 'parameters › checkOctaneCompatibility'.
Unexpected item 'parameters › checkModelProperties'.

So PHPStan failed to even load its config. Simply removing those options isn't enough either: without Larastan, PHPStan no longer understands Eloquent's magic statics and reports false positives (Call to an undefined static method ...::create(), ::where(), and @mixin \Eloquent unknown class).

Fix

Restore Larastan on the modern stack:

  • Add larastan/larastan: ^3.0 to require-dev. Larastan 3 supports Laravel 11.44+/12.4+ on PHPStan 2.x (Larastan 2 was the version that couldn't install on Laravel 12, which is why it was dropped).
  • Bump phpstan/phpstan-deprecation-rules and phpstan/phpstan-phpunit to ^2.0 to match PHPStan 2.
  • In phpstan.neon.dist: drop checkMissingIterableValueType (removed in PHPStan 2; not needed at level 5) and point Larastan's noEnvCallsOutsideOfConfig rule at the package's own config directory via configDirectories, so the idiomatic env() call in config/webhook-client.php isn't flagged.

Verification

Locally on PHP
Parse error: syntax error, unexpected token "" in Command line code on line 1:

  • vendor/bin/phpstan analyse[OK] No errors
  • vendor/bin/pest → 28 passed

The matrix (PHP 8.3 to 8.5 x Laravel 11/12) all satisfy Larastan 3's requirements (PHP ^8.2, illuminate ^11.44.2 || ^12.4.1).

main was left mid-upgrade: Larastan was dropped from require-dev (it was
incompatible with Laravel 12) but phpstan.neon.dist still referenced its
checkOctaneCompatibility and checkModelProperties options, so PHPStan
failed to even load its config.

Restore Larastan on the modern stack (larastan ^3.0, which supports
Laravel 11.44+/12.4+ on PHPStan 2.x) and bump the phpstan extension
packages to ^2.0 accordingly. Replace the removed checkMissingIterableValueType
option, and point Larastan's noEnvCallsOutsideOfConfig rule at the
package's own config directory so the idiomatic env() call in
config/webhook-client.php is not flagged.

PHPStan and the full test suite pass locally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@freekmurze

Copy link
Copy Markdown
Member Author

Closing: this was based on a stale local checkout. The PHPStan config error it addresses was already fixed on main (the Larastan options were dropped and ignoreErrors added for the Eloquent magic methods). The genuine remaining PHPStan failure on main is Laravel 13 compatibility, which I'm addressing in a fresh PR off current main.

@freekmurze freekmurze closed this Jun 3, 2026
@freekmurze freekmurze deleted the fix-ci branch June 3, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant