Skip to content

Commit

Permalink
test: Proof @param ?string is supported in current setup
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyvdSluijs committed May 19, 2023
1 parent b39a137 commit 80b949f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testCallMethodWithArrayTypeHintAndDocblock(): void
$this->assertEquals('Hello World', $result);
$this->assertEquals($this->calls, [new MethodCall('someMethodWithArrayTypeHint', [[new Argument('1'), new Argument('2')]])]);
}

public function testCallMethodWithAdditionalProvidedParamsOnSomeMethodWithoutArgs()
{
$result = $this->dispatcher->dispatch((string) new Request(1, 'someMethodWithoutArgs', ['arg' => new Argument('whatever')]));
Expand All @@ -91,4 +91,11 @@ public function testCallMethodWithAdditionalProvidedParamsOnSomeMethodWithTypeHi
$this->assertEquals('Hello World', $result);
$this->assertEquals($this->calls, [new MethodCall('someMethodWithTypeHint', [new Argument('whatever')])]);
}

public function testSomeMethodWithNullableTypeParamTag(): void
{
$result = $this->dispatcher->dispatch((string)new Request(1, 'someMethodWithNullableTypeParamTag', ['arg' => null]));
$this->assertEquals('Hello World', $result);
$this->assertEquals($this->calls, [new MethodCall('someMethodWithNullableTypeParamTag', [null])]);
}
}
9 changes: 9 additions & 0 deletions tests/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,13 @@ public function someMethodWithArrayTypeHint(array $args): string
$this->calls[] = new MethodCall('someMethodWithArrayTypeHint', func_get_args());
return 'Hello World';
}

/**
* @param ?string $arg
*/
public function someMethodWithNullableTypeParamTag($arg): string
{
$this->calls[] = new MethodCall('someMethodWithNullableTypeParamTag', func_get_args());
return 'Hello World';
}
}

0 comments on commit 80b949f

Please sign in to comment.