PHPackages                             canvural/larastan-strict-rules - 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. canvural/larastan-strict-rules

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

canvural/larastan-strict-rules
==============================

Extra strict and opinionated PHPStan rules for Laravel.

3.0.3(1y ago)891.0M↑20.2%6[1 issues](https://github.com/canvural/larastan-strict-rules/issues)[2 PRs](https://github.com/canvural/larastan-strict-rules/pulls)4MITPHPPHP ^8.2CI passing

Since Jun 20Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/canvural/larastan-strict-rules)[ Packagist](https://packagist.org/packages/canvural/larastan-strict-rules)[ Fund](https://www.paypal.me/canvural)[ GitHub Sponsors](https://github.com/canvural)[ RSS](/packages/canvural-larastan-strict-rules/feed)WikiDiscussions 2.2.x Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (42)Used By (4)

larastan-strict-rules
---------------------

[](#larastan-strict-rules)

Extra strict and opinionated PHPStan rules for Laravel.

[![Tests](https://github.com/canvural/larastan-strict-rules/workflows/Tests/badge.svg)](https://github.com/canvural/larastan-strict-rules/actions)[![codecov](https://camo.githubusercontent.com/21e2ba6773a164be8986d4b09698137252b9be76fc864a290c2ec1227b944258/68747470733a2f2f636f6465636f762e696f2f67682f63616e767572616c2f6c6172617374616e2d7374726963742d72756c65732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/canvural/larastan-strict-rules)[![PHPStan](https://camo.githubusercontent.com/d300bb2a4c15228ad2fa238fe49f1aa67ea3fb95332a246ab4303af0d3a0178e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d627269676874677265656e2e7376673f7374796c653d666c6174266c6f676f3d706870)](https://phpstan.org)

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

[](#installation)

You can install the package via composer:

```
composer require --dev canvural/larastan-strict-rules
```

To enable all the rules, include `rules.neon` in your project's PHPStan config:

```
includes:
    - vendor/canvural/larastan-strict-rules/rules.neon
```

Disabling rules
---------------

[](#disabling-rules)

You can disable rules using configuration parameters:

```
parameters:
    larastanStrictRules:
        noDynamicWhere: false
        noFacade: false
        noGlobalLaravelFunction: false
        noLocalQueryScope: false
        noPropertyAccessor: false
        noValidationInController: false
        scopeShouldReturnQueryBuilder: false
        listenerShouldHaveVoidReturnType: false
```

Enabling rules one-by-one
-------------------------

[](#enabling-rules-one-by-one)

If you don't want to start using all the available strict rules at once but only one or two, you can!

You can disable all rules from the included `rules.neon` with:

```
parameters:
	larastanStrictRules:
		allRules: false
```

Then you can re-enable individual rules with configuration parameters:

```
parameters:
	larastanStrictRules:
		allRules: false
		noDynamicWhere: true
```

Rules
-----

[](#rules)

#### `NoDynamicWhereRule`

[](#nodynamicwhererule)

This rule disallows the usage of dynamic where methods on Eloquent query builder.

#### `NoFacadeRule`

[](#nofacaderule)

This rule disallows the usage of Laravel Facades. Also, checks for the real time facade usage.

#### `NoGlobalLaravelFunctionRule`

[](#nogloballaravelfunctionrule)

This rule disallows the usage of global helper functions that comes with Laravel.

If you want to allow some functions, you can use the `allowedGlobalFunctions` parameter. Like so:

```
parameters:
    allowedGlobalFunctions:
        - app
        - event
```

#### `NoValidationInControllerRule`

[](#novalidationincontrollerrule)

This rule disallows validating the request in controllers.

#### `ScopeShouldReturnQueryBuilderRule`

[](#scopeshouldreturnquerybuilderrule)

This rule makes sure `Illuminate\Database\Eloquent\Builder` instance is returned from `Eloquent` local query scopes.

#### `NoLocalQueryScopeRule`

[](#nolocalqueryscoperule)

This rule disallows the usage of local model query scopes all together.

#### `NoPropertyAccessorRule`

[](#nopropertyaccessorrule)

This rule disallows the usage of model property accessors.

#### `ListenerShouldHaveVoidReturnTypeRule`

[](#listenershouldhavevoidreturntyperule)

This rule makes sure your event listeners have a void return type.

If you return `false` from an event listener, Laravel will stop the propagation of an event to other listeners. Sometimes this can be useful. But other time it can cause bugs that you will need to debug for hours. So this opinionated rule makes sure you always have `void` return type for your event listeners.

You need to configure this rule by adding the directories that your event listeners are in to the `listenerPaths` parameter:

```
parameters:
    listenerPaths:
        - app/Listeners
        - app/DomainA/Listeners
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

People:

- [Can Vural](https://github.com/canvural)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance71

Regular maintenance activity

Popularity53

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~58 days

Recently: every ~84 days

Total

37

Last Release

53d ago

Major Versions

1.x-dev → v2.0.02022-03-03

2.2.2 → 3.0.02024-12-02

2.2.3 → 3.0.12025-04-25

2.2.4 → 3.0.22025-04-25

2.2.5 → 3.0.32025-04-29

PHP version history (5 changes)0.1.0PHP ^7.2

0.1.3PHP ^7.3

0.1.6PHP ^7.3 || ^8.0

v2.0.0PHP ^8.0

3.0.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![canvural](https://avatars.githubusercontent.com/u/1574232?v=4)](https://github.com/canvural "canvural (58 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (44 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (13 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (5 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (2 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (1 commits)")[![rodrigoprimo](https://avatars.githubusercontent.com/u/77215?v=4)](https://github.com/rodrigoprimo "rodrigoprimo (1 commits)")[![jeremynikolic](https://avatars.githubusercontent.com/u/4478969?v=4)](https://github.com/jeremynikolic "jeremynikolic (1 commits)")

---

Tags

laravelphpphpstanphpstan-extensionphpstan-rulesphpstan-strict

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/canvural-larastan-strict-rules/health.svg)

```
[![Health](https://phpackages.com/badges/canvural-larastan-strict-rules/health.svg)](https://phpackages.com/packages/canvural-larastan-strict-rules)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78768.9M1.5k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

66766.6M1.1k](/packages/phpstan-phpstan-doctrine)[phpat/phpat

PHP Architecture Tester

1.2k3.5M32](/packages/phpat-phpat)[tomasvotruba/bladestan

PHPStan rule for static analysis of Blade templates

363584.5k4](/packages/tomasvotruba-bladestan)[spaze/phpstan-disallowed-calls

PHPStan rules to detect disallowed method &amp; function calls, constant, namespace, attribute, property &amp; superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.

33320.0M375](/packages/spaze-phpstan-disallowed-calls)

PHPackages © 2026

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