Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Reduce the loop fixpoint regression fixture to its essential shape
Co-Authored-By: Claude Code
  • Loading branch information
janedbal committed Sep 2, 2026
commit 2f64ac522877c079db184abf8de4d954433697db
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,32 @@

namespace LoopFixpointConditionalExpressions;

use LogicException;
use function PHPStan\Testing\assertType;

final class Item
{

public function assign(): void
{
}

}

abstract class Foo
class Foo
{

/** @return list<Item> */
abstract public function getItems(): array;

public function run(int $quantityToAllocate, int $unitsThatFit): void
/** @param list<Item> $items */
public function run(array $items): void
{
$items = $this->getItems();
if ($quantityToAllocate <= 0) {
return;
}
if ($unitsThatFit <= 0) {
return;
}

do {
$unitsAdded = min($unitsThatFit, $quantityToAllocate);
foreach ([1, 2] as $_) {
$toCurrent = 0;
if ($items !== []) {
$unitsAdded = min($unitsAdded, count($items));
$toCurrent = $unitsAdded;
$toCurrent = count($items);
}

while ($toCurrent > 0) {
assertType('list<LoopFixpointConditionalExpressions\Item>', $items);
$item = array_shift($items);
assertType('LoopFixpointConditionalExpressions\Item|null', $item);
if ($item === null) {
throw new LogicException();
}
$item->assign();
$toCurrent--;
}

$quantityToAllocate -= $unitsAdded;
} while ($quantityToAllocate > 0);
}
}

}
Loading