Skip to content

Commit

Permalink
Test native hooks / asymmetric visibility emitter for PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Aug 31, 2024
1 parent ab07d7c commit 1428196
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ XP Compiler ChangeLog

## ?.?.? / ????-??-??

* Added PHP 8.4 emitter which feature-checks for both property hooks
and asymmetric visibility RFCs, deciding whether to natively emit or
use virtual properties
* 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
inconsistency with accessing undefined properties
Expand Down
26 changes: 26 additions & 0 deletions src/test/php/lang/ast/unittest/emit/PHP84Test.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php namespace lang\ast\unittest\emit;

use lang\ast\emit\Type;
use test\{Assert, Test};

class PHP84Test extends EmittingTest {

/** @return string */
protected function runtime() { return 'php:8.4.0'; }

#[Test]
public function property_hooks() {
Assert::matches(
'/\$test{get=>"Test";}/',
$this->emit('class %T { public $test { get => "Test"; } }')
);
}

#[Test]
public function asymmetric_visibility() {
Assert::matches(
'/public private\(set\) string \$test/',
$this->emit('class %T { public private(set) string $test; }')
);
}
}

0 comments on commit 1428196

Please sign in to comment.