PHPackages                             driveto/phpstan-twig - 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. driveto/phpstan-twig

ActiveLibrary[Testing &amp; Quality](/categories/testing)

driveto/phpstan-twig
====================

Twig extensions for PHPStan

0.0.1(3y ago)356MITPHPPHP ^8.0

Since Aug 15Pushed 3y agoCompare

[ Source](https://github.com/driveto/phpstan-twig)[ Packagist](https://packagist.org/packages/driveto/phpstan-twig)[ RSS](/packages/driveto-phpstan-twig/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

PhpStan extenstion for Twig templates
=====================================

[](#phpstan-extenstion-for-twig-templates)

Inspired by blog series by @TomasVortuba -

Known issues
------------

[](#known-issues)

- Performance
    - Currently, templates are processed only sequentially
    - Same templates with same variables included in multiple templates are checked multiple times
    - High memory usage when depth of included templates is higher
- Method name guessing is not supported. I believe that template engine should not guess which method programmer wanted to use. Therefore, if you want to use method, use it with full name and parentheses `{{ class.fullMethodName() }}`

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

[](#installation)

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

```
composer require --dev driveto/phpstan-twig

```

Include extension.neon in your project's PHPStan config:

```
includes:
    - vendor/driveto/phpstan-twig/extension.neon

```

Add path to Twig service in phpstan.neon:

```
parameters:
    twig:
        twigEnvironmentLoader: tests/TwigEnvironmentLoader.php

```

Example of Twig loader:

```
use App\Kernel;
use Symfony\Component\Dotenv\Dotenv;

require __DIR__ . '/../vendor/autoload.php';

(new Dotenv())->bootEnv(__DIR__ . '/../.env');

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();
return $kernel->getContainer()->get('twig');
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1418d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d52a51628c50d6acb39fa551efa30c1960b55e084f43ac61e97c3022c63c43f2?d=identicon)[david.kmenta](/maintainers/david.kmenta)

![](https://avatars.githubusercontent.com/u/24732992?v=4)[Driveto](/maintainers/driveto)[@driveto](https://github.com/driveto)

---

Top Contributors

[![HonzaMatosik](https://avatars.githubusercontent.com/u/13003350?v=4)](https://github.com/HonzaMatosik "HonzaMatosik (19 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/driveto-phpstan-twig/health.svg)

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

###  Alternatives

[larastan/larastan

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

6.5k55.4M8.4k](/packages/larastan-larastan)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k101.8M2.2k](/packages/behat-behat)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[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.

4853.5M91](/packages/shipmonk-dead-code-detector)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)

PHPackages © 2026

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