File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Tests ;
6+
7+ class ClassTest extends RepresenterTestCase
8+ {
9+ public function testClassConstantType (): void
10+ {
11+ $ this ->assertSameRepresentation (
12+ <<<'CODE'
13+ <?php
14+ interface I {
15+ const string PHP = 'PHP 8.3';
16+ }
17+
18+ class Php84 implements I {
19+ const string PHP = 'PHP 8.4';
20+ }
21+ CODE,
22+ <<<'CODE'
23+ <?php
24+ interface I {
25+ const PHP = 'PHP 8.3';
26+ }
27+
28+ class Php84 implements I {
29+ const PHP = 'PHP 8.4';
30+ }
31+ CODE,
32+ );
33+ }
34+ }
Original file line number Diff line number Diff line change 2121use PhpParser \Node \Scalar \InterpolatedString ;
2222use PhpParser \Node \Scalar \String_ ;
2323use PhpParser \Node \Stmt \Class_ ;
24+ use PhpParser \Node \Stmt \ClassConst ;
2425use PhpParser \Node \Stmt \ClassMethod ;
2526use PhpParser \Node \Stmt \Function_ ;
2627use PhpParser \Node \Stmt \InlineHTML ;
@@ -249,6 +250,14 @@ private function normalizeCastDouble(Double $node): void
249250 $ node ->setAttribute ('kind ' , Double::KIND_DOUBLE );
250251 }
251252
253+ /**
254+ * TRANSFORM: remove class const type
255+ */
256+ private function removeClassConstType (ClassConst $ node ): void
257+ {
258+ $ node ->type = null ;
259+ }
260+
252261 /**
253262 * {@inheritDoc}
254263 */
@@ -283,6 +292,8 @@ public function enterNode(Node $node)
283292 $ this ->replaceStaticCallName ($ node );
284293 } elseif ($ node instanceof MethodCall) {
285294 $ this ->replaceMethodCallName ($ node );
295+ } elseif ($ node instanceof ClassConst) {
296+ $ this ->removeClassConstType ($ node );
286297 }
287298
288299 return null ;
You can’t perform that action at this time.
0 commit comments