Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nathanbrauer opened this issue Oct 19, 2023 · 0 comments
Open

Comments

@nathanbrauer
Copy link

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?

@nathanbrauer nathanbrauer changed the title Checking if $callback is callable, but calling $this->callback() Checking if $callback is callable, but then calling $this->callback() Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant