Skip to content

Commit 421d01f

Browse files
committed
Improve the return type of ParameterBag::getEnum
The return value can only be null when using null as default value. when providing an enum instance as default value, we know that the return value will always be an enum instance.
1 parent 5ec3fa3 commit 421d01f

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

InputBag.php

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public function set(string $key, mixed $value): void
8383
* @param ?T $default
8484
*
8585
* @return ?T
86+
*
87+
* @psalm-return ($default is null ? T|null : T)
8688
*/
8789
public function getEnum(string $key, string $class, ?\BackedEnum $default = null): ?\BackedEnum
8890
{

ParameterBag.php

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ public function getBoolean(string $key, bool $default = false): bool
160160
* @param ?T $default
161161
*
162162
* @return ?T
163+
*
164+
* @psalm-return ($default is null ? T|null : T)
163165
*/
164166
public function getEnum(string $key, string $class, ?\BackedEnum $default = null): ?\BackedEnum
165167
{

0 commit comments

Comments
 (0)