CC-39568 Add Spryker suite architecture PHPStan rules - #35
Merged
Conversation
Port 8 architecture/convention rules (stateless components, expander/mapper shape, repository read/write split, persistence transfer-only signatures, repository ORM write calls, gateway action signatures, API Platform provider/processor) plus the NativeTypeNames helper. Register each in extension.neon and cover with RuleTestCase-based tests.
The always-on extension.neon is auto-included by consumers' core fallback neon (e.g. suite src/phpstan.neon), which would run these opinionated, core-heavy rules on core code. Move them into a separate rules.neon that consumers include explicitly (and gate), leaving extension.neon core-safe.
phpcs: reference the raw Slevomat ParameterTypeHint/ReturnTypeHint/ PropertyTypeHint sniffs to forbid @param/@return/@var annotations that only restate a native type (array-shape and narrowing docblocks stay exempt), and surgically lift Spryker's mandatory-@return[-void] DocBlock sniffs that would otherwise collide. Reformat existing sources accordingly. phpstan: add a self-check rule requiring a native type hint on every class constant (PHP 8.3+), with a RuleTestCase and Good/Bad fixtures. Registered in tests/phpstan.neon only, so it self-enforces this package's own src/ and is not exported to consumers via extension.neon.
- Add phpcs config enabling Slevomat useless-annotation detection while excluding the mandatory-@return sniffs, matching the docblock tooling - Type every class constant natively; keep array-shape @var docblocks - Drop redundant scalar @param/@return/@var annotations across rules and tests - Remove internal rule-doc path references from error messages and class docblocks, and update the rule tests' expected message strings to match
olhalivitchuk
approved these changes
Jul 20, 2026
stereomon
changed the base branch from
master
to
feature/cc-39568-enforce-typed-consts-no-redundant-docblocks
July 20, 2026 11:57
stereomon
changed the base branch from
feature/cc-39568-enforce-typed-consts-no-redundant-docblocks
to
master
July 20, 2026 11:59
…ure-rules' into feature/cc-39568-enforce-typed-consts-no-redundant-docblocks # Conflicts: # tests/Rules/Spryker/DynamicMethodMissingPhpDocAnnotationRuleTest.php
…d-consts-no-redundant-docblocks CC-39568 Enforce typed class constants and forbid redundant docblocks
stereomon
marked this pull request as ready for review
July 23, 2026 04:47
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.
Extracts eight custom architecture/convention rules (stateless components, expander/mapper method shape, repository read/write split, persistence transfer-only signatures, repository ORM write calls, gateway action signatures, API Platform provider/processor) plus the NativeTypeNames helper into this reusable extension. Each rule is registered in
extension.neonand covered byRuleTestCase-based tests. Part of CC-39568; extracted from suite PR #871 so these architecture rules live as a reusable PHPStan extension.Test plan:
composer test(18 green) andcomposer stan(level 8, no errors) on PHP 8.4.