Search by

noldors / phpstan-extension

noldors

Custom PHPStan rules for PHP and Laravel projects.

Package info

github.com/noldor/phpstan-extension

Type:phpstan-extension

pkg:composer/noldors/phpstan-extension

Statistics

Installs: 43

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.8.0 2026-10-29 19:41 UTC

README

Custom PHPStan rule sets for PHP and Laravel projects. Requires PHP >=8.5, ext-mbstring and PHPStan ^2.3.

Installation

composer require --dev noldors/phpstan-extension

Connection

For a PHP project, add to phpstan.neon:

includes:
    - vendor/noldors/phpstan-extension/src/php.neon

parameters:
    paths:
        - src

For a Laravel project, use the Laravel set, which also includes the PHP set:

includes:
    - vendor/noldors/phpstan-extension/src/laravel.neon

parameters:
    paths:
        - app
        - src

Keep only existing project directories in paths. The PHP set checks reference parameters, exception translation and mandatory JSON error flags. Its collection and DTO checks require explicit owner/DTO scopes; see the rule documentation. The PHP set also enables TLS, full-request logging, assertion and PHPUnit provider safety checks. Database builder mock checks require explicit test scopes. The Laravel set also enables validation placement checks and adds infrastructure APIs to the DTO configuration. Its PostgreSQL instant check requires explicitly configured application-owned paths; see the rule documentation. Keep your existing Larastan configuration when analysing Laravel APIs. Application contract checks require explicit role scopes.

For the complete opt-in Eloquent model checks, install Larastan ^3.13.2 and use the property bridge on Laravel 13.38+:

includes:
    - vendor/larastan/larastan/extension.neon
    - vendor/noldors/phpstan-extension/src/laravel-model-properties.neon

parameters:
    paths: [app, database/factories]
    noldors:
        eloquent:
            modelNamespaces: [App\Models]

See Eloquent configuration and coverage and the complete Laravel attribute catalog.

The sets are opt-in. Existing src/rules.neon includes remain supported and load the Laravel set.

Documentation

See the rule documentation for the rule catalogue, examples and configuration options.

Development

composer install
composer format
composer check

check runs Pint, PHPStan at maximum level, Phanalist and PHPUnit. Tests run in random order. Intentionally invalid fixtures are excluded from direct static analysis and formatting and are analysed by the rule tests instead.

Laravel is a development-only dependency. Lighthouse is represented by a minimal test-only validator stub loaded via autoload-dev; the tests check inheritance detection, not Lighthouse's runtime behaviour. Neither framework is installed when this package is used as a dependency.

Distribution

Composer and Git dist archives contain only composer.json, MIT license.txt and src/, including all rule-set configuration files. Documentation, tests, tooling and dependencies stay in the source checkout. archive.exclude and .gitattributes enforce this allowlist. A source checkout (--prefer-source) contains the full repository.

See license.txt.

Releases

Work happens on branches from master, through PRs with passing quality checks and tests. After an ordinary merge, GitHub Actions checks master again, creates a SemVer tag and verifies its publication through the Packagist webhook. See the release workflow and activation guide.