PHPackages                             grifart/phpstan-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. grifart/phpstan-rules

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

grifart/phpstan-rules
=====================

Fills missing pieces of the PHP type system.

00[2 issues](https://github.com/grifart/phpstan-rules/issues)PHP

Since Dec 5Pushed 6y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

PHPStan rules
=============

[](#phpstan-rules)

`@overrides` or must call parent
--------------------------------

[](#overrides-or-must-call-parent)

If there is overriding method, it must either has annotation `@overrides` or must call parent method.

```
class BasePresenter {

  private $dep;

  public function injectFoo(Dependency $dep): void {
      $this->dep = $dep
  }

}

class LoginPresenter extends BasePresenter {

  private $dep;

  public function injectFoo(Dependency $dep): void {
      $this->dep = $dep
  }

}
```

Requires `LoginPresenter` to be explicitly tell that you are intentionally overriding method:

```
class LoginPresenter extends BasePresenter {

  private $dep;

  /**
   * @overrides
   */
  public function injectFoo(Dependency $dep): void {
      $this->dep = $dep
  }

}
```

or call parent function:

```
class LoginPresenter extends BasePresenter {

  private $dep;

  public function injectFoo(Dependency $dep): void {
      $this->dep = $dep
      parent::injectFoo($dep);
  }

}
```

Sealed classes
--------------

[](#sealed-classes)

Sealed classes are used for representing restricted class hierarchies.

```
// file: enum.php

/**
 * @sealed
 */
abstract class EnumFoo {
}

final class Value1 extends EnumFoo {}
final class Value2 extends EnumFoo {}
final class Value3 extends EnumFoo {}

// file: other.php

final class Value4 extends EnumFoo {} // not allowed
```

This restricts declaring any other sub-type of `EnumFoo`, then `Value1`, `Value2`, `Value3`. This is usefull, because it should then understand that:

```
\assert($value instanceof EnumFoo);

switch (getclass($value)): {
  case Value1::class:
    break;
  case Value2::class:
    break;
  case Value3::class:
    break;
  default:
    echo "unreachable code!";
    break;
}
```

Type system should know that default case is unreachable, because there cannot be any other type decalared anywhere.

Overriding property in child class
----------------------------------

[](#overriding-property-in-child-class)

```
class BasePresenter {

  /** @var Dependency */
  public $dep;

}

class LoginPresenter extends BasePresenter {

  /** @var Dependency2 */
  public $dep; // error

}
```

require\_once return value used
-------------------------------

[](#require_once-return-value-used)

This is usually not what you expect.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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/939d12e9a77e30f843e33a785f81d8ee45b71bf2db88c0d32c0d36571c71a58d?d=identicon)[jkuchar](/maintainers/jkuchar)

---

Top Contributors

[![jkuchar](https://avatars.githubusercontent.com/u/133822?v=4)](https://github.com/jkuchar "jkuchar (14 commits)")

### Embed Badge

![Health badge](/badges/grifart-phpstan-rules/health.svg)

```
[![Health](https://phpackages.com/badges/grifart-phpstan-rules/health.svg)](https://phpackages.com/packages/grifart-phpstan-rules)
```

###  Alternatives

[riverskies/laravel-vue-component

Helper package to aid usage of Vue Components within Laravel projects

201.2k](/packages/riverskies-laravel-vue-component)

PHPackages © 2026

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