Skip to content

Add Larastan to enforce opinionated coding standards#31

Open
thinkstylestudio wants to merge 3 commits into
developfrom
feature/add-larastan-8697
Open

Add Larastan to enforce opinionated coding standards#31
thinkstylestudio wants to merge 3 commits into
developfrom
feature/add-larastan-8697

Conversation

@thinkstylestudio
Copy link
Copy Markdown

Closes #11

Summary

Adds Larastan (larastan/larastan ^3.0), the maintained successor to the abandoned nunomaduro/larastan package, for static analysis of Laravel code.

Configuration

  • phpstan.neon.dist at level 6 with Larastan extension and opinionated rules:
    • checkModelProperties
    • checkModelMethodVisibility
    • checkConfigTypes
    • Built-in Larastan rules (noEnvCallsOutsideOfConfig, noModelMake, etc.)
  • Analyzes app/, config/, database/, and routes/

Usage

composer analyse
# or with Lando
lando analyse

CI

Adds a GitHub Actions workflow (.github/workflows/phpstan.yml) that runs composer analyse on pushes to main and on pull requests.

Code fixes

Resolved existing PHPStan issues so analysis passes without a baseline, including return types, model PHPDocs, Filament form component typing, and a commented-out Spatie\LaravelData\Data cast (package not installed).

Open in Web Open in Cursor 

Justin Rhodes and others added 3 commits August 11, 2025 21:01
Install larastan/larastan (successor to nunomaduro/larastan) with PHPStan
level 6 and Larastan rules for model visibility, config types, and env usage.

Fix existing type issues so analysis passes cleanly, add composer analyse
script, Lando tooling, and a GitHub Actions workflow to enforce on PRs.

Co-authored-by: Theron Smith <theron+github@thinkstylestudio.com>
Comment thread config/settings.php
DateTimeZone::class => Spatie\LaravelSettings\SettingsCasts\DateTimeZoneCast::class,
// Spatie\DataTransferObject\DataTransferObject::class => Spatie\LaravelSettings\SettingsCasts\DtoCast::class,
Spatie\LaravelData\Data::class => Spatie\LaravelSettings\SettingsCasts\DataCast::class,
// Spatie\LaravelData\Data::class => Spatie\LaravelSettings\SettingsCasts\DataCast::class,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check that these are not needed.

@thinkstylestudio thinkstylestudio marked this pull request as ready for review May 20, 2026 07:01
@thinkstylestudio thinkstylestudio self-assigned this May 20, 2026
@thinkstylestudio thinkstylestudio changed the base branch from main to develop May 20, 2026 07:14
@dpellenwood dpellenwood requested a review from travisred May 22, 2026 15:24
Copy link
Copy Markdown

@dpellenwood dpellenwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍏

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: re: PHP version.

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.

Add Larastan to enforce opinionated coding standards

3 participants