PHPackages                             raul338/cakephp-phpstan-extensions - 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. raul338/cakephp-phpstan-extensions

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

raul338/cakephp-phpstan-extensions
==================================

Services to aid phpstan analysis on CakePHP projects

5.0.0(1y ago)065.1k—0.4%MITPHPPHP &gt;=8.1CI passing

Since Mar 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/raul338/cakephp-phpstan-extensions)[ Packagist](https://packagist.org/packages/raul338/cakephp-phpstan-extensions)[ RSS](/packages/raul338-cakephp-phpstan-extensions/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (17)Used By (0)

CakePHP phpstan extensions
==========================

[](#cakephp-phpstan-extensions)

[![CI](https://github.com/raul338/cakephp-phpstan-extensions/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/raul338/cakephp-phpstan-extensions/actions/workflows/static-analysis.yml)

Services to aid phpstan analysis on CakePHP projects

VersionCakePHP Versionphpstan version5.x5.x2.0+4.x4.x2.0+3.x4.x1.10+2.x3.x0.121.x3.x0.11Install
-------

[](#install)

```
composer require --dev raul338/cakephp-phpstan-extensions
```

This extensions load automatically if you install [phpstan/extension-installer](https://github.com/phpstan/extension-installer)

```
composer require --dev phpstan/extension-installer
```

or if you don't use phpstan/extension-installer, include in your phpstan.neon

```
includes:
	- vendor/raul338/cakephp-phpstan-extensions/src/cakephp-extensions.neon

```

How does this help me
---------------------

[](#how-does-this-help-me)

This extension includes rules to analyze the following snippets wihout using var annotations

### Dynamic Finders

[](#dynamic-finders)

[Link to the Book](https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#dynamic-finders)

```
$query = $this->Users->findAllByUsername('joebob');
```

### Detect methods from behaviors

[](#detect-methods-from-behaviors)

[Link to the Book](https://book.cakephp.org/3/en/orm/behaviors.html#defining-mixin-methods)

This only works if the method name is not modified in implementedMethods. Otherwise the analysis may be wrong, or you'll have to decorate your code with dockblocks

```
/**
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
 */
public class UsersTable extends Table
{
    public function initialize(array $config)
    {
        parent::initialize($config);
        $this->addBehavior('Timestamp');
    }
}
// somewhere else - phpstan will know its the Timestamp touch method
$this->Users->touch($user);
```

### FriendsOfCake/crud Actions &amp; Listeners

[](#friendsofcakecrud-actions--listeners)

This is for use with [FriendsOfCake/crud](https://github.com/FriendsOfCake/crud)

```
public function add()
{
    // phpstan will know action() is a AddAction instead of BaseAction
    $this->Crud->action()->saveOptions([]);

    // phpstan will know it is a \Crud\Listener\RelatedModelsListener
    $this->Crud->listener('relatedModels')->relatedModels(true);
}
```

It will only work if you use one of the default action

- add
- delete
- edit
- index
- view

And in spanish names:

- agregar
- editar
- borrar
- ver

If you use an action with crud you'll have to do something like this:

```
public function custom()
{
    $this->Crud->mapAction('custom', 'Crud.Index');
    /** @var \Crud\Action\IndexAction */
    $action = $this->Crud->action();
}
```

### FriendsOfCake/crud Event Subject

[](#friendsofcakecrud-event-subject)

Tell phpstan that if is an event inside a Controller, the subject will probably be a CrudSubject

Example:

```
$this->Crud->on('beforePaginate', function (Event $event) {
    $query = $event->getSubject()->query;
    $query->where([ /** ... */]);
});
```

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance42

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity73

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~112 days

Recently: every ~0 days

Total

17

Last Release

460d ago

Major Versions

1.0.1 → 2.1.02020-03-25

1.x-dev → 2.x-dev2020-07-05

2.x-dev → 3.0.02024-09-15

3.x-dev → 4.0.02025-02-13

4.0.0 → 5.x-dev2025-02-13

PHP version history (7 changes)2.0.0PHP &gt;=7.3

1.0.0PHP &gt;=7.2

2.0.1PHP ^7.1

3.0.0PHP ^7.4

3.0.1PHP ^7.4|~8.0

5.x-devPHP &gt;=8.1

4.0.1PHP ^7.4|^8.0|^8.1|^8.2|^8.3

### Community

Maintainers

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

---

Top Contributors

[![raul338](https://avatars.githubusercontent.com/u/7199046?v=4)](https://github.com/raul338 "raul338 (74 commits)")

---

Tags

cakephpphpstan-extensionstatic-analysisPHPStanstatic analysiscakephpphpstan-rules

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/raul338-cakephp-phpstan-extensions/health.svg)

```
[![Health](https://phpackages.com/badges/raul338-cakephp-phpstan-extensions/health.svg)](https://phpackages.com/packages/raul338-cakephp-phpstan-extensions)
```

###  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)[ekino/phpstan-banned-code

Detected banned code using PHPStan

2925.6M92](/packages/ekino-phpstan-banned-code)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

3462.2M52](/packages/shipmonk-dead-code-detector)[szepeviktor/phpstan-wordpress

WordPress extensions for PHPStan

3257.8M898](/packages/szepeviktor-phpstan-wordpress)[staabm/phpstan-dba

2912.3M2](/packages/staabm-phpstan-dba)[staabm/phpstan-todo-by

1991.8M55](/packages/staabm-phpstan-todo-by)

PHPackages © 2026

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