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

Detect risky PHPUnit test

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
php
領域
testing

調査の方向性

Start from the issue's try/catch example and review the repository's existing PHPUnit-related rules and tests. Define whether PHPStan should report tests that can finish successfully after the expected Throwable is caught without an explicit failure, then add coverage for the agreed behavior.

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

説明

Feature request

In the following scenario:

function test_exception_state(): void {
  $myService = new MyService();

  try {
    $myService->doSomethingWrong();

    // missing: $this->fail();
  } catch (MyException $exception) {
    $this->assertSame('Custom message', $exception->getMessage());
    $this->assertSame('Another property', $exception->smthNotTypicalOfException);
  }
}

Essentially, a case where we want to do an explicit try/catch because expectExceptionObject() doesn't cut it (want to catch a Throwable instead of test some state of the exception besides message/code), it is easy to forget a fail() statement and leading to a risky test.

Maybe it leading as a risky is fine... But maybe it's a kinda of issue that PHPStan could detect & report. Just an idea.

Did PHPStan help you today? Did it make you happy in any way?

Today it did not help, but I didn't run it either so cannot blame it :) I like PHPStan otherwise!

主要言語
PHP
スター
544
フォーク
58
平均マージ
2日 1時間
マージ済み PR(30日)
5

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

phpstan/phpstan-phpunit のほかの issue

phpstan/phpstan-phpunit の issue をすべて見る

似ている issue

PHP の issue をもっと見る

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

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