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

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

macopedia/phpstan-magento1
==========================

Extension for PHPStan to allow analysis of Magento 1 code.

v1.2.0(5mo ago)4432.7k↑112.6%3[2 issues](https://github.com/macopedia/phpstan-magento1/issues)2MITPHPPHP &gt;= 7.4

Since Apr 12Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/macopedia/phpstan-magento1)[ Packagist](https://packagist.org/packages/macopedia/phpstan-magento1)[ RSS](/packages/macopedia-phpstan-magento1/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (2)

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

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

Extension for [PHPStan](https://github.com/phpstan/phpstan) to allow analysis of Magento 1 code. It doesn't require db connection to run.

Usage
-----

[](#usage)

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

Make sure it has

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

Then run

```
composer require --dev macopedia/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 `magentoRootPath` parameter in the phpstan.neon file. Add to the project's phpstan.neon:

```
parameters:
    magentoRootPath: %currentWorkingDirectory%/htdocs
```

Example configuration file for analysing Magento Module
-------------------------------------------------------

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

```
includes:
    - vendor/macopedia/phpstan-magento1/extension.neon
parameters:
    magentoRootPath: %currentWorkingDirectory%/htdocs
    paths:
        #lets start small with just our extensions
        - %currentWorkingDirectory%/app/code/local/VendorName/ModuleName
    excludePaths:
        - */Vendor/ModuleName/SomePathToExclude/*
    level: 0
```

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

54

—

FairBetter than 96% of packages

Maintenance70

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~226 days

Recently: every ~241 days

Total

12

Last Release

152d ago

Major Versions

v0.1.5 → v1.0.02021-09-27

PHP version history (2 changes)v1.0.0PHP &gt;= 7.2

v1.1.0PHP &gt;= 7.4

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  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)[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)[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.6M551](/packages/spaze-phpstan-disallowed-calls)[mglaman/phpstan-drupal

Drupal extension and rules for PHPStan

20731.4M187](/packages/mglaman-phpstan-drupal)

PHPackages © 2026

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