Skip to content

Commit

Permalink
Add tests for reflective access to virtual properties
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed May 18, 2024
1 parent 7cd4039 commit 00e15f1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/php/lang/ast/unittest/emit/PropertyHooksTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@ public function abstract_property() {
Assert::equals('public abstract string $test', $t->property('test')->toString());
}

#[Test]
public function reflective_get() {
$t= $this->declare('class %T {
public string $test { get => "Test"; }
}');

$instance= $t->newInstance();
Assert::equals('Test', $t->property('test')->get($instance));
}

#[Test]
public function reflective_set() {
$t= $this->declare('class %T {
public string $test { set => ucfirst($value); }
}');

$instance= $t->newInstance();
$t->property('test')->set($instance, 'test');
Assert::equals('Test', $instance->test);
}

#[Test]
public function interface_hook() {
$t= $this->declare('interface %T {
Expand Down

0 comments on commit 00e15f1

Please sign in to comment.