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

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

Closed
Zdanc32 opened this issue Nov 29, 2022 · 24 comments · Fixed by #502
Assignees

Comments

@Zdanc32
Copy link

Zdanc32 commented Nov 29, 2022

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
`

@Zdanc32
Copy link
Author

Zdanc32 commented Nov 29, 2022

At version 9.39.0 still working

@joskfg
Copy link

joskfg commented Nov 29, 2022

This change produce the error laravel/framework#45120

@Zdanc32
Copy link
Author

Zdanc32 commented Nov 29, 2022

ok, I will set version of laravel 9.39 and I will wait when lib use new :P thanks anyway

Only what u need to do is add options to function stop() in Consumer class

/**
 * Stop listening and bail out of the script.
 *
 * @param  int
 * @param  WorkerOptions|null  $options
 * @return int
 */
public function stop($status = 0, $options = null): int
{
    // Tell the server you are going to stop consuming.
    // It will finish up the last message and not send you any more.
    $this->channel->basic_cancel($this->consumerTag, false, true);

    return parent::stop($status, $options);
}

@bojcheski
Copy link

ok, I will set version of laravel 9.39 and I will wait when lib use new :P thanks anyway

Only what u need to do is add options to function stop() in Consumer class

/**
 * Stop listening and bail out of the script.
 *
 * @param  int
 * @param  WorkerOptions|null  $options
 * @return int
 */
public function stop($status = 0, $options = null): int
{
    // Tell the server you are going to stop consuming.
    // It will finish up the last message and not send you any more.
    $this->channel->basic_cancel($this->consumerTag, false, true);

    return parent::stop($status, $options);
}

laravel 9.41.0 also works

@sturtond
Copy link

sturtond commented Dec 2, 2022

Is the pull request going live soon ?

@andrey-helldar
Copy link

Me too. Laravel 9.41.0 works, but 9.41.0-2 doesn't work.

@bojcheski
Copy link

Is the pull request going live soon ?

just stick to laravel <= 9.41.0 until the pull request is merged. or if you really need laravel > 9.41 simply force vyuldashev/laravel-queue-rabbitmq not to be updated in your composer.json and adjust the code as it is in this pull request until everything is merged

@coloralp
Copy link

coloralp commented Dec 6, 2022

doesn't work with "laravel/framework": "^9.19",

@heylucasf
Copy link

How can i create a project with v9.41? I am trying to install but when i check the version it keeps "v9.43"

@andrey-helldar
Copy link

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

@heylucasf
Copy link

In laravel/laravel project? (I am beginner)

@andrey-helldar
Copy link

@heylucasf, just run the command and see

@heylucasf
Copy link

@heylucasf, just run the command and see

Worked, thanks.

shuqingzai added a commit to shuqingzai/laravel-queue-rabbitmq that referenced this issue Dec 9, 2022
shuqingzai added a commit to shuqingzai/laravel-queue-rabbitmq that referenced this issue Dec 9, 2022
shuqingzai added a commit to shuqingzai/laravel-queue-rabbitmq that referenced this issue Dec 9, 2022
shuqingzai added a commit to shuqingzai/laravel-queue-rabbitmq that referenced this issue Dec 10, 2022
@amarmain
Copy link

any update?

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

@devzorg
Copy link

devzorg commented Dec 19, 2022

guys just make an override file and add it to compose.json at section autoload, it won't block u to update Lara
"autoload": { "files": [ "overrides/Consumer.php" ],

@amarmain
Copy link

@devzorg thanks for the tip!

I've just test it and unlock laravel version updates in my composer

@gbespyatykh
Copy link

@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

@geekyHomz
Copy link

geekyHomz commented Dec 28, 2022

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",

@AliBayat
Copy link

AliBayat commented Jan 1, 2023

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

@iamfarhad
Copy link

you can use my laravel rabbitmq package

https://github.com/iamfarhad/LaravelRabbitMQ

jeromegamez added a commit to jeromegamez/vyuldashev-laravel-queue-rabbitmq that referenced this issue Jan 3, 2023
@zerossB
Copy link

zerossB commented Jan 3, 2023

Any solution for this?

I thought upgrading to version 13 of the package would work, but the same error happens in the same place.

 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);

      +26 vendor frames
  27  artisan:37
      App\Console\Kernel::handle("class Symfony\Component\Console\Input\ArgvInput { protected $definition = class Symfony\Component\Console\Input\InputDefinition { private array $arguments = [...]; private int $requiredCount = 0; private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL; private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL; private array $options = [...]; private array $negations = [...]; private array $shortcuts = [...] }; protected $stream = NULL; protected $options = []; protected $arguments = []; protected $interactive = TRUE; private array $tokens = [0 => 'package:discover', 1 => '--ansi']; private array $parsed = *uninitialized* }", "class Symfony\Component\Console\Output\ConsoleOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private bool $decorated = TRUE; private array $styles = [...]; private Symfony\Component\Console\Formatter\OutputFormatterStyleStack $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}stream = resource(2) of type (stream); private Symfony\Component\Console\Output\OutputInterface $stderr = class Symfony\Component\Console\Output\StreamOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter...")

  28  artisan:0
      {main}()

   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

shuqingzai added a commit to shuqingzai/laravel-queue-rabbitmq that referenced this issue Jan 4, 2023
@M-Porter
Copy link
Collaborator

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

@samlay
Copy link

samlay commented Jan 25, 2023

@M-Porter any ETA on merging? No rush, just so I know whether to wait or try out some of the suggested workarounds instead.

@M-Porter
Copy link
Collaborator

hey @samlay, hopefully by the end of the week. But I'm also moving on Saturday which means my free time it taken up by packing so please don't hold me to that 😅

jeromegamez added a commit to jeromegamez/vyuldashev-laravel-queue-rabbitmq that referenced this issue Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet