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

Wrong fix of new without parentheses on anonymous readonly class #1673

Open
paranoiq opened this issue Apr 25, 2024 · 0 comments
Open

Wrong fix of new without parentheses on anonymous readonly class #1673

paranoiq opened this issue Apr 25, 2024 · 0 comments

Comments

@paranoiq
Copy link

paranoiq commented Apr 25, 2024

rule: Usage of "new" without parentheses is disallowed. (SlevomatCodingStandard.ControlStructures.NewWithParentheses.MissingParentheses)

$object3 = new class {
    public readonly int $foo;
    public int $bar;
};

is not detected at all (this may be a feature? - running with default configuration: <rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>)

$object4 = new readonly class {
    public int $foo;
};

is autofixed to invalid code (wrong parentheses placement):

$object4 = new readonly class {
    public int $foo();
};

this is ok (no error. not changed):

$object4 = new readonly class() {
    public int $foo;
};
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

1 participant