monospice / laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.
MIT License
101 stars 48 forks source link

New Relic Reporting : Monospice\LaravelRedisSentinel\Horizon\HorizonServiceBindings::getIterator() should either be compatible with IteratorAggregate::getIterator() #41

Open TheFrankman opened 2 years ago

TheFrankman commented 2 years ago

Hello there,

Since upgrading to PHP8.1 New Relic is alive with the below error.

I can't actually see these logs in Laravel.log or the Horizon.log - I also can't confirm that it's even real since New Relic has been unreliable since 8.1 but I'm wondering if anyone else is experiencing this issue at all ?

I am on "monospice/laravel-redis-sentinel-drivers": "^2.7" (2.x-dev) perhaps i'm just being stupid and i'm on the wrong version of the driver.

Any assistance / thoughts would be great.

Return type of Monospice\LaravelRedisSentinel\Horizon\HorizonServiceBindings::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
                in Composer\Autoload\includeFile called at /var/www/hidden/vendor/composer/ClassLoader.php (428)
                                                  /in Composer\Autoload\ClassLoader::loadClass called at ? (?)
              in is_a called at /var/www/hidden/vendor/laravel/framework/src/Illuminate/Log/LogManager.php (371)
…:createMonologDriver called at /var/www/hidden/vendor/laravel/framework/src/Illuminate/Log/LogManager.php (210)
…\LogManager::resolve called at /var/www/hidden/vendor/laravel/framework/src/Illuminate/Log/LogManager.php (125)
…\Log\LogManager::get called at /var/www/hidden/vendor/laravel/framework/src/Illuminate/Log/LogManager.php (112)
…g\LogManager::driver called at /var/www/hidden/vendor/laravel/framework/src/Illuminate/Log/LogManager.php (101)
…lled at /var/www/hidden/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php (101)
…lled at /var/www/hidden/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php (72)
TheFrankman commented 2 years ago

By the way, i have fixed this in my fork as the error suggests : adding #[\ReturnTypeWillChange] to HorizonServiceBindings::getIterator() like so :

/**
     * Get an iterator for the service bindings so we can iterate over an
     * instance of this class.
     *
     * @return ArrayIterator
     */
    #[\ReturnTypeWillChange]
    public function getIterator()
    {
        return new ArrayIterator($this->serviceBindings);
    }