Call to EntityManager::clear in loop not detected
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
No source file or test is named. Start by reproducing the reported PHPStan error with the EntityManager::clear() call inside the foreach loop, then compare it with the version where clear() is outside the loop. Done means the valid assertion is no longer reported as always false while the relevant analysis behavior remains covered.
Written by the indexing model from the issue text.
Description
I'm currently in the process of upgrading phpstan an phpstan-doctrine to the current version (phpstan 1.11.6, phpstan-doctrine 1.4.4) and I'm encountering a new error.
We have a test like the following:
public function testCleanup(EntityManager $entityManager): void
{
if ([] !== $entityManager->getRepository(Favourite::class)->findAll()) {
self::markTestSkipped('Invalid setup');
}
foreach ([1,2,3] as $dummy) {
// setup ...
$entityManager->clear();
}
self::assertCount(4, $entityManager->getRepository(Favourite::class)->findAll());
// ...
}
This test reports Call to static method PHPUnit\Framework\Assert::assertCount() with 4 and array{} will always evaluate to false..
When adding a $entityManager->clear(); outside the loop, no error is reported.
- Dominant language
- PHP
- Stars
- 678
- Forks
- 122
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 3
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-doctrine
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
phpstan/phpstan-doctrine#785 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
phpstan/phpstan-doctrine#792 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
phpstan/phpstan-doctrine#788 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
phpstan/phpstan-doctrine#763 ·
All issues in phpstan/phpstan-doctrine
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100