Skip to content

Commit

Permalink
File::getMethodProperties(): add extra test with nullable static retu…
Browse files Browse the repository at this point in the history
…rn type
  • Loading branch information
jrfnl committed Jan 31, 2024
1 parent c44475c commit 27ce14f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/Core/File/GetMethodPropertiesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class ReturnMe {
private function myFunction(): static {
return $this;
}

/* testReturnTypeNullableStatic */
function myNullableFunction(): ?static {
return $this;
}
}

/* testPHP8MixedTypeHint */
Expand Down
26 changes: 26 additions & 0 deletions tests/Core/File/GetMethodPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,32 @@ public function testReturnTypeStatic()
}//end testReturnTypeStatic()


/**
* Test a function with return type "?static".
*
* @return void
*/
public function testReturnTypeNullableStatic()
{
// Offsets are relative to the T_FUNCTION token.
$expected = [
'scope' => 'public',
'scope_specified' => false,
'return_type' => '?static',
'return_type_token' => 8,
'return_type_end_token' => 8,
'nullable_return_type' => true,
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected);

}//end testReturnTypeNullableStatic()


/**
* Test a function with return type "mixed".
*
Expand Down

0 comments on commit 27ce14f

Please sign in to comment.