Skip to content

Commit

Permalink
fix phpstan hinting for search method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondřej Ešler committed Dec 11, 2019
1 parent 083068a commit e058817
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ final public function equals(Enum $enum) : bool
*
* @param mixed $for a value to search for
*
* @return ?Enum
* @return ?static
*/
final public static function search($for) : ?Enum
{
Expand Down
9 changes: 9 additions & 0 deletions tests/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,13 @@ public function testJsonEncode() : void
$this->assertSame('0.3333333333333333', json_encode(IntraWorldsEnum::TAMPA()));
$this->assertSame('{"foo":["bar"]}', json_encode(IntraWorldsEnum::MUNICH()));
}

public function testPhpstanHinting() : void
{
$search = static function ($value) : ?IntraWorldsEnum {
return IntraWorldsEnum::search($value);
};

$this->assertSame(IntraWorldsEnum::PILSEN(), $search(true));
}
}

0 comments on commit e058817

Please sign in to comment.