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

Collection tap changes wrong collection #24675

Closed
Fuzzyma opened this issue Jun 23, 2018 · 3 comments
Closed

Collection tap changes wrong collection #24675

Fuzzyma opened this issue Jun 23, 2018 · 3 comments

Comments

@Fuzzyma
Copy link

Fuzzyma commented Jun 23, 2018

The tap method of Collection seems broken. I only read the source but to me it seems like the callack gets passed a copy of the collection but NOT the copy is returned. So basically the callback acts on a Collection which will be GarbageCollected afterwards:

    public function tap(callable $callback)
    {
        $callback(new static($this->items));
        return $this;
    }

Source

@staudenmeir
Copy link
Contributor

The original PR explains it: #17756

@JosephSilber
Copy link
Member

@staudenmeir and the original PR is wrong 😢

@Fuzzyma
Copy link
Author

Fuzzyma commented Sep 25, 2020

I KNEW it!!! :D

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

4 participants