Skip to content

Checking if $callback is callable, but then calling $this->callback()  #105

@nathanbrauer

Description

@nathanbrauer

Regarding this portion....

if (is_callable($callback)) {
$this->callback();
}

...of this method...

/**
* @param array|iterable $list
* @param callable|null $callback
* @return \Generator
*/
public function yieldSingle($list, $callback = null)
{
if (!is_array($list) && !$list instanceof \Traversable) {
$list = [$list];
}
foreach ($list as $item) {
$injected = (yield $item);
if ($injected === static::$STOP_GENERATOR) {
break;
}
}
if (is_callable($callback)) {
$this->callback();
}
}

We check to see if $callback is callable, but then we call $this->callback() instead of $callback().

Is this intentional? If so, shouldn't $callback just be boolean?

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