Skip to content

Type inference for HeaderBag could support has() #399

@Seldaek

Description

@Seldaek

Right now calling this triggers an error as the returned header is string|null, but really after ->has($key) returns true, we can assert that ->get($sameKey) will be string. At least as long as there is no other impure call made in between like ->remove() or ->replace()

if ($request->headers->has('foo')) {
    $v = strtolower($request->headers->get('foo'));
}

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