Skip to content

Commit 97e3450

Browse files
committed
✅ Add "new MyClass()->method() without parentheses" backward compatibility test
1 parent 5302ef1 commit 97e3450

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Tests;
6+
7+
class ClassInstantiationTest extends RepresenterTestCase
8+
{
9+
/**
10+
* Ensures that we represent with parentheses to avoid having to re-run the representer.
11+
*/
12+
public function testBackwardCompatibility(): void
13+
{
14+
$this->assertRepresentation(
15+
<<<'CODE'
16+
<?php
17+
new MyClass()->method();
18+
CODE,
19+
<<<'CODE'
20+
(new C0())->m0();
21+
CODE,
22+
'{"C0":"MyClass","m0":"method"}',
23+
);
24+
}
25+
26+
public function testClassInstantiation(): void
27+
{
28+
$this->assertSameRepresentation(
29+
<<<'CODE'
30+
<?php
31+
(new MyClass())->method();
32+
CODE,
33+
<<<'CODE'
34+
<?php
35+
new MyClass()->method();
36+
CODE,
37+
);
38+
}
39+
}

0 commit comments

Comments
 (0)