Skip to content

Commit 8a7744a

Browse files
Fix InputBag::get (#200)
1 parent 3b455dd commit 8a7744a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Stubs/5/InputBag.stubphp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ final class InputBag extends ParameterBag
77
/**
88
* Returns a string input value by name.
99
*
10-
* @template D of string|null
10+
* @template D of string|int|float|bool|null
1111
* @psalm-param D $default
12-
* @psalm-return string|D
12+
* @psalm-return string|int|float|bool|D
1313
* @psalm-taint-source input
1414
*/
1515
public function get(string $key, $default = null) {}

tests/acceptance/acceptance/InputBag.feature

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Feature: InputBag get return type
1111
use Symfony\Component\HttpFoundation\Request;
1212
"""
1313

14-
Scenario Outline: Return type is string if default argument is string.
14+
Scenario Outline: Return type is not null if default argument is string.
1515
Given I have the following code
1616
"""
1717
class App
@@ -24,11 +24,14 @@ Feature: InputBag get return type
2424
}
2525
"""
2626
When I run Psalm
27-
Then I see no errors
27+
Then I see these errors
28+
| Type | Message |
29+
| InvalidScalarArgument | Argument 1 of trim expects string, scalar provided |
2830
Examples:
2931
| property |
3032
| query |
3133
| cookies |
34+
| request |
3235

3336
Scenario Outline: Return type is nullable if default argument is not provided.
3437
Given I have the following code
@@ -44,10 +47,11 @@ Feature: InputBag get return type
4447
"""
4548
When I run Psalm
4649
Then I see these errors
47-
| Type | Message |
48-
| PossiblyNullArgument | Argument 1 of trim cannot be null, possibly null value provided |
50+
| Type | Message |
51+
| InvalidScalarArgument | Argument 1 of trim expects string, null\|scalar provided |
4952
And I see no other errors
5053
Examples:
5154
| property |
5255
| query |
5356
| cookies |
57+
| request |

0 commit comments

Comments
 (0)