Skip to content

Commit eeff25e

Browse files
authored
fix: space after anonymous class keyword (#1579)
Fixes #1544
1 parent 06e2512 commit eeff25e

6 files changed

Lines changed: 41 additions & 41 deletions

File tree

src/printer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ function printNode(path, options, print) {
21452145
parts.push(
21462146
"class",
21472147
node.arguments.length > 0
2148-
? printArgumentsList(path, options, print)
2148+
? concat([" ", printArgumentsList(path, options, print)])
21492149
: "",
21502150
group(path.call(print, "what"))
21512151
);

tests/class/__snapshots__/jsfmt.spec.js.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ $app->setLogger(
315315
);
316316
317317
var_dump(
318-
new class(10) extends SomeClass implements SomeInterface {
318+
new class (10) extends SomeClass implements SomeInterface {
319319
private $num;
320320
321321
public function __construct($num)
@@ -339,7 +339,7 @@ class Outer
339339
340340
public function func2()
341341
{
342-
return new class($this->prop) extends Outer {
342+
return new class ($this->prop) extends Outer {
343343
private $prop3;
344344
345345
public function __construct($prop)
@@ -435,7 +435,7 @@ $class = new class
435435
{
436436
};
437437
438-
$class = new class(
438+
$class = new class (
439439
$arg,
440440
'string',
441441
2100,
@@ -446,7 +446,7 @@ $class = new class(
446446
}
447447
) {};
448448
449-
$class = new class(
449+
$class = new class (
450450
$arg,
451451
'string',
452452
2100,
@@ -457,7 +457,7 @@ $class = new class(
457457
}
458458
) implements MyOtherClass {};
459459
460-
$class = new class(
460+
$class = new class (
461461
$arg,
462462
'string',
463463
2100,
@@ -468,7 +468,7 @@ $class = new class(
468468
}
469469
) implements MyOtherClass, MyOtherClass1, MyOtherClass2 {};
470470
471-
$class = new class(
471+
$class = new class (
472472
$arg,
473473
'string',
474474
2100,
@@ -482,7 +482,7 @@ $class = new class(
482482
{
483483
};
484484
485-
$class = new class(
485+
$class = new class (
486486
$arg,
487487
'string',
488488
2100,
@@ -499,7 +499,7 @@ $class = new class(
499499
{
500500
};
501501
502-
$class = new class(
502+
$class = new class (
503503
$arg,
504504
'string',
505505
2100,
@@ -510,7 +510,7 @@ $class = new class(
510510
}
511511
) extends MyOtherClass {};
512512
513-
$class = new class(
513+
$class = new class (
514514
$arg,
515515
'string',
516516
2100,
@@ -524,7 +524,7 @@ $class = new class(
524524
{
525525
};
526526
527-
$class = new class(
527+
$class = new class (
528528
$arg,
529529
'string',
530530
2100,
@@ -535,7 +535,7 @@ $class = new class(
535535
}
536536
) extends MyOtherClass implements MyI {};
537537
538-
$class = new class(
538+
$class = new class (
539539
$arg,
540540
'string',
541541
2100,
@@ -546,7 +546,7 @@ $class = new class(
546546
}
547547
) extends MyOtherClass implements MyI, MyII, MyIII {};
548548
549-
$class = new class(
549+
$class = new class (
550550
$arg,
551551
'string',
552552
2100,
@@ -560,7 +560,7 @@ $class = new class(
560560
{
561561
};
562562
563-
$class = new class(
563+
$class = new class (
564564
$arg,
565565
'string',
566566
2100,
@@ -576,7 +576,7 @@ $class = new class(
576576
{
577577
};
578578
579-
$class = new class(
579+
$class = new class (
580580
$arg,
581581
'string',
582582
2100,
@@ -591,7 +591,7 @@ $class = new class(
591591
{
592592
};
593593
594-
$class = new class(
594+
$class = new class (
595595
$arg,
596596
'string',
597597
2100,
@@ -609,7 +609,7 @@ $class = new class(
609609
{
610610
};
611611
612-
$class = new class(
612+
$class = new class (
613613
$arg,
614614
'string',
615615
2100,

tests/comments/__snapshots__/jsfmt.spec.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ class Foo extends Bar implements Baz, Buzz
884884
}
885885
}
886886
887-
return new class($this->taxonomy, $this->post_types) extends Taxonomy_Config {
887+
return new class ($this->taxonomy, $this->post_types) extends Taxonomy_Config {
888888
// body of anonymous class
889889
public function get_args()
890890
{
@@ -893,7 +893,7 @@ return new class($this->taxonomy, $this->post_types) extends Taxonomy_Config {
893893
} // after member function on anonymous class
894894
};
895895
896-
$test = new class($arg1) extends Test {
896+
$test = new class ($arg1) extends Test {
897897
// some comment
898898
};
899899
@@ -5870,14 +5870,14 @@ $a = new class {
58705870
// Comment
58715871
};
58725872
5873-
$a = new class(
5873+
$a = new class (
58745874
// Comment
58755875
$a,
58765876
$b,
58775877
$c
58785878
) {};
58795879
5880-
$a = new class(
5880+
$a = new class (
58815881
// Comemnt
58825882
$a,
58835883
// Comment

tests/new/__snapshots__/jsfmt.spec.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ setLogger(
319319
}
320320
}
321321
);
322-
$var = new class(
322+
$var = new class (
323323
$arg,
324324
'string',
325325
2100,
@@ -400,19 +400,19 @@ string
400400
$var\`
401401
);
402402
403-
$var = new class(
403+
$var = new class (
404404
'string
405405
string
406406
string'
407407
) {};
408408
409-
$var = new class(
409+
$var = new class (
410410
'string
411411
string
412412
string'
413413
) {};
414414
415-
$var = new class(10) extends SomeClass implements SomeInterface {
415+
$var = new class (10) extends SomeClass implements SomeInterface {
416416
private $num;
417417
418418
public function __construct($num)

tests/nowdoc/__snapshots__/jsfmt.spec.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,15 +1299,15 @@ EOD
12991299
$b
13001300
);
13011301
1302-
$var = new class(
1302+
$var = new class (
13031303
<<<'EOD'
13041304
string
13051305
string
13061306
string
13071307
EOD
13081308
) {};
13091309
1310-
$var = new class(
1310+
$var = new class (
13111311
$a,
13121312
<<<'EOD'
13131313
string
@@ -1316,7 +1316,7 @@ string
13161316
EOD
13171317
) {};
13181318
1319-
$var = new class(
1319+
$var = new class (
13201320
<<<'EOD'
13211321
string
13221322
string
@@ -3371,7 +3371,7 @@ call(
33713371
$b,
33723372
);
33733373
3374-
$var = new class(
3374+
$var = new class (
33753375
<<<'EOD'
33763376
string
33773377
string
@@ -3380,7 +3380,7 @@ $var = new class(
33803380
,
33813381
) {};
33823382
3383-
$var = new class(
3383+
$var = new class (
33843384
$a,
33853385
<<<'EOD'
33863386
string
@@ -3390,7 +3390,7 @@ $var = new class(
33903390
,
33913391
) {};
33923392
3393-
$var = new class(
3393+
$var = new class (
33943394
<<<'EOD'
33953395
string
33963396
string

tests/trailing_commas/__snapshots__/jsfmt.spec.js.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,9 +2348,9 @@ $foo = new Foo(
23482348
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string'
23492349
);
23502350
2351-
$foo = new class('constructor', 'bar') {};
2351+
$foo = new class ('constructor', 'bar') {};
23522352
2353-
$foo = new class(
2353+
$foo = new class (
23542354
'constructor',
23552355
'bar',
23562356
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string'
@@ -2643,9 +2643,9 @@ $foo = new Foo(
26432643
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string'
26442644
);
26452645
2646-
$foo = new class('constructor', 'bar') {};
2646+
$foo = new class ('constructor', 'bar') {};
26472647
2648-
$foo = new class(
2648+
$foo = new class (
26492649
'constructor',
26502650
'bar',
26512651
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string'
@@ -2938,9 +2938,9 @@ $foo = new Foo(
29382938
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string'
29392939
);
29402940
2941-
$foo = new class('constructor', 'bar') {};
2941+
$foo = new class ('constructor', 'bar') {};
29422942
2943-
$foo = new class(
2943+
$foo = new class (
29442944
'constructor',
29452945
'bar',
29462946
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string'
@@ -3233,9 +3233,9 @@ $foo = new Foo(
32333233
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string',
32343234
);
32353235
3236-
$foo = new class('constructor', 'bar') {};
3236+
$foo = new class ('constructor', 'bar') {};
32373237
3238-
$foo = new class(
3238+
$foo = new class (
32393239
'constructor',
32403240
'bar',
32413241
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string',
@@ -3530,9 +3530,9 @@ $foo = new Foo(
35303530
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string'
35313531
);
35323532
3533-
$foo = new class('constructor', 'bar') {};
3533+
$foo = new class ('constructor', 'bar') {};
35343534
3535-
$foo = new class(
3535+
$foo = new class (
35363536
'constructor',
35373537
'bar',
35383538
'very-very-very-very-very-very-very-very-very-very-very-very-veru-long-string'

0 commit comments

Comments
 (0)