This package provides additional PHPStan rules for Shopware 6 projects. It helps developers catch common mistakes and enforce best practices specific to Shopware development.
You can install the package via composer:
composer require --dev shopwarelabs/phpstan-shopware
To use these rules, include the package's configuration file in your PHPStan configuration:
includes:
- vendor/shopwarelabs/phpstan-shopware/rules.neon
or you use PHPStan Extension Installer
- Custom rules for Shopware 6.5 specific patterns
- Improved type inference for Shopware core classes
- Additional checks for common Shopware development pitfalls
Here's a comprehensive list of all available rules:
-
NoSuperglobalsRule: Prevents usage of superglobals (
$_GET
,$_POST
,$_FILES
,$_REQUEST
). Use proper request objects instead. -
DisallowFunctionsRule: Prevents usage of certain disallowed functions in the codebase.
-
NoEntityRepositoryInLoopRule: Prevents EntityRepository method calls within loops to avoid N+1 query problems.
-
NoSessionInPaymentHandlerAndStoreApiRule: Prevents usage of session in payment handlers and Store API contexts.
-
NoSymfonySessionInConstructorRule: Prevents injection of Symfony Session in constructor to avoid early session starts.
-
ForbidGlobBraceRule: Prevents usage of glob brace expansion for better cross-platform compatibility.
-
InternalClassExtendsRule: Ensures proper extension of internal classes.
-
NoUserEntityGetStoreTokenRule: Prevents direct access to store tokens from User entities.
-
MethodBecomesAbstractRule: Checks for methods that should be abstract.
-
ClassExtendUsesAbstractClassWhenExisting: Enforces the use of abstract classes when they exist.
-
NoDALFilterByID: Prevents direct ID filtering in DAL queries.
-
ScheduledTaskTooLowIntervalRule: Ensures scheduled tasks don't have too low intervals.
-
DisallowDefaultContextCreation: Prevents creation of default contexts in inappropriate places.
-
SetForeignKeyRule: Enforces proper foreign key handling.
-
InternalFunctionCallRule: Controls usage of internal functions.
-
InternalMethodCallRule: Controls usage of internal methods.
You can customize the behavior of these rules by adding configuration to your phpstan.neon
file. See the configuration section for more details.
Contributions are welcome! Please see CONTRIBUTING.md for details.
The MIT License (MIT). Please see License File for more information.