Suggest assertNull() over assertSame(null, ...)
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #198 by @alies-dev — merged
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
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.
Written by the indexing model from the issue text.
Description
$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.
- Dominant language
- Gherkin
- Stars
- 79
- Forks
- 38
- Avg merge
- 6h 52m
- Merged PRs (30d)
- 28
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from psalm/psalm-plugin-phpunit
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
psalm/psalm-plugin-phpunit#222 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
psalm/psalm-plugin-phpunit#220 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
psalm/psalm-plugin-phpunit#219 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
psalm/psalm-plugin-phpunit#216 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 57/100
psalm/psalm-plugin-phpunit#223 ·
Maintainers usually reply within 1 day
All issues in psalm/psalm-plugin-phpunit
Similar issues
-
area: build-and-ci S3: minor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manaflow-ai/cmux#39902 ·
Maintainers usually reply within 1 day
-
ai core enhancement good first issue testing
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug drawing-tools
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
cofade/open-garden-planner#827 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Unit tests use deprecated constant (part 2)Possibly taken @servo-highfive claimed this today. OpenE-less-complex
Difficulty 1/5 Under an hour Newbie friendliness 84/100
servo/servo#49766 · 1 comment ·
Maintainers usually reply within 1 day