CC-39568 Enforce typed class constants and forbid redundant docblocks - #36
Merged
Conversation
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.
olhalivitchuk
approved these changes
Jul 20, 2026
stereomon
changed the base branch from
master
to
feature/cc-39568-suite-architecture-rules
July 20, 2026 12:00
…ure-rules' into feature/cc-39568-enforce-typed-consts-no-redundant-docblocks # Conflicts: # tests/Rules/Spryker/DynamicMethodMissingPhpDocAnnotationRuleTest.php
stereomon
marked this pull request as ready for review
July 20, 2026 12:34
stereomon
merged commit Jul 20, 2026
f3f1793
into
feature/cc-39568-suite-architecture-rules
6 checks passed
stereomon
deleted the
feature/cc-39568-enforce-typed-consts-no-redundant-docblocks
branch
July 20, 2026 12:34
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.
Adds tooling so this package can never carry untyped class constants or redundant type-restating docblocks.
What it enforces
@param/@return/@vardocblocks that only restate a native type are forbidden via phpcs (raw Slevomat type-hint sniffs); array-shape and narrowing docblocks (list<...>,array<...>,class-string<...>) remain exempt.@return/@return voidDocBlock sniffs are surgically lifted where they collide with the above; the rest of the Spryker docblock checks stay in force.The constant rule is self-enforcement only (wired in the test phpstan config, not
extension.neon), so it checks this package's ownsrc/and is not imposed on consuming Spryker projects. It can be promoted toextension.neonlater if we want it exported to consumers.Test plan
vendor/bin/phpcbfthenvendor/bin/phpcs -p src/ tests/— clean.composer test— all pass (incl. the new rule's RuleTestCase with Good/Bad fixtures).composer stan— no errors; verified a temporary untyped constant is flagged, then removed.