Suggest assertTrue()/assertFalse() over assertSame(true|false, ...)

Open
#183 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

A pull request for this has already been merged.

  • #198 by @alies-dev — merged

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
testing

Research direction

Start with the plugin’s afterMethodCallAnalysis hook and the existing check for assertSame(null, ...), then inspect its helper and tests. Add coverage for literal true and false as the first argument to assertSame and assertNotSame, and confirm the plugin reports the suggested PHPUnit assertion; the issue estimates roughly 45 lines including tests.

Written by the indexing model from the issue text.

Description

enhancement good first issue

$this->assertSame(true, $isPaid) is clearer as $this->assertTrue($isPaid) and gives a better failure message.

phpstan-phpunit reports it (AssertSameBooleanExpectedRule).

Idea: same hook and helper as the assertSame(null, ...) check: in afterMethodCallAnalysis, detect a literal true/false first argument to assertSame/assertNotSame and emit a plugin issue. Roughly 45 lines with tests.

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from psalm/psalm-plugin-phpunit

All issues in psalm/psalm-plugin-phpunit

Similar issues

More Testing & QA issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.