-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-phpunit
#591Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.2.4 |
| PHPUnit version | 11.5.42 |
The rule propose invalid code.
Minimal PHP Code Causing Issue
This rule suggest the following change:
- $this->assertSame(10, iterator_count($executedProcesses));
+ $this->assertCount(10, $executedProcesses);Expected Behaviour
Looking at the API, it looks fine. However, PHPUnit implements ::assertCount() as follows:
final public static function assertCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
{
if ($haystack instanceof Generator) {
throw GeneratorNotSupportedException::fromParameterName('$haystack');
}
self::assertThat(
$haystack,
new Count($expectedCount),
$message,
);
}So when $executedProcesses is a Generator, this rule ends up creating invalid code.