Skip to content

Commit

Permalink
Merge branch 'feature/file-getmethod-properties-allow-static-return-t…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jun 22, 2020
2 parents ad0bfc2 + 7e24a44 commit 4c6f4be
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,7 @@ public function getMethodProperties($stackPtr)
T_CALLABLE => T_CALLABLE,
T_SELF => T_SELF,
T_PARENT => T_PARENT,
T_STATIC => T_STATIC,
T_NS_SEPARATOR => T_NS_SEPARATOR,
];

Expand Down
7 changes: 7 additions & 0 deletions tests/Core/File/GetMethodPropertiesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,10 @@ $result = array_map(
static fn(int $number) : int => $number + 1,
$numbers
);

class ReturnMe {
/* testReturnTypeStatic */
private function myFunction(): static {
return $this;
}
}
23 changes: 23 additions & 0 deletions tests/Core/File/GetMethodPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,29 @@ public function testArrowFunction()
}//end testArrowFunction()


/**
* Test a function with return type "static".
*
* @return void
*/
public function testReturnTypeStatic()
{
$expected = [
'scope' => 'private',
'scope_specified' => true,
'return_type' => 'static',
'nullable_return_type' => false,
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

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

}//end testReturnTypeStatic()


/**
* Test helper.
*
Expand Down

0 comments on commit 4c6f4be

Please sign in to comment.