<?php

class ArithmeticError extends Error {}
class DivisionByZeroError extends ArithmeticError {}
class AssertionError extends Error {}
class CompileError extends Error {}
class ParseError extends CompileError {}
class TypeError extends Error {}
class ArgumentCountError extends TypeError {}
class ValueError extends Error {}
class UnhandledMatchError extends Error {}

class LogicException extends Exception {}
class BadFunctionCallException extends LogicException {}
class BadMethodCallException extends BadFunctionCallException {}
class DomainException extends LogicException {}
class InvalidArgumentException extends LogicException {}
class LengthException extends LogicException {}
class OutOfRangeException extends LogicException {}

class RuntimeException extends Exception {}
class OutOfBoundsException extends RuntimeException {}
class OverflowException extends RuntimeException {}
class RangeException extends RuntimeException {}
class UnderflowException extends RuntimeException {}
class UnexpectedValueException extends RuntimeException {}

class Random\RandomException extends Exception {}

// https://www.php.net/manual/en/class.arrayiterator.php
// TODO: make it work with T[] arrays when generic classes are available.
// For now, it only supports mixed[].
final class ArrayIterator {
    public function __construct($arr ::: mixed[]);

    public function count(): int;

    public function current(): mixed;

    public function key(): mixed;

    public function next(): void;

    public function valid(): bool;
}
