Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 30, 2022
1 parent 1d8b2eb commit a07dc81
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/PHPStan/Analyser/data/for-loop-i-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,41 @@ public function doLOrem() {
}

}

class Capacity
{

function __construct(public mixed $current, public int $count) {}

}
interface Foo2 {
function equals(self $other): bool;
}

class HelloWorld
{
/**
* @param Foo2[] $startTimes
* @return mixed[]
*/
public static function groupCapacities(array $startTimes): array
{
if ($startTimes === []) {
return [];
}
sort($startTimes);

$capacities = [];
$current = $startTimes[0];
$count = 0;
foreach ($startTimes as $startTime) {
if (!$startTime->equals($current)) {
$count = 0;
}
$count++;
}
assertType('int<1, max>', $count);

return $capacities;
}
}

0 comments on commit a07dc81

Please sign in to comment.