Skip to content

Commit b0c6462

Browse files
committed
Emit readonly classes natively with PHP 8.2
See https://wiki.php.net/rfc/readonly_classes
1 parent 1428196 commit b0c6462

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

ChangeLog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ XP Compiler ChangeLog
66
* Added PHP 8.4 emitter which natively emits property hooks and asymmetric
77
visibility syntax
88
(@thekid)
9-
* Changed emitter to use native readonly classes in PHP 8.3, fixing an
9+
* Changed emitter to use native readonly classes in PHP 8.2, fixing an
1010
inconsistency with accessing undefined properties
1111
(@thekid)
1212

src/main/php/lang/ast/emit/PHP82.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class PHP82 extends PHP {
2424
RewriteDynamicClassConstants,
2525
RewriteStaticVariableInitializations,
2626
RewriteProperties,
27-
ReadonlyClasses,
2827
OmitConstantTypes
2928
;
3029

src/test/php/lang/ast/unittest/emit/PHP82Test.class.php

+8
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ public function callable_static_method_syntax() {
2222
public function callable_instance_method_syntax() {
2323
Assert::equals('$this->method(...);', $this->emit('$this->method(...);'));
2424
}
25+
26+
#[Test]
27+
public function readonly_classes() {
28+
Assert::matches(
29+
'/readonly class [A-Z0-9]+{/',
30+
$this->emit('readonly class %T { }')
31+
);
32+
}
2533
}

0 commit comments

Comments
 (0)