Closed larsroettig closed 4 years ago
Hi @larsroettig. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento-engcom-team give me 2.3-develop instance
- upcoming 2.3.x release
For more details, please, review the Magento Contributor Assistant documentation.
@larsroettig do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
Additional details:
level 0
(loosest one) check for now.Looking forward to closely observe this :) The main challenge when getting level 0 to run is to configure autoloading properly - sometimes projects rely on weird autoloading rules or custom autoloader. Most commonly, there's problem with PHPUnit testcases - they have to be present at least in autoload-dev
too.
This is important to get right:
*Â Have class definitions in files by themselves, not mix them with any side-effects (like code below the class definition that runs when the class is autoloaded)
-a
CLI option.autoload_files
option in phpstan.neon (or files
in Composer).You might want to follow our work regarding Magento support for PHPStan here until there's an official extension ;)
PHPStan was added to Magento https://github.com/magento/magento2/blob/2.4-develop/composer.json#L95
Summary (*)
As the architecture team discussed at https://github.com/magento/architecture/pull/114 we should add PHPStan as developer composer dependencies.
How:
composer require --dev phpstan/phpstan
Add check todev/tests/static/phpunit.xml.dist
Expected behaviour (*)
PHPStan run with the Magento static checks
Actual result (*)
Php Stan is not installed and does not run with the static checks
Examples (*)
Benefits
Following types of issues can be found in Magento codebase: the use of undefined class; call to undefined function; missing parent::__construct() call; passed arguments mismatch, etc.
Additional information
The Drupal people also picked up phpstan, read some insights https://glamanate.com/blog/writing-better-drupal-code-static-analysis-using-phpstan
Proposed solution