Skip to content

Commit

Permalink
File::getMethodProperties(): add tests with PHP 8 "mixed" return type
Browse files Browse the repository at this point in the history
No changes needed to the actual method, the return type is already handled correctly.
  • Loading branch information
jrfnl committed Jul 15, 2020
1 parent 80f031b commit 17b2c66
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Core/File/GetMethodPropertiesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ class ReturnMe {
return $this;
}
}

/* testPHP8MixedTypeHint */
function mixedTypeHint() :mixed {}

/* testPHP8MixedTypeHintNullable */
// Intentional fatal error - nullability is not allowed with mixed, but that's not the concern of the method.
function mixedTypeHintNullable(): ?mixed {}
46 changes: 46 additions & 0 deletions tests/Core/File/GetMethodPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,52 @@ public function testReturnTypeStatic()
}//end testReturnTypeStatic()


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

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

}//end testPHP8MixedTypeHint()


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

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

}//end testPHP8MixedTypeHintNullable()


/**
* Test helper.
*
Expand Down

0 comments on commit 17b2c66

Please sign in to comment.