laravel / lumen-framework

The Laravel Lumen Framework.
https://lumen.laravel.com
MIT License
1.48k stars 419 forks source link

Fatal error: Trait 'Illuminate\Foundation\Bus\Dispatchable' not found in .../vendor/illuminate/queue/CallQueuedClosure.php on line 14 #1136

Closed gihan9a closed 3 years ago

gihan9a commented 3 years ago
$ php artisan list -V
Laravel Framework Lumen (8.2.1) (Laravel Components ^8.0)

Description:

When initializing vimeo/psalm package it complains that Illuminate\Foundation\Bus\Dispatchable Trait is missing. Hence it aborts.

This error has reported in the following places. https://github.com/Maatwebsite/Laravel-Excel/issues/2347 https://github.com/Maatwebsite/Laravel-Excel/issues/2221 https://github.com/spatie/laravel-webhook-server/issues/3

As someone has suggested, jobs can be dispatched without Dispatchable in Lumen. Errors vanish after removing the following lines from https://github.com/illuminate/queue/blob/master/CallQueuedClosure.php#L1-L16. Since I don't know the internals I'm reporting this as an issue instead of a PR

--- a/CallQueuedClosure.php
+++ b/CallQueuedClosure.php
@@ -8,12 +8,11 @@ use Illuminate\Bus\Batchable;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Container\Container;
 use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
 use ReflectionFunction;

 class CallQueuedClosure implements ShouldQueue
 {
-    use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+    use Batchable, InteractsWithQueue, Queueable, SerializesModels;

     /**
      * The serializable Closure instance.

Steps To Reproduce:

  1. composer create-project --prefer-dist laravel/lumen blog
  2. cd blog
  3. composer require --dev vimeo/psalm
  4. ./vendor/bin/psalm --init
driesvints commented 3 years ago

We usually don't account for tools like psalm. If you think something is broken here feel free to PR something. Thanks.

gihan9a commented 3 years ago

Thanks for the quick reply.

I doubt it has lead to break lumen apps. That's why the listed issues can be found on GitHub. I found this in my first ever Laravel/Lumen project. I'll try to open PR.