Skip to content

Commit bf71252

Browse files
committed
File::getMethodProperties(): add extra test with nullable static return type
1 parent 767d63a commit bf71252

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/Core/File/GetMethodPropertiesTest.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ class ReturnMe {
7979
private function myFunction(): static {
8080
return $this;
8181
}
82+
83+
/* testReturnTypeNullableStatic */
84+
function myNullableFunction(): ?static {
85+
return $this;
86+
}
8287
}
8388

8489
/* testPHP8MixedTypeHint */

tests/Core/File/GetMethodPropertiesTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,32 @@ public function testReturnTypeStatic()
563563
}//end testReturnTypeStatic()
564564

565565

566+
/**
567+
* Test a function with return type "?static".
568+
*
569+
* @return void
570+
*/
571+
public function testReturnTypeNullableStatic()
572+
{
573+
// Offsets are relative to the T_FUNCTION token.
574+
$expected = [
575+
'scope' => 'public',
576+
'scope_specified' => false,
577+
'return_type' => '?static',
578+
'return_type_token' => 8,
579+
'return_type_end_token' => 8,
580+
'nullable_return_type' => true,
581+
'is_abstract' => false,
582+
'is_final' => false,
583+
'is_static' => false,
584+
'has_body' => true,
585+
];
586+
587+
$this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected);
588+
589+
}//end testReturnTypeNullableStatic()
590+
591+
566592
/**
567593
* Test a function with return type "mixed".
568594
*

0 commit comments

Comments
 (0)