magento / magento/magento-coding-standard
Add sniff for Service Contracts
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
Rule
According to this page there are some very specific rules for service contracts. For example:
- Valid object types include a fully qualified class name or a fully qualified interface name.
- Any parameters or return values of type array can be denoted by following any of the previous types by an empty set of square brackets []
Wouldn't it make sense to have a sniff for these things?
Reason
I come across a lot of service contracts that don't include FQCN and/or have an array return type instead of FQCN[]. This goes against the rules set by Magento and might also break future (web api) implementations (due to reflection).
Implementation
Not sure at this moment how to implement this, but it seems to me that this can be done with a new sniff.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Magento service-contract rules and inspect the repository's existing sniffs to determine the appropriate entry point for a new sniff. Define the checks for fully qualified class or interface names and array types written as FQCN[], then verify the sniff reports violations without false positives.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100