Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicts with PER-CS 2.0 in regards with formatting braces for empty classes #470

Open
hostep opened this issue Sep 26, 2023 · 2 comments
Labels
Projects

Comments

@hostep
Copy link
Contributor

hostep commented Sep 26, 2023

Preconditions

  1. Have a class like this:
<?php

declare(strict_types=1);

namespace Some\Namespace;

use Magento\Framework\Exception\LocalizedException;

class SomeException extends LocalizedException {}

Steps to reproduce

  1. Run Magento's phpcs coding standard against this class

Expected result

  1. No errors, as PER-CS 2.0 expects:

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?

@hostep hostep added the bug Something isn't working label Sep 26, 2023
@m2-assistant
Copy link

m2-assistant bot commented Sep 26, 2023

Hi @hostep. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this


Join Magento Community Engineering Slack and ask your questions in #github channel.

@hostep
Copy link
Contributor Author

hostep commented Feb 1, 2024

Is not entirely the same issue but is close enough: maybe we should also implement this from PER-CS 2.0: magento/magento2#38050 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Backlog
  
Ready for Grooming
Development

No branches or pull requests

1 participant