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 () {};
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
expected
actual
reference
in PHP-CS-Fixer with @PSR12 Rulesets, 'space_before_parenthesis' option is true
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/f45c5a08595b5d09b1aec3b284a5fc854fc9eeb2/doc/rules/class_notation/class_definition.rst#example-5
in PHP_CodeSniffer is same style https://github.com/squizlabs/PHP_CodeSniffer/issues/3200