Signatur
interface Countable
Beschreibung
Standard bei allen Collection-Klassen.
Rückgabewert
Typ
void
Beispiele
Basis
<?php
class Cart implements Countable {
public function __construct(private array $items = []) {}
public function count(): int { return count($this->items); }
}
echo count(new Cart([1, 2, 3])); // 3