Skip to content

Commit d61d363

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 8685f13 + e380e3c commit d61d363

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Internal/Hydrator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public static function getHydrator($class)
6464
return $baseHydrator;
6565

6666
case 'ErrorException':
67-
return $baseHydrator->bindTo(null, new class() extends \ErrorException {
67+
return $baseHydrator->bindTo(null, new class extends \ErrorException {
6868
});
6969

7070
case 'TypeError':
71-
return $baseHydrator->bindTo(null, new class() extends \Error {
71+
return $baseHydrator->bindTo(null, new class extends \Error {
7272
});
7373

7474
case 'SplObjectStorage':
@@ -166,11 +166,11 @@ public static function getSimpleHydrator($class)
166166
return $baseHydrator;
167167

168168
case 'ErrorException':
169-
return $baseHydrator->bindTo(new \stdClass(), new class() extends \ErrorException {
169+
return $baseHydrator->bindTo(new \stdClass(), new class extends \ErrorException {
170170
});
171171

172172
case 'TypeError':
173-
return $baseHydrator->bindTo(new \stdClass(), new class() extends \Error {
173+
return $baseHydrator->bindTo(new \stdClass(), new class extends \Error {
174174
});
175175

176176
case 'SplObjectStorage':

Tests/LazyGhostTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function testReflectionPropertyGetValue()
225225

226226
public function testIndirectModification()
227227
{
228-
$obj = new class() {
228+
$obj = new class {
229229
public array $foo;
230230
};
231231
$proxy = $this->createLazyGhost($obj::class, fn () => null);

Tests/LazyProxyTraitTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function testOverwritePropClass()
205205

206206
public function testWither()
207207
{
208-
$obj = new class() {
208+
$obj = new class {
209209
public $foo = 123;
210210

211211
public function withFoo($foo): static
@@ -226,7 +226,7 @@ public function withFoo($foo): static
226226

227227
public function testFluent()
228228
{
229-
$obj = new class() {
229+
$obj = new class {
230230
public $foo = 123;
231231

232232
public function setFoo($foo): static
@@ -244,7 +244,7 @@ public function setFoo($foo): static
244244

245245
public function testIndirectModification()
246246
{
247-
$obj = new class() {
247+
$obj = new class {
248248
public array $foo;
249249
};
250250
$proxy = $this->createLazyProxy($obj::class, fn () => $obj);
@@ -268,7 +268,7 @@ public function testReadOnlyClass()
268268

269269
public function testLazyDecoratorClass()
270270
{
271-
$obj = new class() extends TestClass {
271+
$obj = new class extends TestClass {
272272
use LazyProxyTrait {
273273
createLazyProxy as private;
274274
}

Tests/ProxyHelperTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function testGenerateLazyProxyForClassWithUnserializeMagicMethod(object $
170170

171171
public static function classWithUnserializeMagicMethodProvider(): iterable
172172
{
173-
yield 'not type hinted __unserialize method' => [new class() {
173+
yield 'not type hinted __unserialize method' => [new class {
174174
public function __unserialize($array)
175175
{
176176
}
@@ -190,7 +190,7 @@ public function __unserialize($data): void
190190
}
191191
EOPHP];
192192
193-
yield 'type hinted __unserialize method' => [new class() {
193+
yield 'type hinted __unserialize method' => [new class {
194194
public function __unserialize(array $array)
195195
{
196196
}
@@ -220,7 +220,7 @@ public function foo(#[\SensitiveParameter] $a): int
220220

221221
EOPHP;
222222

223-
$class = new \ReflectionClass(new class() {
223+
$class = new \ReflectionClass(new class {
224224
#[SomeAttribute]
225225
public function foo(#[\SensitiveParameter, AnotherAttribute] $a): int
226226
{

Tests/VarExporterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function provideFailingSerialization()
6565
yield [$h = fopen(__FILE__, 'r')];
6666
yield [[$h]];
6767

68-
$a = new class() {
68+
$a = new class {
6969
};
7070

7171
yield [$a];

0 commit comments

Comments
 (0)