Skip to content

Map::ksort TypeError on null comparator  #134

@ollieread

Description

@ollieread

When calling the ksort() method on Ds\Map I get the following error if the parameter is null or a variable that is null.

TypeError: Ds\Map::ksort() expects parameter 1 to be a valid callback, no array or string given

Omitting the parameter entirely works without issue.

The reason I'm running into this issue is that I actually have a few classes that basically wrap around the DS data structures. The particular method I have that causes this issue, is:

public function ksort(?callable $comparator = null): self
{
    $this->items->ksort($comparator);
    return $this;
}

In this case $this->items is an instance of Ds\Map.

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