laravel-queue-rabbitmq: PHP Fatal error: Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null)

I used command:

composer update at laravel version 9.42

log:

`PHP Fatal error: Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null) in /home/gabriel/Projekty/subjects_and_grades/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php on line 200

Symfony\Component\ErrorHandler\Error\FatalError

Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null)

at vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php:200 196▕ * 197▕ * @param int $status 198▕ * @return int 199▕ */ ➜ 200▕ public function stop($status = 0): int 201▕ { 202▕ // Tell the server you are going to stop consuming. 203▕ // It will finish up the last message and not send you any more. 204▕ $this->channel->basic_cancel($this->consumerTag, false, true);

Whoops\Exception\ErrorException

Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null)

at vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php:200 196▕ * 197▕ * @param int $status 198▕ * @return int 199▕ */ ➜ 200▕ public function stop($status = 0): int 201▕ { 202▕ // Tell the server you are going to stop consuming. 203▕ // It will finish up the last message and not send you any more. 204▕ $this->channel->basic_cancel($this->consumerTag, false, true);

  +1 vendor frames 

2 [internal]:0 Whoops\Run::handleShutdown() Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255 `

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 12
  • Comments: 24

Commits related to this issue

Most upvoted comments

@devzorg thank you!

I will add little more details to your temporary solution to fix problem:

  1. Copy vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php class to custom place. In my example is: composer-overrides/vyuldashev/laravel-queue-rabbitmq/Consumer.php.

  2. Make signature and implementation compatible to parent in copied class:

    public function stop($status = 0, $options = null): int
    {
        $this->channel->basic_cancel($this->consumerTag, false, true);

        return parent::stop($status, $options);
    }
  1. Update autoload section at root composer.json: exclude package’s Consumer class from classmap. Next, add overriden class instead of them
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        },
        "exclude-from-classmap" : [
            "vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php"
        ],
        "files" : [
            "composer-overrides/vyuldashev/laravel-queue-rabbitmq/Consumer.php"
        ]
    },
  1. Update laravel/framework package to latest version and dump autoloader’s map: composer dump

This solution tested with php artisan queue:work command

@heylucasf, just run the composer require laravel/framework:9.41 console command.

Hi, new maintainers were recently added and we are getting up to speed with going through issues and getting the library compatible again!

Is the pull request going live soon ?

any update?

we have to use laravel 9.41 and cannot have the last laravel updated version because of this issue

doesn’t work with “laravel/framework”: “^9.19”,

Add to composer.json, the below line. It will downgrade the worker to be compatible with the package, then once they fix the issue, remove it.

"illuminate/queue": "9.41.0",

@vyuldashev it would be nice if you can review and merge one of the pull requests associated with this issue.

@heylucasf, just run the command and see

Worked, thanks.