fix: update static analysis#224
Open
Morgy93 wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the project’s static-analysis tooling (PHPStan + PHPCS) to include tests/ alongside src/, and applies a set of test refactors/typing tweaks to improve analysis signal and reduce brittle assertions.
Changes:
- Expand PHPStan and PHPCS scopes to cover both
src/andtests/, and align CI/DDEV execution with the configured PHPStan paths. - Refactor and harden several unit tests with clearer expected values and additional type assertions for decoded/reflective data.
- Remove project-specific VS Code settings and tighten
.gitignorehandling for.vscode/.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Service/ThemeBuilder/MagentoStandard/BuilderTest.php | Minor refactor to make expected IO note message explicit. |
| tests/Unit/Service/ThemeBuilder/HyvaThemes/BuilderTest.php | Store watch() result before asserting for clarity. |
| tests/Unit/Service/Hyva/IncompatibilityDetectorTest.php | Import PHPStan type alias and use it in helper phpdoc. |
| tests/Unit/Service/Hyva/CompatibilityCheckerTest.php | Refactor fixtures via helper, add PHPStan type imports, and enrich issue test data. |
| tests/Unit/Model/TemplateEngine/Decorator/InspectorHintsTest.php | Add phpdoc for helper params and harden JSON extraction/decoding assertions. |
| tests/Unit/Model/Config/Source/ToolbarPositionTest.php | Simplify label assertions for option arrays. |
| tests/Unit/Model/Config/Source/InspectorThemeTest.php | Simplify label assertions for option arrays. |
| tests/Unit/Console/Command/Theme/CleanCommandTest.php | Extract expected string for readability. |
| tests/Unit/Console/Command/System/FakeHttpClient.php | Add phpdoc/type hints and adjust method bodies to satisfy static analysis. |
| tests/Unit/Console/Command/Hyva/CompatibilityCheckCommandTest.php | Remove stray blank line. |
| tests/Unit/Console/Command/Dev/InspectorCommandTest.php | Extract expected string for readability. |
| tests/Unit/Console/Command/AbstractCommandTest.php | Add assertIsArray guards around reflective property reads. |
| tests/coverage-checker.php | Document/disable specific Magento2 PHPCS security sniffs for this standalone CLI script. |
| phpstan.neon | Include tests/ in PHPStan analysis paths. |
| phpcs.xml.dist | Include tests/ in PHPCS scanning scope. |
| .vscode/settings.json | Remove repo-local VS Code settings file. |
| .gitignore | Ignore only the top-level /.vscode/ directory. |
| .github/workflows/static-analysis.yml | Run PHPStan using config-defined paths (no explicit target path). |
| .ddev/commands/web/phpstan | Default to config-declared paths unless an explicit target path is supplied. |
Comment on lines
+49
to
+53
| if [[ -n ${TARGET_PATH} ]]; then | ||
| vendor/bin/phpstan analyse -c "${PHPSTAN_CONFIG}" "$@" "${TARGET_PATH}" | ||
| else | ||
| vendor/bin/phpstan analyse -c "${PHPSTAN_CONFIG}" "$@" | ||
| fi |
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 several improvements and cleanups across the codebase, focusing on static analysis configuration, test robustness, and type safety. The most significant changes include updating PHPStan and PHPCS configurations to include test files, improving test assertions for better reliability, and enhancing type annotations and signatures in test utilities.
Static Analysis and Coding Standards Configuration:
phpstan.neonand.github/workflows/static-analysis.ymlto analyze bothsrcandtestsdirectories, ensuring tests are included in static analysis. The shell script for running PHPStan was also improved to default to paths from the config file unless an explicit path is given. ([[1]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-0361f0c81f363476ddc6f44ab36fcbe66ee685d5f4c2a46b054924591544b766R8),[[2]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-e9db86b6fd5f791eb849075b600b921e5e95b978e41f9d290c01027440076ec3L167-R167),[[3]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-5ad29139442714d924b649b678a51b25f152332fa7e42e02f0f541a859e67a99L28-R30),[[4]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-5ad29139442714d924b649b678a51b25f152332fa7e42e02f0f541a859e67a99L40-R50))tests/directory to PHPCS analysis for code style checks. ([phpcs.xml.distR6](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-05ae9cddcaec1e845771a7db224961439f83ef5939ec67d3a48744cb34d7e58bR6))Test Suite Robustness and Type Safety:
[[1]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-8ce5becb11db42c01531b7776a63e42c7de860d19749d3666ee8d047b93a06ebR283),[[2]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-8ce5becb11db42c01531b7776a63e42c7de860d19749d3666ee8d047b93a06ebL308-R311),[[3]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-8ce5becb11db42c01531b7776a63e42c7de860d19749d3666ee8d047b93a06ebL319-R324),[[4]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-8ce5becb11db42c01531b7776a63e42c7de860d19749d3666ee8d047b93a06ebL368-R375),[[5]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-211dbd9e250f36909366c1068ec89cb8af3ee69fa03c52e0fa2b6cd96e05467eL162-R168),[[6]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-211dbd9e250f36909366c1068ec89cb8af3ee69fa03c52e0fa2b6cd96e05467eL183-R189),[[7]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-211dbd9e250f36909366c1068ec89cb8af3ee69fa03c52e0fa2b6cd96e05467eL210-R217))FakeHttpClient, to clarify expected types and improve static analysis. ([[1]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-c1db05ee5a2b4e75243fa080e07b4c7144c2baa84b4ef9de02bba3afc15d2787R25-R32),[[2]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-c1db05ee5a2b4e75243fa080e07b4c7144c2baa84b4ef9de02bba3afc15d2787R45-R63),[[3]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-c1db05ee5a2b4e75243fa080e07b4c7144c2baa84b4ef9de02bba3afc15d2787R73-R75),[[4]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-c1db05ee5a2b4e75243fa080e07b4c7144c2baa84b4ef9de02bba3afc15d2787L75-R102),[[5]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-c1db05ee5a2b4e75243fa080e07b4c7144c2baa84b4ef9de02bba3afc15d2787R119-R121),[[6]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-91329aacf940df2f33a19f6428f86d470fbf3c84104ae47aa0173e97a3dd022aR15-R19))Test Code Quality and Readability:
[[1]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-659afd8c7959fa26c528b44374b59db364acf9f6fe88c458c0f0c03168c788faL164-R165),[[2]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-e3024871d782f6176b562d755185c96e0048c3d8a42a3889a99f85722ccd802dL226-R227),[[3]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-637f6aff7c0555250b1ec5c8fe05a075107e5cb8592e54ed7302a9a643477bd5L362),[[4]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-d67a718e8900aff25fc7b8b73734350532b11655097679f5f7bd77b1738ea7d9L29),[[5]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-68380b84f3377be67b790a19e4bad84772312b003b342cd051dc55371976563eL32))[[1]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-91329aacf940df2f33a19f6428f86d470fbf3c84104ae47aa0173e97a3dd022aL183-R192),[[2]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-91329aacf940df2f33a19f6428f86d470fbf3c84104ae47aa0173e97a3dd022aL202-R206),[[3]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-91329aacf940df2f33a19f6428f86d470fbf3c84104ae47aa0173e97a3dd022aL222-R227),[[4]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-91329aacf940df2f33a19f6428f86d470fbf3c84104ae47aa0173e97a3dd022aL244-R245),[[5]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-91329aacf940df2f33a19f6428f86d470fbf3c84104ae47aa0173e97a3dd022aL269-R269),[[6]](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-211dbd9e250f36909366c1068ec89cb8af3ee69fa03c52e0fa2b6cd96e05467eR53-R56))Miscellaneous:
[.vscode/settings.jsonL1-L7](https://github.com/OpenForgeProject/mageforge/pull/224/files#diff-a5de3e5871ffcc383a2294845bd3df25d3eeff6c29ad46e3a396577c413bf357L1-L7))These changes collectively improve the maintainability, reliability, and coverage of static analysis and tests in the project.