8000 minor #57901 Code style change in ``@PER`-CS2.0` affecting ``@Symfony… · symfony/error-handler@00574b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 00574b8

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 3e985c9 + 0ee7b0f commit 00574b8

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function __construct(
194194
$traceReflector->setValue($e, $trace);
195195
$e->file = $file ?? $e->file;
196196
$e->line = $line ?? $e->line;
197-
}, null, new class() extends \Exception {
197+
}, null, new class extends \Exception {
198198
});
199199
}
200200

ErrorRenderer/CliErrorRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CliErrorRenderer implements ErrorRendererInterface
2626
public function render(\Throwable $exception): FlattenException
2727
{
2828
$cloner = new VarCloner();
29-
$dumper = new class() extends CliDumper {
29+
$dumper = new class extends CliDumper {
3030
protected function supportsColors(): bool
3131
{
3232
$outputStream = $this->outputStream;

Tests/ErrorHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public function testHandleError()
333333

334334
public function testHandleErrorWithAnonymousClass()
335335
{
336-
$anonymousObject = new class() extends \stdClass {
336+
$anonymousObject = new class extends \stdClass {
337337
};
338338

339339
$handler = ErrorHandler::register();
@@ -422,7 +422,7 @@ public static function handleExceptionProvider(): array
422422
['Uncaught Exception: foo', new \Exception('foo')],
423423
['Uncaught Exception: foo', new class('foo') extends \RuntimeException {
424424
}],
425-
['Uncaught Exception: foo stdClass@anonymous bar', new \RuntimeException('foo '.(new class() extends \stdClass {
425+
['Uncaught Exception: foo stdClass@anonymous bar', new \RuntimeException('foo '.(new class extends \stdClass {
426426
})::class.' bar')],
427427
['Uncaught Error: bar', new \Error('bar')],
428428
['Uncaught ccc', new \ErrorException('ccc')],

Tests/Exception/FlattenExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public static function stringAndIntDataProvider(): array
245245

246246
public function testAnonymousClass()
247247
{
248-
$flattened = FlattenException::createFromThrowable(new class() extends \RuntimeException {
248+
$flattened = FlattenException::createFromThrowable(new class extends \RuntimeException {
249249
});
250250

251251
$this->assertSame('RuntimeException@anonymous', $flattened->getClass());
@@ -255,7 +255,7 @@ public function testAnonymousClass()
255255

256256
$this->assertSame('Symfony\Component\HttpKernel\Exception\NotFoundHttpException@anonymous', $flattened->getClass());
257257

258-
$flattened = FlattenException::createFromThrowable(new \Exception(\sprintf('Class "%s" blah.', (new class() extends \RuntimeException {
258+
$flattened = FlattenException::createFromThrowable(new \Exception(\sprintf('Class "%s" blah.', (new class extends \RuntimeException {
259259
})::class)));
260260

261261
$this->assertSame('Class "RuntimeException@anonymous" blah.', $flattened->getMessage());

0 commit comments

Comments
 (0)
0