diff --git a/language/control-structures/finally.xml b/language/control-structures/finally.xml index c87bfa1732..75a7f85f5d 100644 --- a/language/control-structures/finally.xml +++ b/language/control-structures/finally.xml @@ -1,6 +1,6 @@ - + finally @@ -29,7 +29,7 @@ function inverse($x) { try { echo inverse(5) . "\n"; } catch (\DivisionByZeroError $e) { - echo 'Caught error: ', $e->getMessage(), "\n"; + echo 'Caught error: ', $e->getMessage(), "\n"; } finally { echo "First finally.\n"; } @@ -37,7 +37,7 @@ try { try { echo inverse(0) . "\n"; } catch (\DivisionByZeroError $e) { - echo 'Caught error: ', $e->getMessage(), "\n"; + echo 'Caught error: ', $e->getMessage(), "\n"; } finally { echo "Second finally.\n"; } @@ -248,7 +248,7 @@ function generate() try { yield 1; yield 2; - } catch(\Exception $e) { + } catch (\Exception $e) { echo 'catch'; } finally { echo "finally\n"; @@ -260,7 +260,7 @@ try { echo $i, "\n"; throw new Exception(); } -} catch(Exception $e) { +} catch (Exception $e) { echo 'outer catch'; } ]]> @@ -294,7 +294,7 @@ function generate() try { yield 1; yield 2; - } catch(\Exception $e) { + } catch (\Exception $e) { echo 'catch'; } finally { echo "finally\n"; @@ -307,7 +307,7 @@ try { echo $i, "\n"; throw new Exception(); } -} catch(Exception $e) { +} catch (Exception $e) { echo 'outer catch'; } ]]> @@ -407,7 +407,7 @@ quit &finally; ブロックの中で exit を呼び出すと、 - その外側にある他の &finally; ブロックはすべてスキップされます。 + その外側にある &finally; ブロックはすべてスキップされます。 <function>exit</function> を呼び出して外側の &finally; ブロックをスキップする @@ -450,7 +450,7 @@ function generate() try { yield 1; yield 2; - } catch(\Exception $e) { + } catch (\Exception $e) { echo 'catch'; } finally { echo "inner finally\n"; diff --git a/language/control-structures/match.xml b/language/control-structures/match.xml index 4c13aae7de..2c862c54ad 100644 --- a/language/control-structures/match.xml +++ b/language/control-structures/match.xml @@ -1,6 +1,6 @@ - + match @@ -208,7 +208,7 @@ try { 1, 2 => foo(), 3, 4 => bar(), }; -} catch (\UnhandledMatchError $e) { +} catch (UnhandledMatchError $e) { var_dump($e); } ]]> diff --git a/language/control-structures/throw.xml b/language/control-structures/throw.xml index 391ecd87cc..e03f381461 100644 --- a/language/control-structures/throw.xml +++ b/language/control-structures/throw.xml @@ -1,17 +1,17 @@ - + throw &throw; キーワードは式であり、式を書ける場所ならどこでも使えます。 引数として Throwable - のインスタンスを受け取ります。 + オブジェクトを受け取ります。 - PHP 8.0 より前のバージョンでは、&throw; キーワードは式ではなく文でした。 + PHP 8.0.0 より前のバージョンでは、&throw; キーワードは式ではなく文でした。 diff --git a/language/control-structures/try-catch.xml b/language/control-structures/try-catch.xml index 03f624702b..4da62fa15c 100644 --- a/language/control-structures/try-catch.xml +++ b/language/control-structures/try-catch.xml @@ -1,8 +1,8 @@ - + - Try...Catch + try...catch try @@ -180,9 +180,9 @@ class B extends Exception {} try { throw new A; -} catch(A $e) { +} catch (A $e) { throw new B; -} catch(B) { +} catch (B) { echo 'Hello'; } diff --git a/language/error-handling.xml b/language/error-handling.xml index 9bfcef355b..859d318f79 100644 --- a/language/error-handling.xml +++ b/language/error-handling.xml @@ -1,6 +1,6 @@ - + エラー処理 @@ -8,7 +8,7 @@ エラーは、アプリケーションの開発やライフサイクルの中でごく普通に起こるものです。 - そのため PHP には、エラーを通知したり、エラーに対処したりする方法が複数用意されています。 + そのため PHP には、エラーを報告したり、エラーに対処したりする方法が複数用意されています。 PHP がエラーを報告する仕組みには、主に次のふたつがあります。 @@ -81,7 +81,7 @@ - <literal>グローバルな例外ハンドラ</literal> + グローバルな例外ハンドラ set_exception_handler を使うと、 キャッチされないあらゆる Throwable @@ -97,8 +97,6 @@ ユーザー定義の例外は、組み込みの Exception クラスを拡張して定義できます。 - 子クラスの中でアクセスできるメソッドやプロパティについては、 - 派生元である Exception クラスのページを参照ください。 組み込みの Exception クラスを拡張したクラスで @@ -222,7 +220,7 @@ A custom function for this type of exception さまざまな状況を知らせるために使われます。 必要に応じて、画面に表示したりログに記録したりできます。 デフォルトでは、PHP はすべての診断エラーを報告します。 - (PHP 8.0 より前のバージョンでは、E_NOTICE と + (PHP 8.0.0 より前のバージョンでは、E_NOTICE と E_DEPRECATED の診断エラーはデフォルトでは報告されませんでした) @@ -243,7 +241,7 @@ A custom function for this type of exception 開発環境では常に、 error_reporting を E_ALL にしておくべきです。 - PHP が発する報告をすべて確認して対応する必要があるからです。 + PHP が発する報告にすべて気づいて対応できるようにするためです。 一方、運用環境では、もう少しレベルを下げて E_ALL & ~E_NOTICE & ~E_DEPRECATED にすることもできますが、 多くの場合は E_ALL のままでも適切です。 @@ -301,8 +299,8 @@ A custom function for this type of exception などの一部の診断エラーは、この方法では処理できません (完全な一覧は set_error_handler を参照ください)。 それ以外の診断エラーは、さまざまな方法で処理できます。 - たとえば、ユーザーにはカスタムエラーページを表示しつつ、 - メールの送信など、ログよりも直接的な方法で報告するといった使い方ができます。 + たとえば、独自のハンドラで、ユーザーにはエラーページを表示しつつ、 + メールの送信など、ログよりも直接的な方法でエラーを報告できます。 @@ -317,7 +315,7 @@ A custom function for this type of exception - + Error Error @@ -9,10 +9,12 @@
&reftitle.intro; - + Error - は、PHP のすべての内部エラーの基底クラスです。 - + は、プログラミング上の誤りを示すエラーの基底クラスです。 + こうしたエラーは一般に、通常の動作中に処理するのではなく、 + プログラムを修正して対処する必要があります。 +
diff --git a/language/predefined/exception.xml b/language/predefined/exception.xml index 97edbdbb90..f8c27a4e03 100644 --- a/language/predefined/exception.xml +++ b/language/predefined/exception.xml @@ -1,6 +1,6 @@ - + Exception @@ -10,10 +10,10 @@
&reftitle.intro; - + Exception は、 - すべてのユーザー例外の基底クラスです。 - + 通常の動作中に処理できる例外の基底クラスです。 +