Skip to content

Commit

Permalink
Emit readonly classes natively with PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Aug 31, 2024
1 parent 1428196 commit b0c6462
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ XP Compiler ChangeLog
* Added PHP 8.4 emitter which natively emits property hooks and asymmetric
visibility syntax
(@thekid)
* Changed emitter to use native readonly classes in PHP 8.3, fixing an
* Changed emitter to use native readonly classes in PHP 8.2, fixing an
inconsistency with accessing undefined properties
(@thekid)

Expand Down
1 change: 0 additions & 1 deletion src/main/php/lang/ast/emit/PHP82.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class PHP82 extends PHP {
RewriteDynamicClassConstants,
RewriteStaticVariableInitializations,
RewriteProperties,
ReadonlyClasses,
OmitConstantTypes
;

Expand Down
8 changes: 8 additions & 0 deletions src/test/php/lang/ast/unittest/emit/PHP82Test.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@ public function callable_static_method_syntax() {
public function callable_instance_method_syntax() {
Assert::equals('$this->method(...);', $this->emit('$this->method(...);'));
}

#[Test]
public function readonly_classes() {
Assert::matches(
'/readonly class [A-Z0-9]+{/',
$this->emit('readonly class %T { }')
);
}
}

0 comments on commit b0c6462

Please sign in to comment.