Skip to content

Conversation

@algirdasci
Copy link

What was changed

Changed QueueInterface $payload parameter from array to mixed.

Why?

All interface implementations uses mixed payload where providing serializable objects are possible. Using QueueInterface as type, triggers phpstan errors of incompatible types:

Example:

class CallbackService
{
    public function __construct(
        // flow is in-memory roadrunner driver (Spiral\RoadRunnerBridge\Queue\Queue)
        private readonly QueueInterface $flow,
    ) {
    }
    
    public function send(): void
    {
        // CallbackJob is DTO which can be serialized
        $job = new CallbackJob();
    
        // call below will trigger phpstan error:
        // phpstan: Parameter #2 $payload of method Spiral\Queue\QueueInterface::push() expects array, CallbackJob given.
        $this->flow->push(CallbackJob, $job);
    }
}

@roxblnfk
Copy link
Member

Expanding the parameter type in the interface is a breaking change for backward compatibility. We cannot accept this change in the current version.

However, we can consider declaring a broader type with annotations.

@algirdasci algirdasci closed this Sep 30, 2025
@algirdasci algirdasci deleted the fix/queue-interface-parameter-type branch September 30, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants