Skip to content

Commit

Permalink
Implement short set in accordance with RFC
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Mar 16, 2024
1 parent 8584d20 commit 5929c83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/php/lang/ast/emit/PropertyHooks.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function emitProperty($result, $property) {
$method,
new Signature($hook->parameter ? [$hook->parameter] : [new Parameter('value', null)], null),
null === $hook->expression ? null : [$this->rewriteHook(
$hook->expression,
$hook->expression instanceof Block ? $hook->expression : new Assignment($virtual, '=', $hook->expression),
$property->name,
$virtual,
$literal
Expand Down
10 changes: 5 additions & 5 deletions src/test/php/lang/ast/unittest/emit/PropertyHooksTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function run() {
#[Test]
public function set_expression() {
$r= $this->run('class %T {
public $test { set => $this->test= ucfirst($value); }
public $test { set => ucfirst($value); }
public function run() {
$this->test= "test";
Expand Down Expand Up @@ -96,7 +96,7 @@ public function get_and_set_using_property() {
$r= $this->run('class %T {
public $test {
get => $this->test;
set => $this->test= ucfirst($value);
set => ucfirst($value);
}
public function run() {
Expand Down Expand Up @@ -128,7 +128,7 @@ public function run() {
public function typed_set() {
$r= $this->run('use util\\Bytes; class %T {
public string $test {
set(string|Bytes $arg) => $this->test= ucfirst($arg);
set(string|Bytes $arg) => ucfirst($arg);
}
public function run() {
Expand All @@ -144,7 +144,7 @@ public function run() {
public function typed_mismatch() {
$this->run('class %T {
public string $test {
set(int $times) => $this->test= $times." times";
set(int $times) => $times." times";
}
public function run() {
Expand Down Expand Up @@ -203,7 +203,7 @@ public function reflection() {
$t= $this->declare('class %T {
public string $test {
get => $this->test;
set => $this->test= ucfirst($value);
set => ucfirst($value);
}
}');

Expand Down

0 comments on commit 5929c83

Please sign in to comment.