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(4y ago)356MITPHPPHP ^8.0

Since Aug 15Pushed 4y 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 2w ago

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

23

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

1463d 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

[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67475.0M1.6k](/packages/phpstan-phpstan-doctrine)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79378.2M2.5k](/packages/phpstan-phpstan-symfony)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136411.0k14](/packages/rector-rector-src)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2613.3M489](/packages/ssch-typo3-rector)[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.

5014.2M111](/packages/shipmonk-dead-code-detector)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)

PHPackages © 2026

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