PHPackages                             looglecz/phpstan-magento2-extension - 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. looglecz/phpstan-magento2-extension

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

looglecz/phpstan-magento2-extension
===================================

Get best of PHPStan with respect to some Magento2 specialities

v0.1.8(1y ago)2645

Since Jan 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/LoogleCZ/PHPStan-Magento2-Extension)[ Packagist](https://packagist.org/packages/looglecz/phpstan-magento2-extension)[ RSS](/packages/looglecz-phpstan-magento2-extension/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (10)Used By (0)

PHPStan extension for Magento 2
===============================

[](#phpstan-extension-for-magento-2)

This repository contains set of rule and exclusions for PHPStan in order to be able to get best of the PHPStan static analysis with respect to some nasty things Magento does.

Exclusion of errors
-------------------

[](#exclusion-of-errors)

- Missing type in interceptor method
    - Since you need to copy part of the original method's signature, you are sometimes forced to use not-well typed arguments. This extension will ignore such errors.

Stubs
-----

[](#stubs)

Various stubs for different classes that are vaguely typed or there is error in the type hint.

Collection templates
--------------------

[](#collection-templates)

Magneto 2 collections offers you a way how to manipulate with objects in bulk. However, PHPStan cannot interfere specific type of item from the collection itself. In this extension, there are stubs for the Collection classes that allows you to have properly typed collection items that can help you with static analysis.

Stubs are available for following classes:

- `\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection`
- `\Magento\Framework\Data\Collection\AbstractDb`
- `\Magento\Framework\Data\Collection`

### Usage

[](#usage)

All you need to do is include `@extends AbstractCollection` in class-level PHPDoc. For example:

```
