-
-
Notifications
You must be signed in to change notification settings - Fork 1
fix: phpstan level 5 errors #84 #100
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request addresses PHPStan level 5 static analysis errors by refactoring code to use modern PHP 8+ features, improve type safety, and fix type-related issues. The changes focus on constructor property promotion, better type documentation, and removing redundant checks.
Changes:
- Lowered PHPStan level from 6 to 5 and removed continue-on-error from CI workflow to enforce static analysis
- Refactored multiple classes to use PHP 8+ constructor property promotion (readonly properties)
- Improved PHPDoc type annotations and removed redundant type checks
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| phpstan.neon | Lowered PHPStan analysis level from 6 to 5 |
| .github/workflows/phpstan.yml | Changed Magento installation method and removed continue-on-error flag |
| src/Service/ThemeBuilder/BuilderPool.php | Applied constructor property promotion |
| src/Service/StaticContentCleaner.php | Simplified return logic to check only cleaned files |
| src/Service/Hyva/CompatibilityChecker.php | Removed unused IncompatibilityDetector dependency |
| src/Model/ThemePath.php | Removed unused ThemeList and ThemeCollection dependencies |
| src/Model/TemplateEngine/Plugin/InspectorHints.php | Applied constructor property promotion and quoted @SuppressWarnings annotation |
| src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php | Deleted factory class |
| src/Model/TemplateEngine/Decorator/InspectorHints.php | Applied constructor property promotion, made Random required, added guard clause, improved instanceof checks |
| src/Console/Command/Theme/TokensCommand.php | Changed return type from int to null for validation methods |
| src/Console/Command/Theme/CleanCommand.php | Removed redundant is_string check on typed parameter |
| src/Console/Command/Theme/BuildCommand.php | Removed redundant is_string check on typed parameter |
| src/Console/Command/System/VersionCommand.php | Removed unused PACKAGE_NAME constant |
| src/Console/Command/System/CheckCommand.php | Improved PHPDoc type annotations and ini_get handling |
| src/Console/Command/Dev/InspectorCommand.php | Applied constructor property promotion and removed unreachable default case |
| src/Block/Inspector.php | Applied constructor property promotion |
This pull request includes a variety of improvements and refactorings across the codebase, focusing on constructor property promotion, type hinting, and code simplification. The most significant changes are grouped below.
Constructor Property Promotion and Dependency Handling:
Inspector,InspectorCommand,InspectorHints,InspectorHintsdecorator, andBuilderPool) to use PHP's constructor property promotion withprivate readonlyfor dependencies, reducing boilerplate and improving immutability. [1] [2] [3] [4] [5]ThemePathandCompatibilityChecker. [1] [2]Codebase Simplification and Cleanup:
InspectorHintsFactoryclass, streamlining the template engine decorator logic.Type Hinting and Documentation Improvements:
System/CheckCommand.php, enhancing code clarity and IDE support. [1] [2] [3] [4] [5] [6]Workflow and Build Improvements:
composer create-projectfor Magento installation instead ofgit clone, improving reliability and mirroring production setups.continue-on-errorflag and redundant module enablement.Minor Fixes and Consistency:
These changes collectively modernize the codebase, improve maintainability, and enhance type safety.