}> */ public array $imports = []; public int $runs = 0; /** @param list $jobs */ public function __construct( private readonly int $importResult = 1, private readonly ?Throwable $importError = null, private array $jobs = [], private readonly ?Throwable $workerError = null, ) { } public function import(string $sourcePath, array $extensions): int { $this->imports[] = [$sourcePath, $extensions]; if ($this->importError !== null) { throw $this->importError; } return $this->importResult; } public function runWorkerOnce(callable $shouldStop): ?int { $this->runs++; if ($this->workerError !== null) { throw $this->workerError; } // The real worker consults the callback between items; mirror that contract. $shouldStop(); return array_shift($this->jobs); } }