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

Issue on styling anonymous class with parentheses #567

Open
tobigumo opened this issue Mar 4, 2022 · 1 comment
Open

Issue on styling anonymous class with parentheses #567

tobigumo opened this issue Mar 4, 2022 · 1 comment

Comments

@tobigumo
Copy link

tobigumo commented Mar 4, 2022

Q A
Bug report? yes
Feature request? no
Library version 2.1.0

In anonymous class style, I expected, class keyword, one space, parentheses, one space and opening curly brace.
but actual, no one space after class keyword.

sample

test code

<?php
return new class {
    public function __construct(private $num)
    {
        $this->num = $num;
    }
};

expected

--- Original
+++ New
<?php
-return new class {
+return new class () {
    public function __construct(private $num)
    {
        $this->num = $num;
    }
};

actual

--- Original
+++ New
<?php
-return new class {
+return new class() {
    public function __construct(private $num)
    {
        $this->num = $num;
    }
};

reference

in PHP-CS-Fixer with @psr12 Rulesets,
'space_before_parenthesis' option is true

--- Original
+++ New
 <?php
-$foo = new class(){};
+$foo = new class () {};

https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/f45c5a08595b5d09b1aec3b284a5fc854fc9eeb2/doc/rules/class_notation/class_definition.rst#example-5

in PHP_CodeSniffer is same style
squizlabs/PHP_CodeSniffer#3200

@JustSteveKing
Copy link
Collaborator

Hey @tobigumo do you have a copy of your configuration so we can see what we are dealing with?

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

No branches or pull requests

2 participants