Skip to content

CC-39568 Add Spryker suite architecture PHPStan rules - #35

Merged
stereomon merged 9 commits into
masterfrom
feature/cc-39568-suite-architecture-rules
Jul 23, 2026
Merged

CC-39568 Add Spryker suite architecture PHPStan rules#35
stereomon merged 9 commits into
masterfrom
feature/cc-39568-suite-architecture-rules

Conversation

@stereomon

Copy link
Copy Markdown
Contributor

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.neon and covered by RuleTestCase-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) and composer stan (level 8, no errors) on PHP 8.4.

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
@stereomon
stereomon changed the base branch from master to feature/cc-39568-enforce-typed-consts-no-redundant-docblocks July 20, 2026 11:57
@stereomon
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
stereomon marked this pull request as ready for review July 23, 2026 04:47
@stereomon
stereomon merged commit f08de7a into master Jul 23, 2026
6 checks passed
@stereomon
stereomon deleted the feature/cc-39568-suite-architecture-rules branch July 23, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants