SpartnerNL / Laravel-Nova-Excel

🚀 Supercharged Excel exports for Laravel Nova Resources
https://docs.laravel-excel.com/nova/1.0/
MIT License
383 stars 74 forks source link

[BUG] MemoryCache class methods incompatible with Psr\SimpleCache\CacheInterface #154

Closed matthewjumpsoffbuildings closed 2 years ago

matthewjumpsoffbuildings commented 2 years ago

Prerequisites

Versions

Description

When attempting to install Laravel Nova Excel via Composer, I am getting the following error message:

Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed

  at vendor/maatwebsite/excel/src/Cache/MemoryCache.php:62
     58▕ 
     59▕     /**
     60▕      * {@inheritdoc}
     61▕      */
  ➜  62▕     public function get($key, $default = null)
     63▕     {
     64▕         if ($this->has($key)) {
     65▕             return $this->cache[$key];
     66▕         }

Steps to Reproduce

Attempt to install the package on the specified version of PHP

Expected behavior:

The package installs normally

Actual behavior:

The package doesnt install, instead throwing the error message shared above

Additional Information

If I manually edit the file in question (Maatwebsite\Excel\Cache\MemoryCache.php) and update the method signatures for almost all of the methods, to be compatible with the Psr\SimpleCache\CacheInterface , for example:

 public function setMultiple($values, $ttl = null)

Becomes:

 public function setMultiple($values, $ttl = null):bool

Then everything works fine and the generation of autoload files goes smoothly

StanBarrows commented 2 years ago

Probably linked to:

Temporary fix composer require psr/simple-cache:^2.0 maatwebsite/excel

patrickbrouwers commented 2 years ago

Indeed has to be installed like that, the docs of the main package already reflected this, the Excel Nova docs too now.