Download the PHP package prestashop/phpstan-prestashop without Composer
On this page you can find all versions of the php package prestashop/phpstan-prestashop. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download prestashop/phpstan-prestashop
More information about prestashop/phpstan-prestashop
Files in prestashop/phpstan-prestashop
Package phpstan-prestashop
Short Description PrestaShop extension for PHPStan
License MIT
Informations about the package phpstan-prestashop
PrestaShop PHPStan extension
Content
This PHPStan extension adds custom rules to PHPStan:
- ClassConstantsMustHaveVisibilityRule
- UseStrictTypesForNewClassesRule
- UseTypeHintForNewMethodsRule
- UseTypedReturnForNewMethodsRule
Installation
Install the dependencies with Composer:
Tests
Install the dev dependencies with Composer:
Run tests using PHPUnit:
Rules are tested using PHPStan RuleTestCase.
Run static analysis with PHPStan:
Extension is validated using a real PHPStan phar
Use in a project
To use this extension, first require it in Composer:
Then you need to include extension.neon in your project's PHPStan config:
Required settings
UseStrictTypesForNewClassesRule
Rule UseStrictTypesForNewClassesRule
requires loading of a configuration asset.
You need to provide a service that is an instance of PHPStanForPrestaShop\PHPConfigurationLoader\ConfigurationLoaderInterface
,
named @strictTypesForNewClassesRuleConfigurationFileLoader
. It should load an array of classes for which
the UseStrictTypesForNewClassesRule
should not be applied.
There is two available implementations: PHPStanForPrestaShop\PHPConfigurationLoader\ArrayConfigurationLoader
and PHPStanForPrestaShop\PHPConfigurationLoader\PHPConfigurationFileLoader
.
Example with PHPConfigurationFileLoader
:
UseTypedReturnForNewMethodsRule
Rule UseTypedReturnForNewMethodsRule
requires loading of a configuration asset.
You need to provide a service that is an instance of PHPStanForPrestaShop\PHPConfigurationLoader\ConfigurationLoaderInterface
,
named @returnTypesForNewMethodsRuleConfigurationFileLoader
. It should load an array of class methods for which
the UseTypedReturnForNewMethodsRule
should not be applied.
There is two available implementations: PHPStanForPrestaShop\PHPConfigurationLoader\ArrayConfigurationLoader
and PHPStanForPrestaShop\PHPConfigurationLoader\PHPConfigurationFileLoader
.
Example with PHPConfigurationFileLoader
:
UseTypeHintForNewMethodsRule
Similarly to UseTypedReturnForNewMethodsRule
, rule UseTypeHintForNewMethodsRule
requires loading of an instance of PHPStanForPrestaShop\PHPConfigurationLoader\ConfigurationLoaderInterface
,
named @typeHintsForNewMethodsRuleConfigurationFileLoader
. It should load an array of class methods for which
the UseTypeHintForNewMethodsRule
should not be applied.
There is two available implementations: PHPStanForPrestaShop\PHPConfigurationLoader\ArrayConfigurationLoader
and PHPStanForPrestaShop\PHPConfigurationLoader\PHPConfigurationFileLoader
.
Example with PHPConfigurationFileLoader
: