false-positive: Call to static method PHPUnit\Framework\Assert::assertCount() with int<0, max> and array will always evaluate to true
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- php
- Domain
- testing-qa
Research direction
Start by reproducing the reported assertCount call with the supplied PHPDoc types using phpstan/phpstan 2.2.14 and phpstan/phpstan-phpunit 2.0.18. Trace the PHPUnit assertCount rule or entry point that reports the diagnostic, then add or update a regression test so this valid call is no longer reported as always true.
Written by the indexing model from the issue text.
Description
With the method below phpstan since lately reports the false-positive "Call to static method PHPUnit\Framework\Assert::assertCount() with int<0, max> and array will always evaluate to true."
/**
* @param array<int|string> $expectedKeys
* @param array<mixed> $actual
*/
public static function assertArrayHasSameKeys(array $expectedKeys, array $actual): void {
\PHPUnit\Framework\Assert::assertCount(count($expectedKeys), $actual);
// ...
}
Used versions:
phpstan/phpstan 2.2.14
phpstan/phpstan-phpunit 2.0.18
- Dominant language
- PHP
- Stars
- 544
- Forks
- 58
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 5
Contributor guide
No contributing guide indexed for this repository
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 phpstan/phpstan-phpunit
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#321 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#309 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
phpstan/phpstan-phpunit#299 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
phpstan/phpstan-phpunit#292 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
phpstan/phpstan-phpunit#291 ·
All issues in phpstan/phpstan-phpunit
Similar issues
-
a11y admissions.uiowa.edu needs grooming SiteImprove best practice
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Save States Menu Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pluginsGLPI/datainjection#673 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
octobercms/october#6130 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
getgrav/grav-plugin-form#656 ·