Skip to content

Commit 4187b64

Browse files
committed
minor #57901 Code style change in `@PER-CS2.0 affecting @Symfony` (parentheses for anonymous classes) (bonroyage)
This PR was squashed before being merged into the 7.2 branch. Discussion ---------- Code style change in ``@PER`-CS2.0` affecting ``@Symfony`` (parentheses for anonymous classes) | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT I have created a PR (PHP-CS-Fixer/PHP-CS-Fixer#8140) in the PHP-CS-Fixer repo to bring the ``@PER`-CS2.0` ruleset in line with the specifications on the `new_with_parentheses` rule for anonymous classes. Since the ``@Symfony`` ruleset builds upon the ``@PER`-CS2.0` ruleset, they would like confirmation that the Symfony community is OK with this change affecting the Symfony ruleset as well. Should it not be, I'll push another commit there ensuring that the change does not affect ``@Symfony``. Therefore, this PR is not meant to be merged, but function as an RFC to get your opinion and show the effect it would have when applied to the Symfony source. Commits ------- 506e0dd327 Code style change in ``@PER`-CS2.0` affecting ``@Symfony`` (parentheses for anonymous classes)
2 parents 79d4511 + cc18d66 commit 4187b64

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

Tests/InputBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class InputBagTest extends TestCase
2020
{
2121
public function testGet()
2222
{
23-
$bag = new InputBag(['foo' => 'bar', 'null' => null, 'int' => 1, 'float' => 1.0, 'bool' => false, 'stringable' => new class() implements \Stringable {
23+
$bag = new InputBag(['foo' => 'bar', 'null' => null, 'int' => 1, 'float' => 1.0, 'bool' => false, 'stringable' => new class implements \Stringable {
2424
public function __toString(): string
2525
{
2626
return 'strval';
@@ -58,7 +58,7 @@ public function testGetBooleanError()
5858

5959
public function testGetString()
6060
{
61-
$bag = new InputBag(['integer' => 123, 'bool_true' => true, 'bool_false' => false, 'string' => 'abc', 'stringable' => new class() implements \Stringable {
61+
$bag = new InputBag(['integer' => 123, 'bool_true' => true, 'bool_false' => false, 'string' => 'abc', 'stringable' => new class implements \Stringable {
6262
public function __toString(): string
6363
{
6464
return 'strval';

Tests/JsonResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function testConstructorWithNullAsDataThrowsAnUnexpectedValueException()
171171

172172
public function testConstructorWithObjectWithToStringMethod()
173173
{
174-
$class = new class() {
174+
$class = new class {
175175
public function __toString(): string
176176
{
177177
return '{}';

Tests/ParameterBagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function testGetIntExceptionWithInvalid()
206206

207207
public function testGetString()
208208
{
209-
$bag = new ParameterBag(['integer' => 123, 'bool_true' => true, 'bool_false' => false, 'string' => 'abc', 'stringable' => new class() implements \Stringable {
209+
$bag = new ParameterBag(['integer' => 123, 'bool_true' => true, 'bool_false' => false, 'string' => 'abc', 'stringable' => new class implements \Stringable {
210210
public function __toString(): string
211211
{
212212
return 'strval';

Tests/RequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2213,7 +2213,7 @@ public function testFactory()
22132213

22142214
public function testFactoryCallable()
22152215
{
2216-
$requestFactory = new class() {
2216+
$requestFactory = new class {
22172217
public function createRequest(): Request
22182218
{
22192219
return new NewRequest();

Tests/Session/Storage/Proxy/AbstractProxyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AbstractProxyTest extends TestCase
2626

2727
protected function setUp(): void
2828
{
29-
$this->proxy = new class() extends AbstractProxy {};
29+
$this->proxy = new class extends AbstractProxy {};
3030
}
3131

3232
public function testGetSaveHandlerName()

Tests/StreamedJsonResponseTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ public function testResponseOtherTraversable()
132132
{
133133
$arrayObject = new \ArrayObject(['__symfony_json__' => '__symfony_json__']);
134134

135-
$iteratorAggregate = new class() implements \IteratorAggregate {
135+
$iteratorAggregate = new class implements \IteratorAggregate {
136136
public function getIterator(): \Traversable
137137
{
138138
return new \ArrayIterator(['__symfony_json__']);
139139
}
140140
};
141141

142-
$jsonSerializable = new class() implements \IteratorAggregate, \JsonSerializable {
142+
$jsonSerializable = new class implements \IteratorAggregate, \JsonSerializable {
143143
public function getIterator(): \Traversable
144144
{
145145
return new \ArrayIterator(['This should be ignored']);
@@ -187,7 +187,7 @@ public function testResponseStatusCode()
187187

188188
public function testPlaceholderAsObjectStructure()
189189
{
190-
$object = new class() {
190+
$object = new class {
191191
public $__symfony_json__ = 'foo';
192192
public $bar = '__symfony_json__';
193193
};

0 commit comments

Comments
 (0)