calling assertInstanceOf on a property set in TestCase::setUp() should result in RedundantCondition
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
Research direction
Start by reading the plugin's handling of PHPUnit assertions and the existing tests for Psalm's RedundantCondition diagnostics. The issue gives a proposed TestCase::setUp() example, but says the exact error and test case are uncertain; trace how property types flow from setUp() into test methods and determine the expected diagnostic. Done means a regression test confirms the intended behavior without introducing other errors.
Written by the indexing model from the issue text.
Description
- if
TestCase::$fooisT|null - and
TestCase::setUp()setsTestCase::$footoT - and nothing else modifies
TestCase::$foo - then
TestCase::assertInstanceOf(T::class, $this->foo)is redundant
not quite sure on the exact error/test case that should occur, but this is a vague mashup of what I'm thinking:
Scenario: setUp resolves types
Given I have the following code
"""
class MyTestCase extends TestCase
{
/** @var \DateTime|null */
private $date;
/** @return void */
public function setUp() {
$this->date = new \DateTime();
}
/** @return void */
public function testSomething() {
$this->assertInstanceOf(\DateTime::class, $this->date);
}
}
"""
When I run Psalm
Then I see these errors
| Type | Message |
| RedundantConditionGivenDocblockType | Found a redundant condition when evaluating docblock-defined type $this->date and trying to reconcile type 'DateTime' to DateTime |
And I see no other errors
- 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