PHPackages                             jbboehr/phpstan-laravel-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. jbboehr/phpstan-laravel-validation

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

jbboehr/phpstan-laravel-validation
==================================

Laravel Validation extension for PHPStan

59.8k↓33.3%1[6 PRs](https://github.com/jbboehr/phpstan-laravel-validation/pulls)PHP

Since Sep 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jbboehr/phpstan-laravel-validation)[ Packagist](https://packagist.org/packages/jbboehr/phpstan-laravel-validation)[ RSS](/packages/jbboehr-phpstan-laravel-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (7)Used By (0)

phpstan-laravel-validation
==========================

[](#phpstan-laravel-validation)

[![ci](https://github.com/jbboehr/phpstan-laravel-validation/actions/workflows/ci.yml/badge.svg)](https://github.com/jbboehr/phpstan-laravel-validation/actions/workflows/ci.yml)[![License: AGPL v3+](https://camo.githubusercontent.com/804e16c3c0324eb20ab6b4366bc15bd122b822188a5d6d0d057675a242577b73/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4147504c5f76332532622d626c75652e737667)](https://www.gnu.org/licenses/agpl-3.0)[![stability-experimental](https://camo.githubusercontent.com/0daa00e91aa931aeb2d321edc5a2ce6fe8fb4037fc35c084c4a01cde1621ac98/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73746162696c6974792d6578706572696d656e74616c2d6f72616e67652e737667)](https://camo.githubusercontent.com/0daa00e91aa931aeb2d321edc5a2ce6fe8fb4037fc35c084c4a01cde1621ac98/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73746162696c6974792d6578706572696d656e74616c2d6f72616e67652e737667)

Explanation
-----------

[](#explanation)

If the rules given to a laravel validator are a constant expression, then the shape of the array returned by `\Illuminate\Validation\Validator::validated()` is known at compile-time, and can be statically analyzed.

```
$request = new \Illuminate\Http\Request();

$data = \Illuminate\Support\Facades\Validator::make($request->all(), [
    'person.*.email' => 'required|email|unique:users',
    'person.*.first_name' => 'required|string',
    'person.*.age' => 'required|integer|string',
])->validated();

\PHPStan\dumpType($data);
// array{person: array}

$data = $request->validate([
    'person.*.email' => 'required|email|unique:users',
    'person.*.first_name' => 'required|string',
    'person.*.age' => 'required|integer|string',
]);

\PHPStan\dumpType($data);
// array{person: array}
```

If the input data does not match the rules array, an `\Illuminate\Validation\ValidationException` is thrown, thus preserving type safety.

Installation
------------

[](#installation)

To use this extension, require it in [Composer](https://getcomposer.org/):

```
composer require --dev jbboehr/phpstan-laravel-validation
```

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

### Manual installation

[](#manual-installation)

If you don't want to use `phpstan/extension-installer`, include `extension.neon` in your project's PHPStan config:

```
includes:
    - vendor/jbboehr/phpstan-laravel-validation/extension.neon
```

Caveats
-------

[](#caveats)

- Laravel's validation does not cast anything, so, for example, `numeric` produces the type union `int|float|numeric-string`. If you know it will always be a string, you can refine the type by using `numeric|string` and get a plain `numeric-string`.
- Wildcards must be indexed by integer and can't be mixed with non-wildcard rules.
- Custom validation rules, implicit rules, and enums are not currently supported.

License
-------

[](#license)

This project is licensed under the [AGPL v3+](https://www.gnu.org/licenses/agpl-3.0) License - see the LICENSE.md file for details.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 89.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ccc4aa01c69052830471c5ba84c4af824796d46d9920dc8574cb6e368281ab79?d=identicon)[jbboehr](/maintainers/jbboehr)

---

Top Contributors

[![jbboehr](https://avatars.githubusercontent.com/u/225601?v=4)](https://github.com/jbboehr "jbboehr (25 commits)")[![momala454](https://avatars.githubusercontent.com/u/83005?v=4)](https://github.com/momala454 "momala454 (3 commits)")

---

Tags

laravellaravel-frameworkphpphp8phpstanphpstan-extension

### Embed Badge

![Health badge](/badges/jbboehr-phpstan-laravel-validation/health.svg)

```
[![Health](https://phpackages.com/badges/jbboehr-phpstan-laravel-validation/health.svg)](https://phpackages.com/packages/jbboehr-phpstan-laravel-validation)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M679](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M571](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.0k](/packages/orchestra-testbench)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
