Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPStan to Magento static checks #114

Merged
merged 2 commits into from Mar 13, 2019

Conversation

Projects
None yet
6 participants
@lenaorobei
Copy link
Contributor

lenaorobei commented Mar 11, 2019

Problem

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.

Currently such bugs cannot be detected by tools Magento uses for static checks.
PHPStan utilizes AST (abstract syntax tree) to perform sophisticated static code analysis which cannot be archived by using token-base approach (PHP CodeSniffer) and Reflection (PHP Mess Detector).

Solution

Add phpstan/phpstan to Magento require-dev section, update static code checks.

Requested Reviewers

@buskamuza
@paliarush
@antonkril

@magento-cicd2

This comment has been minimized.

Copy link

magento-cicd2 commented Mar 11, 2019

CLA assistant check
All committers have signed the CLA.

@lenaorobei lenaorobei changed the title Add PHPStan to the static checks Add PHPStan to Magento static checks Mar 11, 2019

@lenaorobei lenaorobei referenced this pull request Mar 11, 2019

Closed

March 13th, 2019 #77

@larsroettig

This comment has been minimized.

@shochdoerfer

This comment has been minimized.

Copy link
Member

shochdoerfer commented Mar 12, 2019

If you need or want to validate .phtml files also, you might need to follow this blog post. Not sure if patching phpstan is needed or if one could simply write an extension.

@buskamuza buskamuza requested review from buskamuza, paliarush and antonkril Mar 12, 2019


### Prerequisites
- PHP >= 7.1.
- Installed Magento application with generated code.

This comment has been minimized.

Copy link
@buskamuza

buskamuza Mar 12, 2019

Contributor

Can we avoid installed instance? Is it only for generated code?

This comment has been minimized.

Copy link
@lenaorobei

lenaorobei Mar 12, 2019

Author Contributor

Yes, we can. My bad, wrong wording. setup:di:compile is good enough.

@shochdoerfer

This comment has been minimized.

Copy link
Member

shochdoerfer commented Mar 13, 2019

The Drupal people also picked up phpstan, read some insights here.

@buskamuza buskamuza merged commit 2b9033c into magento:master Mar 13, 2019

1 check passed

licence/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.