smile/magento2-smilelab-phpstan

PHPStan extension for Magento projects.

Installs: 16 109

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 10

Forks: 0

Open Issues: 0

Type:phpstan-extension

1.0.4 2024-07-15 08:16 UTC

This package is auto-updated.

Last update: 2024-12-15 09:08:37 UTC


README

Description

This extension is meant to be used on Magento projects and modules.

The src folder is copied from https://github.com/magento/magento2/tree/2.4.5/dev/tests/static/framework/Magento/PhpStan.

Installation

To use this extension, require it in composer:

composer require --dev smile/magento2-smilelab-phpstan

Configuration

Create a configuration file named phpstan.neon.dist at the root of your project.

Example for a Magento project:

parameters:
    level: 6
    checkMissingIterableValueType: false
    paths:
        - app/code

Exemple for a community module:

parameters:
    level: 6
    checkMissingIterableValueType: false
    phpVersion: {{min_php_version}}
    paths:
        - .
    excludePaths:
        - 'vendor/*'

Where {{min_php_version}} is the minimum compatible version of PHP required by your module. For example, if the min version is PHP 7.4:

phpVersion: 70400

If you also install phpstan/extension-installer then you're all set!

Otherwise, add the following configuration to this file:

includes:
    - vendor/smile/magento2-smilelab-phpstan/extension.neon

Usage

You can run the phpstan analysis with this command:

vendor/bin/phpstan analyse