feat: add mago analyze#205
Draft
Morgy93 wants to merge 2 commits into
Draft
Conversation
Introduce a Static Analysis workflow that builds a full Magento install once and runs PHPStan and `mago analyze` against it in parallel, instead of each tool rebuilding Magento. Replaces the standalone PHPStan workflow (the PHPStan job keeps the same "PHPStan Analysis" check name). - static-analysis.yml: a build-magento job uploads the install as an artifact; the phpstan and mago-analyze jobs consume it without a live database (static analysis only reads code). phpstan.neon is copied into the install because it is export-ignored from the path-repo copy. - mago.toml: exclude phtml templates from analysis (runtime-injected template scope) and ignore the Magento-idiomatic mixed-assignment / mixed-operand codes (PHPStan level 9 is the type gate for those). - ddev: `ddev mago analyze` now runs against the installed Magento so it resolves the full class graph, matching what CI analyzes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fix the type errors mago analyze reports against a full Magento install:
- CheckCommand: cast ini_get('memory_limit') (string|false declared
string); use the PHP_VERSION constant instead of phpversion(); read the
MySQL version via fetchOne('SELECT VERSION()') instead of from(null).
- Type loose framework return values via inline @var (getPaths() ->
array<string,string>, getAllBlocks() -> BlockInterface[]).
- Cast mixed operands/arguments: theme loop index, hrtime() metrics,
stat() mode, and the getOption() flags used in a boolean expression.
- InspectorHints: widen render()'s $dictionary param to match the parent
TemplateEngineInterface; cast the BP constant to string.
- Drop redundant (string) casts and an obsolete @var docblock.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f41408c to
bca9b1a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new, more efficient static analysis workflow for the project, consolidating and optimizing how static analysis tools (PHPStan and Mago) are run in CI. It removes the old PHPStan workflow and replaces it with a unified workflow that builds Magento once and reuses this build for all static analysis jobs, reducing duplication and improving performance. Additionally, there are minor improvements and consistency fixes in CLI commands and scripts, as well as configuration updates for the Mago static analyzer.
Static Analysis Workflow Improvements:
.github/workflows/static-analysis.yml, which builds a single Magento install and shares it as an artifact for both PHPStan and Mago analysis jobs. This enables parallel static analysis without redundant Magento builds, improving CI efficiency..github/workflows/phpstan.ymlworkflow, which previously handled PHPStan analysis and Magento setup separately, now superseded by the new unified workflow.Mago Integration and Configuration:
.ddev/commands/web/magoto support a newanalyzecommand that runs static analysis against the installed Magento, matching CI behavior. This ensures consistent analysis results locally and in CI. [1] [2]mago.tomlto exclude.phtmltemplate files from static analysis (since they rely on runtime-injected variables) and to ignore certainmixed-*warnings that are common in Magento code but not actionable.Code Quality and CLI Consistency:
Theme\BuildCommand,Theme\CleanCommand,Theme\TokensCommand, andTheme\WatchCommand. [1] [2] [3] [4]intwhere necessary in theme processing loops. [1] [2]PHP_VERSIONinstead ofphpversion(), casting results fromini_getand constants, and simplifying SQL inCheckCommand. [1] [2] [3] [4] [5]These changes collectively streamline static analysis, improve developer experience, and ensure more reliable and consistent CI results.