Suggest assertNull() over assertSame(null, ...)

クローズ
#181 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #198 @alies-dev による — マージ済み

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
php
領域
testing

調査の方向性

Start with the plugin’s afterMethodCallAnalysis hook and the existing test patterns for plugin issues; the issue gives no file paths. Check how the plugin reports and tests diagnostics, then add coverage for assertSame(null, ...) and assertNotSame(null, ...) with the suggested assertions. Done means the diagnostics recommend assertNull() and assertNotNull() respectively; a merged pull request already addresses this issue.

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

説明

enhancement good first issue

$this->assertSame(null, $value) works but reads worse and gives a less specific failure message than $this->assertNull($value).

phpstan-phpunit reports it (AssertSameNullExpectedRule).

Idea: in afterMethodCallAnalysis, when assertSame/assertNotSame is called with a literal null as the first argument, emit a plugin issue suggesting assertNull()/assertNotNull(). This and the similar assertSame(true|false, ...) and assertSame(n, count(...)) checks can share one helper. Roughly 40 lines with tests. Plugin issues can be suppressed per project by anyone who prefers the current style.

Idea borrowed from phpstan/phpstan-phpunit.

主要言語
Gherkin
スター
79
フォーク
38
平均マージ
3時間 54分
マージ済み PR(30日)
68

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

psalm/psalm-plugin-phpunit のほかの issue

psalm/psalm-plugin-phpunit の issue をすべて見る

似ている issue

Testing & QA の issue をもっと見る

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

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