Skip to content

parse_url return value might not contain all possible keys #3040

@Daeroni

Description

@Daeroni

Bug report

parse_url return value will only contain elements, that were present in the url that was given,

eg. parse_url('//example.com/test') will return ['host' => 'example.com', 'path' => '/test']

If there is then a check for one element, eg. host, then phpstan assumes after that that all other possible keys are present also, eg. 'schema'.

Code snippet that reproduces the problem

https://phpstan.org/r/e1b54513-8e8b-4717-a414-78655097d39b

Expected output

No errors

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