phpのErrorException が Exception じゃなくて RuntimeException を継承してたらしっくりきそうなんだけど、どうだろう?

定数 説明 発生時の行頭 種類
E_ERROR Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted. Fatal error: Runtime
E_WARNING Run-time warnings (non-fatal errors). Execution of the script is not halted. Warning: Runtime
E_PARSE Compile-time parse errors. Parse errors should only be generated by the parser. Parse error: Compiletime
E_NOTICE Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script. Notice: Runtime
E_CORE_ERROR Fatal errors that occur during PHP's initial startup. This is like an E_ERROR, except it is generated by the core of PHP. *1Fatal error: 不明
E_CORE_WARNING Warnings (non-fatal errors) that occur during PHP's initial startup. This is like an E_WARNING, except it is generated by the core of PHP. *2Warning: 不明
E_COMPILE_ERROR Fatal compile-time errors. This is like an E_ERROR, except it is generated by the Zend Scripting Engine. Fatal error: Compiletime
E_COMPILE_WARNING Compile-time warnings (non-fatal errors). This is like an E_WARNING, except it is generated by the Zend Scripting Engine. *3Warning: Compiletime
E_STRICT Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code. Strict Standards: 不明
E_RECOVERABLE_ERROR Catchable fatal error. It indicates that a probably dangerous error occured, but did not leave the Engine in an unstable state. If the error is not caught by a user defined handle (see also set_error_handler()), the application aborts as it was an E_ERROR. *4Fatal error: 不明
E_DEPRECATED Run-time notices. Enable this to receive warnings about code that will not work in future versions. Deprecated: Runtime

phpのエラー、実際に発生した時の行頭とエラー定数を対応させてみました。
どのエラーの時はどういう行頭になるか、一応ネットで検索して調べました。
さすがに、全種類のエラーを意図的に発生させるのはつらい。
未確認のところは予想です。


ついでに、英語のドキュメントの説明文から、エラーの種類を割り出してみました。

注意: PHP の内部関数の多くは エラー報告 を使っており、例外を使っているのは新しい オブジェクト指向 の拡張モジュールのみです。 しかし、ErrorException を使えば簡単にエラーを例外に変換することができます。

PHP: 例外(exceptions) - Manual

ErrorExceptionはExceptionを継承*5してるんですが、RuntimeExceptionを継承してる方がしっくりくるのになぁと思ったから、調べてみたわけですが、phpのエラーは全部がRuntimeのものじゃないみたいですね。
でも、よく発生するのはRuntimeなんですよね。
だから ErrorException extends RuntimeException だったら良いのになぁ。


ErrorExceptionを使う場合は、RuntimeExceptionのほかにErrorExceptionもRuntimeな例外な場合があるって事を覚えておけばいいのかな。

*1:未確認

*2:未確認

*3:未確認

*4:未確認

*5:ErrorException extends Exception