--TEST-- pg_copy_from with an iterable --EXTENSIONS-- pgsql --SKIPIF-- --FILE-- count; } public function rewind(): void { $this->count = 0; } public function current(): int { return $this->values[$this->count]; } public function key(): int { return $this->count; } public function valid(): bool { return $this->count < count($this->values); } }; try { pg_copy_from($db, $table_name, new stdClass()); } catch (\TypeError $e) { echo $e->getMessage() . PHP_EOL; } var_dump(pg_copy_from($db, $table_name, $iter)); $res = pg_query($db, "SELECT FROM {$table_name}"); var_dump(count(pg_fetch_all($res)) == 3); ?> --CLEAN-- --EXPECT-- pg_copy_from(): Argument #3 ($rows) must be of type Traversable|array, stdClass given bool(true) bool(true)