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

LazyCollection depends on tap helper #41298

Closed
nmokkenstorm opened this issue Mar 2, 2022 · 1 comment · Fixed by #41326
Closed

LazyCollection depends on tap helper #41298

nmokkenstorm opened this issue Mar 2, 2022 · 1 comment · Fixed by #41326
Labels

Comments

@nmokkenstorm
Copy link
Contributor

nmokkenstorm commented Mar 2, 2022

  • Laravel Version: 8.6.11, but the problem is present in 9.x / main
  • PHP Version: 8.1.0
  • Database Driver & Version: n/a

Description:

The sliding implementation here for Illuminate\Support\LazyCollection as defined on Illuminate\Support\Enumerable here uses the tap helper, which the file as defined here is not present for when installing the illuminate\collections package standalone, as it doesn't depend on illuminate/support

Steps To Reproduce:

  • Initialize empty composer project
  • composer require illuminate/collections
  • run the following:
LazyCollection::make(function () {
  foreach (range(1, 10) as $value) {
    yield $value;
  }
})->slide()->dd()

This gave me

PHP Fatal error:  Uncaught Error: Call to undefined function Illuminate\Support\tap() in /[redacted]/vendor/illuminate/collections/LazyCollection.php:974
Stack trace:
#0 /[redacted]/vendor/illuminate/collections/Traits/EnumeratesValues.php(243): Illuminate\Support\LazyCollection->Illuminate\Support\{closure}()
#1 /[redacted]/src/import.php(69): Illuminate\Support\LazyCollection->each()
#2 {main}
  thrown in /[redacted]/vendor/illuminate/collections/LazyCollection.php on line 974

which is in line with the above.

I think the correct solution is to not use tap here, as it seems not worth it to go into dependency hell to resolve this -> depending on illuminate/support within illuminate/collections seems to defeat the purpose of why they were separated in the first place not that long ago.

@driesvints
Copy link
Member

Thanks for your report. @JosephSilber was the original contributor and is gonna look into a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants