magento / magento/magento-coding-standard
Conflicts with PER-CS 2.0 in regards with formatting braces for empty classes
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
### Preconditions
1. Have a class like this:
```php
If class contains no additional declarations (such as an exception that exists only to extend another exception with a new type), then the body of the class SHOULD be abbreviated as {} and placed on the same line as the previous symbol, separated by a space. For example:
>
> `class MyException extends \RuntimeException {}`
### Actual result
1. It outputs:
```
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
9 | WARNING | [x] Opening brace of a class must be on the line after the definition
| | (PSR2.Classes.ClassDeclaration.OpenBraceNewLine)
9 | WARNING | [x] Closing brace must be on a line by itself (Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore)
--------------------------------------------------------------------------------------------------------------------------------------
```
### Discussion
When you use php-cs-fixer with the PER-CS 2.0 ruleset, it conflicts with this Magento2 phpcs standard.
Not sure if this should be considered a bug in the M2 coding-standards, or more of a bug in phpcs itself?
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 by reproducing the reported warnings with the provided PHP class and Magento's PHPCS coding standard, then compare the result with the linked PER-CS 2.0 rule. Done means the empty class format produces no warnings while preserving the standard's other checks; the issue does not name a file or test to update.
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