getArrayCopy()) as $key) { if ($this[$key] === $gameObject) { $this->offsetUnset($key); break; } } } public function findByKind(string $kind): array { $found = []; foreach ($this as $entity) { if ($entity->kind() === $kind) { $found[] = $entity; } } return $found; } /** Snapshot copy so entities added mid-iteration are not touched. */ public function copy(): array { $copy = []; foreach ($this as $entity) { $copy[] = $entity; } return $copy; } }