Skip to content

Commit

Permalink
Use ?T syntax for nullable parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Mar 23, 2024
1 parent b6c1221 commit 7464265
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(private string... $in) { }
#[Test]
public function can_be_mixed_with_normal_arguments() {
$t= $this->declare('class %T {
public function __construct(public string $name, string $initial= null) {
public function __construct(public string $name, ?string $initial= null) {
if (null !== $initial) $this->name.= " ".$initial.".";
}
}');
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/lang/ast/unittest/emit/ParameterTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function value_typed() {

#[Test]
public function value_type_with_null() {
Assert::equals($this->nullable(new XPClass(Value::class)), $this->param('Value $param= null')->constraint()->type());
Assert::equals($this->nullable(new XPClass(Value::class)), $this->param('?Value $param= null')->constraint()->type());
}

#[Test]
Expand All @@ -65,7 +65,7 @@ public function string_typed() {

#[Test]
public function string_typed_with_null() {
Assert::equals($this->nullable(Primitive::$STRING), $this->param('string $param= null')->constraint()->type());
Assert::equals($this->nullable(Primitive::$STRING), $this->param('?string $param= null')->constraint()->type());
}

#[Test]
Expand Down

0 comments on commit 7464265

Please sign in to comment.