Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

A shorter way to define a message

オープン
#344 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
php
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
PHP
スター
61
フォーク
31
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

yiisoft/queue のほかの issue

yiisoft/queue の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。