Closed dshafik closed 16 hours ago
The refactored version is harder to read than the previous version! (For me)
In contrast, I like it and can follow it better. I think it helps keep a clean code base so +1!
Marking as draft since tests are failing.
@crynobone all tests are passing now, only one minor change to a single test (mocking laterOn
which is no longer called instead of later
)
During my latest Inside Laravel livestream I noticed some minor inefficiencies in the Dispatcher code. These most likely are just older code that never got updated.
This includes 3 changes:
isset($uses[InteractsWithQueue::class], $uses[Queueable::class])
instead of a two expensivein_array()
calls, this takes two O(n) operations to just O(1).call_user_func()
call with a dynamic method call, using($this->queueResolver)
to dererefence the property before calling the closure within.pushCommandToQueue()
implementation which previously checked if queue and/or delay were set and then callingpushOn()
orlaterOn()
when with named params we can easily just callpush()
andlater()
— the use ofqueue: $command->queue ?? null
rather than justqueue: $command->queue
is for readability. This one is the only one I'm concerned about, it's possible that an implementation of theQueue
interface/child of theQueue
abstract class has different behavior than just wrappingpush()
andlater()
— but as those must support thequeue
param I don't see any issue with it.