tighten / takeout

Docker-based development-only dependency manager. macOS, Linux, and WSL2-only and installs via PHP's Composer... for now.
MIT License
1.59k stars 83 forks source link

Compatibility to PHP 8.1 #260

Closed ahoiroman closed 2 years ago

ahoiroman commented 2 years ago

Hello,

using takeout, I am getting this error:

➜  ~ takeout --help

Deprecated: Return type of HumbugBox3130\KevinGH\RequirementChecker\RequirementCollection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/.box/src/RequirementCollection.php on line 12

Deprecated: Return type of HumbugBox3130\KevinGH\RequirementChecker\RequirementCollection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/.box/src/RequirementCollection.php on line 16

Deprecated: Return type of PhpOption\Some::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/phpoption/phpoption/src/PhpOption/Some.php on line 152

Deprecated: Return type of PhpOption\None::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/phpoption/phpoption/src/PhpOption/None.php on line 118

Deprecated: Return type of Symfony\Component\Finder\Finder::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/finder/Finder.php on line 608

Deprecated: Return type of Symfony\Component\Finder\Finder::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/finder/Finder.php on line 690

Deprecated: Return type of Symfony\Component\Finder\Iterator\FileTypeFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/finder/Iterator/FileTypeFilterIterator.php on line 42

Deprecated: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php on line 55

Deprecated: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::hasChildren() should either be compatible with RecursiveIterator::hasChildren(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php on line 74

Deprecated: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::getChildren() should either be compatible with RecursiveIterator::getChildren(): ?RecursiveIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php on line 82

Deprecated: Return type of Symfony\Component\Finder\Iterator\FilenameFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/finder/Iterator/FilenameFilterIterator.php on line 28

Deprecated: Return type of Symfony\Component\Finder\Iterator\PathFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/finder/Iterator/PathFilterIterator.php on line 27

In HelperSet.php line 22:

  During inheritance of IteratorAggregate: Uncaught ErrorException: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getItera  
  tor(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfo  
  ny/console/Helper/HelperSet.php:94                                                                                                                                                                       
  Stack trace:                                                                                                                                                                                             
  #0 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/console/Helper/HelperSet.php(22): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return  
   type of ...', 'phar:///Users/r...', 94)                                                                                                                                                                 
  #1 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/.box/vendor/composer/ClassLoader.php(478): include('phar:///Users/r...')                                                      
  #2 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/.box/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('phar:///Users/r...')                                
  #3 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/console/Application.php(1065): Composer\Autoload\ClassLoader->loadClass('Symfony\\Compone...')                 
  #4 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/console/Application.php(321): Symfony\Component\Console\Application->getDefaultHelperSet()                     
  #5 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/console/Command/Command.php(140): Symfony\Component\Console\Application->getHelperSet()                        
  #6 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/console/Application.php(489): Symfony\Component\Console\Command\Command->setApplication(Object(Illuminate\Con  
  sole\Application))                                                                                                                                                                                       
  #7 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/console/Application.php(249): Symfony\Component\Console\Application->add(Object(Symfony\Component\Console\  
  Command\HelpCommand))                                                                                                                                                                                    
  #8 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/console/Application.php(238): Illuminate\Console\Application->addToParent(Object(Symfony\Component\Console  
  \Command\HelpCommand))                                                                                                                                                                                   
  #9 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/console/Application.php(1236): Illuminate\Console\Application->add(Object(Symfony\Component\Console\Command\H  
  elpCommand))                                                                                                                                                                                             
  #10 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/console/Application.php(487): Symfony\Component\Console\Application->init()                                   
  #11 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/console/Application.php(249): Symfony\Component\Console\Application->add(Object(NunoMaduro\Collision\Adap  
  ters\Laravel\Commands\TestCommand))                                                                                                                                                                      
  #12 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/console/Application.php(238): Illuminate\Console\Application->addToParent(Object(NunoMaduro\Collision\Ada  
  pters\Laravel\Commands\TestCommand))                                                                                                                                                                     
  #13 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/console/Application.php(260): Illuminate\Console\Application->add(Object(NunoMaduro\Collision\Adapters\La  
  ravel\Commands\TestCommand))                                                                                                                                                                             
  #14 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/console/Application.php(274): Illuminate\Console\Application->resolve('NunoMaduro\\Coll...')               
  #15 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/support/ServiceProvider.php(396): Illuminate\Console\Application->resolveCommands(Array)                   
  #16 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/console/Application.php(151): Illuminate\Support\ServiceProvider->Illuminate\Support\{closure}(Object(Ill  
  uminate\Console\Application))                                                                                                                                                                            
  #17 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/illuminate/console/Application.php(74): Illuminate\Console\Application->bootstrap()                                   
  #18 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Console/Kernel.php(330): Illuminate\Console\Application->__constru  
  ct(Object(LaravelZero\Framework\Application), Object(Illuminate\Events\Dispatcher), 'v1.8.12')                                                                                                           
  #19 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/laravel-zero/framework/src/Kernel.php(133): Illuminate\Foundation\Console\Kernel->getArtisan()                        
  #20 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/laravel-zero/framework/src/Kernel.php(102): LaravelZero\Framework\Kernel->bootstrap()                                 
  #21 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/vendor/laravel-zero/framework/src/Kernel.php(89): LaravelZero\Framework\Kernel->ensureDefaultCommand(Object(Symfony\Compone  
  nt\Console\Input\ArgvInput))                                                                                                                                                                             
  #22 phar:///Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout/takeout(36): LaravelZero\Framework\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Compone  
  nt\Console\Output\ConsoleOutput))                                                                                                                                                                        
  #23 /Users/ahoi/.composer/vendor/tightenco/takeout/builds/takeout(14): require('phar:///Users/r...')                                                                                                  
  #24 {main}                                                                                                                                                                                               

No problem, I will switch back to 8.0 - is there any ETA for 8.1? Unfortunately I can't contribute by myself at the moment, but I'd be happy to sponsor this package, but the sponsorship-option is disabled.

mrailton commented 2 years ago

I've taken a look at this and it appears that it just needs a new build to be created against PHP 8.1 and released.

I've installed PHP 8.1 locally and run composer install & ./vendor/bin/phpunit, all seems to run well. I've created a new build with php ./takeout app:build and the resulting build appears to work fine.

I have created #261 to add PHP 8.1 to the test suite in Actions

mattstauffer commented 2 years ago

Merged #261; I'll test out the build process locally shortly.

mattstauffer commented 2 years ago

Hm.. after upgrading to 8.1, I can't even build:

image

I'll dig into this a bit later

osbre commented 2 years ago

I've got the same error when using Takeout on PHP 8.1:

PHP Fatal error:  During inheritance of IteratorAggregate: Uncaught ErrorException: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///home/user/.config/composer/vendor/tightenco/takeout/builds/takeout/vendor/symfony/console/Helper/HelperSet.php:94
chrisdicarlo commented 2 years ago

In case it's useful to anyone dealing with these errors, I thought I would mention what I've done as a workaround. Since I've got PHP 8.1 as my default CLI version (but I've got 7.3-8.0 also installed), I just created an alias in my .zshrc that forces Takeout to run under a specific PHP version, e.g.:

alias takeout="php8.0 ~/.config/composer/vendor/bin/takeout"

Not ideal but it lets me run Valet under 8.1 and still maintain a functioning Takeout install.

ahoiroman commented 2 years ago

A very good hint.

Don't forget to source your .zshrc after that.

In my case I had to adopt this a little bit (expose has the same problem, and this can also be solved like that):

alias takeout="/opt/homebrew/Cellar/php@8.0/8.0.13/bin/php ~/.composer/vendor/bin/takeout"
alias expose="/opt/homebrew/Cellar/php@8.0/8.0.13/bin/php ~/.composer/vendor/bin/expose"
mattstauffer commented 2 years ago

Sorry y'all, I've been pretty burned out the last few days. Looking at this again now.

mattstauffer commented 2 years ago

https://github.com/laravel-zero/laravel-zero/issues/367

Looks like this is a known issue. Let me dig into Box but I don't know anything about it so we're probably just dependent on them.

mattstauffer commented 2 years ago

@bakerkretzmar and I put in a PR to two of Laravel Zero's dependencies (PHP Scoper and Covers Validation, IIRC) to try to get PHP 8.1 support. Fingers crossed.

jsposato commented 2 years ago

any update? Will go back to PHP 7 for awhile if this is going to take some time. Appreciate you jumping on it @mattstauffer

mattstauffer commented 2 years ago

This is the PR I made to the dependency:

https://github.com/humbug/php-scoper/pull/543

It's still in draft form until the package author can take time to work with it:

nunomaduro commented 2 years ago

@mattstauffer You can now migrate this tool to Laravel Zero 9, and on the process, you will get this issue fixed. Of course, keep in mind, that just like Laravel 9, Laravel Zero 9 drops PHP 7.4 and PHP 7.3.

mattstauffer commented 2 years ago

Woooo thanks @nunomaduro!

bandgeekndb commented 2 years ago

@mattstauffer Now that the upstream issues have been fixed, what's left to do on this repo? This is my last PHP 8.1 blocker, so I'd love to help anyway I can!

mattstauffer commented 2 years ago

@bandgeekndb Thanks! Looks like we need to upgrade it to Laravel Zero 9. I'd welcome that PR!

bandgeekndb commented 2 years ago

274 was merged yesterday, which should close this once a new build is tagged (1.8.13 was built and tagged before my PR was merged).

I also realize I didn't include any docs updates in my PR, do you want to make a note about dropping PHP7 support? Maybe tag the new release as 2.0 and tell anyone who still needs PHP7 support to stay on the 1.* builds?

mrailton commented 2 years ago

Thanks for the v2.0.0 build Matt. I installed globally and am getting the attached errors (same as previous) Screenshot 2022-03-01 at 18 12 59 If i try to run any command within takeout like enable then it fails with Screenshot 2022-03-01 at 18 20 26

I also tried running the version from repo and same issue. I tried the same build using php 8.0 directly and that appears to work so I tried building from main branch locally on 8.1 and appears to run fine.

Not sure if maybe is a local issue for me or not tho. Also wondering if maybe there's something funky going on where it needs to be built against php 8.1 in order to work properly or something else weird.

bandgeekndb commented 2 years ago

@railto Thanks for bringing this up, I believe I know what happened. I only committed the composer.json, and not the .lock file along with it, so I don't think the right dependencies were in place for the 2.0.0 build. I've submitted #278 to fix this and then v2.0.1 should be working.

mattstauffer commented 2 years ago

Closed in #274 / #278.

priithansen commented 2 years ago

Seems it still might need a new build published also because still seeing same errors that resolve with local "composer i && php ./takeout app:build"

mattstauffer commented 2 years ago

@priithansen which version is that, 2.0.1 or 2.0.2? Thanks!

priithansen commented 2 years ago

Ah jes impatient me tried 2.0.1. Seems 2.0.2 fixes the iterator return value problem but there appears to be some new problem with plain "takeout" command workig but every other command results in "The provided cwd "" does not exist." CleanShot 2022-03-04 at 23 40 54 Yet again doing a local build resolves the problem 🤔

mattstauffer commented 2 years ago

Interesting. I can't reproduce the cwd issue on my machine, but my machine is the one that built it. I'll dig in to see if I can figure out what's going on in Process.php line 344 and what's calling that particular spot, if I can.

priithansen commented 2 years ago

It could always just be something funky with my setup although tried to delete global vendors folder and do composer global clearcache :) anyways Thanks for the fantastic package!