cakephp / cakephp/cakephp-codesniffer
CakePHP.WhiteSpace.FunctionSpacing should recognize comments
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 232
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description
1 public function foo(): void {
2 //blah
3 }
4
5 // here's a comment
6 public function bar(): void {
7 //blah
8 }
The above produces an error:
6 | ERROR | [x] Every function/method needs a newline before (CakePHP.WhiteSpace.FunctionSpacing.Concrete)
Line 4 is a newline, which, IMO, satisfies the sniff requirement. The sniff is not paying attention to the fact that just above is a comment, and above that comment is a new line.
Changing line 5 to this /** here's a comment */ passes the sniff. Why does one comment style pass and the other does not? Both are perfectly valid php comments.
Contributor guide
No contributing guide indexed for this repository
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 CakePHP.WhiteSpace.FunctionSpacing sniff and reproduce the reported PHP example containing line comments and doc comments. Trace why the blank line before the function is treated differently, then add coverage showing both valid comment styles satisfy the spacing requirement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100