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

ActiveLibrary

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

Extension for PHPStan to allow analysis of Magento 1 code.

v1.1.0(1y ago)4339.0k↑154.5%3[1 issues](https://github.com/macopedia/phpstan-magento1/issues)1MITPHPPHP &gt;= 7.4

Since Apr 12Pushed 3mo 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 1mo ago

READMEChangelog (10)Dependencies (1)Versions (15)Used By (1)

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

49

—

FairBetter than 95% of packages

Maintenance56

Moderate activity, may be stable

Popularity42

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity67

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

Recently: every ~172 days

Total

11

Last Release

545d 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.4k43.5M5.2k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78268.9M1.5k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

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

33120.0M375](/packages/spaze-phpstan-disallowed-calls)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

134391.5k12](/packages/rector-rector-src)[wp-cli/wp-cli-tests

WP-CLI testing framework

422.7M87](/packages/wp-cli-wp-cli-tests)

PHPackages © 2026

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