VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho-phpstan-plugin/2.1-installation

⇱ Installation | MahoCommerce/maho-phpstan-plugin | DeepWiki


Loading...
Menu

Installation

This page documents the installation process for maho-phpstan-plugin, including system requirements, dependency structure, autoloading configuration, and PHPStan's automatic extension discovery mechanism. For configuration options, see section 2.2.

Overview

The plugin is a Composer package with type: phpstan-extension composer.json4 PHPStan automatically discovers and loads the plugin via the extra.phpstan.includes mechanism defined in composer.json24-30

Sources: composer.json1-31

System Requirements

RequirementVersion ConstraintDefined In
PHP>= 8.2composer.json7
PHPStan^2.1composer.json8

The plugin requires PHP 8.2+ composer.json7 while PHPStan itself supports PHP 7.4+ composer.lock19 PHPStan is listed in require composer.json6-9 rather than require-dev, ensuring it is available when the plugin is installed as a dependency.

Sources: composer.json6-9 composer.lock18-21

Installation Steps

Standard Installation


This installs the package to vendor/mahocommerce/maho-phpstan-plugin/ and registers:

Sources: composer.json1-31

Package Configuration

Dependency Structure


The type: phpstan-extension declaration composer.json4 enables automatic discovery. PHPStan is in require composer.json8 not require-dev, ensuring availability when the plugin is installed in end-user projects. The require-dev dependencies composer.json10-13 are only used for analyzing the plugin itself.

Sources: composer.json2-13

Autoloading Configuration

Autoloading Mechanism Mapping


Namespace to File Mapping

Namespace/ClassFile PathConfiguration
Maho\PHPStanPlugin\Type\MageTypeExtensionsrc/Type/MageTypeExtension.phpcomposer.json14-18
Maho\PHPStanPlugin\Config\MageCoreConfigsrc/Config/MageCoreConfig.phpcomposer.json14-18
Magemock/maho-phpstan-plugin/Mage.phpcomposer.json19-23
Varien_Objectmock/maho-phpstan-plugin/Varien/Object.phpcomposer.json19-23

The classmap autoloading composer.json19-23 provides mock framework classes used by MageCoreConfig for type resolution. See section 6.1 for details on mock classes.

Sources: composer.json14-23

Automatic Extension Discovery

PHPStan Extension Discovery Flow


Extension Discovery Configuration

composer.json24-30 defines the discovery mechanism:






















KeyValueEffect
typephpstan-extension composer.json4Marks package as PHPStan extension
extra.phpstan.includes["extension.neon"] composer.json26-28Specifies configuration file(s) to load

PHPStan automatically loads extension.neon without requiring manual inclusion in user's phpstan.neon files. The extension.neon file registers all plugin services (see section 3.1).

Sources: composer.json4 composer.json24-30

Dependency Locking

composer.lock1-171 locks dependency versions for reproducible builds:

PackageLocked VersionLocation
phpstan/phpstan2.1.38composer.lock10-61
phpstan/phpstan-strict-rules2.0.8composer.lock112-158
phpstan/phpstan-deprecation-rules2.0.3composer.lock64-110

The lock file contains exact versions, distribution URLs, checksums, and the complete dependency tree. End users installing the plugin receive versions matching their own PHPStan constraints, not the versions locked in the plugin's composer.lock.

Sources: composer.lock1-171

Installation Directory Structure

Installed Directory Layout


Key Files and Directories

PathPurposeAutoload Method
extension.neonPHPStan service registrationextra.phpstan.includes
src/Type/MageTypeExtension.phpDynamic return type inferencePSR-4 composer.json15-17
src/Config/MageCoreConfig.phpMagento alias resolutionPSR-4 composer.json15-17
mock/maho-phpstan-plugin/Mage.phpFramework mock for type resolutionClassmap composer.json20-22

Sources: composer.json14-23

Verification

Verify Composer Installation


Expected output includes version, license, dependencies, and autoload configuration.

Verify PHPStan Discovery


Should show extension.neon loaded from vendor/mahocommerce/maho-phpstan-plugin/.

Verify Autoloading


Should output bool(true).

Sources: composer.json14-18

Troubleshooting

Plugin Not Discovered

If PHPStan does not automatically load the plugin:

  1. Verify package type: Ensure composer.json has "type": "phpstan-extension" composer.json4
  2. Check extra configuration: Confirm extra.phpstan.includes exists composer.json24-30
  3. Reinstall dependencies: Run composer install --no-cache to force fresh installation
  4. Update PHPStan: Ensure PHPStan version supports automatic extension discovery (^2.0+)

Autoloading Issues

If classes cannot be autoloaded:

  1. Regenerate autoload files: Run composer dump-autoload
  2. Verify namespace: Check that PSR-4 mapping in composer.json14-18 is correct
  3. Check file permissions: Ensure vendor/ directory is readable

Version Conflicts

If Composer reports version conflicts:

  1. Check PHP version: Ensure PHP >= 8.2 is installed composer.json7
  2. Update dependencies: Run composer update to resolve conflicts
  3. Check PHPStan version: Ensure PHPStan ^2.0 is available

Sources: composer.json1-31