Skip to content

Possible Incorrect Return Type for Vector #111

@designermonkey

Description

@designermonkey

Between the extension and this polyfil, there is an inconsistency (I think, if I can read the C well enough) where the extension produces a new Vector from the merge method, but the polyfil uses the generic Sequence trait, which returns a Sequence.

This is causing some confusion with vimeo/psalm whose stubs must be created from the polyfil code. I get errors in psalm, and errors in tests depending on which way I set it.

For example:

    private Vector $middlewares;

    public function push(Middleware ...$middlewares): static
    {
        $this->middlewares = $this->middlewares->merge($middlewares);

        return $this;
    }

This should work fine, but psalm errors.

This is my current workaround:

    public function push(Middleware ...$middlewares): static
    {
        $new = $this->middlewares->merge($middlewares);
        $this->middlewares = new Vector($new);

        return $this;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions