PHPackages                             vianetz/phpstan-magento1 - 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. vianetz/phpstan-magento1

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

vianetz/phpstan-magento1
========================

Extension for PHPStan to allow analysis of Magento 1/OpenMage source code.

v0.1.5(7y ago)05.7k2MITPHP

Since Apr 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/vianetz/phpstan-magento1)[ Packagist](https://packagist.org/packages/vianetz/phpstan-magento1)[ RSS](/packages/vianetz-phpstan-magento1/feed)WikiDiscussions master Synced today

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

PHPStan Extension for Magento 1 / OpenMage
==========================================

[](#phpstan-extension-for-magento-1--openmage)

Extension for [PHPStan](https://github.com/phpstan/phpstan) to allow analysis of Magento 1/OpenMage code.

Usage
-----

[](#usage)

Add `phpstan.neon` to your Magento 1/OpenMage project.

Make sure it has

```
includes:
    - vendor/vianetz/phpstan-magento1/extension.neon
```

Then run

```
composer require --dev vianetz/phpstan-magento1
```

Alternative Magento path
------------------------

[](#alternative-magento-path)

By default this extension assumes the Magento directory is `%currentWorkingDirectory%/htdocs`.

You can adapt the path by changing the `magentoRootDirectory` parameter in the `phpstan.neon` file.

Example configuration file for analysing Magento Extensions
-----------------------------------------------------------

[](#example-configuration-file-for-analysing-magento-extensions)

```
includes:
    - vendor/vianetz/phpstan-magento1/extension.neon
parameters:
    paths:
        - %currentWorkingDirectory%/htdocs/app/code/local
```

Known Issues
============

[](#known-issues)

Data/SQL scripts can't be tested
--------------------------------

[](#datasql-scripts-cant-be-tested)

Since these scripts use a presumed `$this` variable due to being included from a setup class, work is needed to:

- work out the correct setup class
- somehow make phpstan aware of it for the file

Magento fluent interface classes aren't fluent for sub-classes
--------------------------------------------------------------

[](#magento-fluent-interface-classes-arent-fluent-for-sub-classes)

This causes subsequent calls to the class object to assume the scope of the super-class that defined the return type.

This is due to their PHPDoc not using the up to date way of specifying fluency with subclasses using `$this` as the type.

Options to resolve:

- Avoid using the fluent interface on these classes
- Patch Magento code to use $this as the return type
- Define @method PHPDoc for the called methods in the subclass
- Add the error to the parameters.ignoreErrors phpstan configuration to ignore it - this loses the ability to properly type the subseqent methods of the fluent interface

Mage\_Core\_Model\_Abstract::load `$id` is not an integer
---------------------------------------------------------

[](#mage_core_model_abstractload-id-is-not-an-integer)

This is due to an inadequate PHPDoc of the load method of the Mage\_Core\_Model\_Abstract class. It should have used a "mixed" type to support when a field is specified as the 2nd argument.

PHPStan extensions have no way of altering existing method parameters.

Options to resolve:

- Patch the Magento code to use mixed as the $id parameter type
- If available in the chain of super-classes, use the loadBy{Field} method, which has the correct parameter typing
- Define @method PHPDoc in your class (which extends Mage\_Core\_Model\_Abstract or a subclass of it) with the correct parameter types
- Add the error to the parameters.ignoreErrors phpstan configuration to ignore it

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.1% 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

2638d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ff492874815eed37664a65070bcd600b4cbe9b0356afa8a9ae2482119fe98e4?d=identicon)[ma4nn](/maintainers/ma4nn)

---

Top Contributors

[![ma4nn](https://avatars.githubusercontent.com/u/26252058?v=4)](https://github.com/ma4nn "ma4nn (17 commits)")[![andytson-inviqa](https://avatars.githubusercontent.com/u/11387086?v=4)](https://github.com/andytson-inviqa "andytson-inviqa (13 commits)")[![kierenevans](https://avatars.githubusercontent.com/u/1554709?v=4)](https://github.com/kierenevans "kierenevans (1 commits)")[![tmotyl](https://avatars.githubusercontent.com/u/515397?v=4)](https://github.com/tmotyl "tmotyl (1 commits)")

---

Tags

magento1openmagephpstanstatic-code-analysis

### Embed Badge

![Health badge](/badges/vianetz-phpstan-magento1/health.svg)

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

###  Alternatives

[larastan/larastan

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

6.5k55.4M8.2k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.1k](/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.5M90](/packages/shipmonk-dead-code-detector)[spaze/phpstan-disallowed-calls

PHPStan rules to detect disallowed method &amp; function calls, constant, namespace, attribute, property &amp; superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.

33422.6M538](/packages/spaze-phpstan-disallowed-calls)[tomasvotruba/cognitive-complexity

PHPStan rules to measure cognitive complexity of your classes and methods

1635.6M284](/packages/tomasvotruba-cognitive-complexity)

PHPackages © 2026

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