ソースコード
<?php
$lines = array();
foreach (preg_grep('/Exception\z/i', get_declared_classes()) as $class) {
$classes = array();
do {
$classes[] = $class;
} while ($class = get_parent_class($class));
$lines[] = implode(' -> ', array_reverse($classes));
}
sort($lines);
echo implode(PHP_EOL, $lines);
実行結果の例
Exception
Exception -> DOMException
Exception -> ErrorException
Exception -> LogicException
Exception -> LogicException -> BadFunctionCallException
Exception -> LogicException -> BadFunctionCallException -> BadMethodCallException
Exception -> LogicException -> DomainException
Exception -> LogicException -> InvalidArgumentException
Exception -> LogicException -> LengthException
Exception -> LogicException -> OutOfRangeException
Exception -> PharException
Exception -> ReflectionException
Exception -> RuntimeException
Exception -> RuntimeException -> OutOfBoundsException
Exception -> RuntimeException -> OverflowException
Exception -> RuntimeException -> PDOException
Exception -> RuntimeException -> RangeException
Exception -> RuntimeException -> UnderflowException
Exception -> RuntimeException -> UnexpectedValueException
Exception -> RuntimeException -> mysqli_sql_exception
PHP言語自体の開発者に言いたい文句
- なんで IOException って存在しないの
- IOException が無いなら Exception とすべきところをなんで RuntimeException を投げる の
- 何で mysqli_sql_exception だけスネークケースなの
- 何で固有例外クラスのうち PDOException と mysqli_sql_exception だけが RuntimeException を継承してるの
個人的にこうあってほしい
Exception
Exception -> DatabaseException
Exception -> DatabaseException -> MysqliExeption
Exception -> DatabaseException -> PDOException
Exception -> DOMException
Exception -> ErrorException
Exception -> IOException
Exception -> LogicException
Exception -> LogicException -> BadFunctionCallException
Exception -> LogicException -> BadFunctionCallException -> BadMethodCallException
Exception -> LogicException -> DomainException
Exception -> LogicException -> InvalidArgumentException
Exception -> LogicException -> LengthException
Exception -> LogicException -> OutOfRangeException
Exception -> PharException
Exception -> ReflectionException
Exception -> RuntimeException
Exception -> RuntimeException -> OutOfBoundsException
Exception -> RuntimeException -> OverflowException
Exception -> RuntimeException -> RangeException
Exception -> RuntimeException -> UnderflowException
Exception -> RuntimeException -> UnexpectedValueException