Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ReflectionTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ReflectionTypeInterface
'null',
'void',
'self',
'static',
'array',
'callable',
'iterable',
Expand Down
17 changes: 17 additions & 0 deletions test/ReflectionTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class ReflectionTypeTest extends TestCase
*/
private $t3;

/**
* @var ReflectionType
*/
private $t4;

private function method(array $param = null, \Exception $param_2): void
{
// for testing only;
Expand All @@ -38,6 +43,11 @@ private function php8method(string|int $union_param): string|int
return $union_param;
}

private function fluentMethod(): static
{
return $this;
}

protected function setUp(): void
{
if (PHP_MAJOR_VERSION < 7) {
Expand All @@ -47,6 +57,7 @@ protected function setUp(): void
$this->t1 = new ReflectionType((new \ReflectionParameter([$this, 'method'], 'param'))->getType());
$this->t2 = new ReflectionType((new \ReflectionParameter([$this, 'method'], 'param_2'))->getType());
$this->t3 = new ReflectionType((new \ReflectionParameter([$this, 'php8method'], 'union_param'))->getType());
$this->t4 = new ReflectionType((new \ReflectionMethod($this, 'fluentMethod'))->getReturnType());
}

public function testGetName(): void
Expand All @@ -56,6 +67,12 @@ public function testGetName(): void
$this->assertSame('string|int', $this->t3->getName());
}

public function testGetNameDoesNotQualifyStaticReturnType(): void
{
// "static" is a reserved word, not a class name — qualifying it as "\static" is invalid PHP.
$this->assertSame('static', $this->t4->getName());
}

public function testAllowsNull(): void
{
$this->assertTrue($this->t1->allowsNull());
Expand Down
Loading