Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

A shorter way to define a message

Abierto
#344 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
php
Área
backend

Línea de trabajo

Start with the Quick Start message in README.md and messages-and-handlers.md to understand the existing manual message contract. The issue proposes an attribute or trait that derives message type and payload from public properties while keeping manual implementations available, but leaves the API and design open. Done means the package has a considered answer on whether to support this common case and, if pursued, a defined approach that preserves manual payload contracts.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Proposed new feature or change

The Quick Start message in README.md is 33 lines for two string properties. Message already covers getMeta()/withMeta(), so what is left per message class is getType(), getPayload() and a fromPayload() with hand-written validation:

public static function fromPayload(string $type, bool|int|float|string|array|null $payload): static
{
    if ($type !== self::TYPE) {
        throw new \InvalidArgumentException("Expected type \"" . self::TYPE . "\", got \"$type\".");
    }
    if (!is_array($payload)
        || !is_string($payload['url'] ?? null)
        || !is_string($payload['destinationPath'] ?? null)
    ) {
        throw new \InvalidArgumentException('Invalid data for ' . self::class . '.');
    }
    return new self($payload['url'], $payload['destinationPath']);
}

That is the same three checks in every message class in an application, and it is the first thing a newcomer meets in the README. Symfony Messenger and Laravel both take a plain object here.

The separation of payload from handler is well argued in messages-and-handlers.md and should stay — the request is for a short path for the common case, not a replacement. Something like an attribute or a trait that derives the type and the payload from the public properties:

#[AsMessage('download-file')]
final class DownloadFileMessage extends Message
{
    public function __construct(
        public readonly string $url,
        public readonly string $destinationPath,
    ) {}
}

with the manual implementation still available for messages that are a cross-application contract and need their payload shape pinned by hand.

Is this something you would consider in the package, or is it meant to stay application-side?

Lenguaje dominante
PHP
Estrellas
61
Forks
31
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de yiisoft/queue

Todos los issues de yiisoft/queue

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.