Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

http-foundation InputBag::get with default value should not return null #91

Closed
@raalderink

Description

If you use HTTPFoundation's Request, and then get specific input bags (query/request,...), the get may return string|null. However, if you pass parameter #2 $default as non-null value, it will never return null, and always a string.

So for example this code can never return null;

$request->query->get('name', 'default value');

Currently, because the typehint on the function is string|null, PHPStan will complain if you pass this to a function with a non-null argument, even though it will never return null;

Parameter #2 $name of class Foo constructor expects string, string|null given

This is tested on Symfony 5.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /