[symfony] Add 6 generic PHPStan rules (attributes, DI, return shapes) - #285
Merged
Merged
Conversation
…tructor, duplicate attribute, property-to-property assign, array-shape return
Co-authored-by: TomasVotruba <924196+TomasVotruba@users.noreply.github.com>
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 6 project-agnostic rules, extracted from a real Symfony/Doctrine app where they proved useful.
Symfony
Commandmust carry#[AsCommand].Constraintmust carry#[\Attribute], so it works as a property attribute.*Interfaceshould use the interface. Only 3rd-party (Symfony/Doctrine) types are checked; project classes are left alone.General
\Attribute::IS_REPEATABLE.$this->a = $this->bkeeps the same service under 2 names; use the original directly.@return array{...}shape.Each rule is registered in the matching config set, documented in the README, and covered by a
RuleTestCasewith report + skip fixtures. Console/Validator stubs added for the attribute rules.Note:
AbstractClassNameMustBeAbstractRulefrom the same batch was intentionally dropped -ExplicitClassPrefixSuffixRulealready covers a non-abstractAbstract*class.Green locally: ECS, PHPStan, Rector, composer-dependency-analyser, full PHPUnit (349 tests).