Skip to content

Commit 1219635

Browse files
[PHP8.4] die,exitの翻訳 (#180)
* dieの変更 * exitの変更 * "proper function"の訳を修正 * "従って"を他ページに合わせてひらがな表記に修正 * カタカナの訳を修正 * 訳を二文に分割 * 他の訳に合わせて"セマンティクス"を追加 * `EN-Revision`の更新 * xmlの構造を原文に正確に併せる微修正 * 重複した表記を削除 * Change suggestionを再適用 --------- Co-authored-by: 武田 憲太郎 <[email protected]>
1 parent dd63118 commit 1219635

File tree

2 files changed

+153
-100
lines changed

2 files changed

+153
-100
lines changed

reference/misc/functions/die.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 84b8fca68fc762fefe85acde180a38b2e77a28b9 Maintainer: hirokawa Status: ready -->
3+
<!-- EN-Revision: 2aaaf1967f2510471b694daf8e41a419fc98b751 Maintainer: hirokawa Status: ready -->
44
<!-- CREDITS: takagi -->
55
<refentry xml:id="function.die" xmlns="http://docbook.org/ns/docbook">
66
<refnamediv>
77
<refname>die</refname>
8-
<refpurpose><literal>exit</literal> と同等</refpurpose>
8+
<refpurpose><function>exit</function> &Alias;</refpurpose>
99
</refnamediv>
10-
10+
1111
<refsect1 role="description">
1212
&reftitle.description;
13-
<para>
14-
この言語構造は、<function>exit</function> と同等です。
15-
</para>
13+
<simpara>
14+
&info.function.alias;
15+
<function>exit</function>.
16+
</simpara>
1617
</refsect1>
17-
1818
</refentry>
19-
2019
<!-- Keep this comment at the end of the file
2120
Local variables:
2221
mode: sgml

reference/misc/functions/exit.xml

Lines changed: 146 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,154 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 86e6094e86b84a51d00ab217ac50ce8dde33d82a Maintainer: hirokawa Status: ready -->
3+
<!-- EN-Revision: 2aaaf1967f2510471b694daf8e41a419fc98b751 Maintainer: hirokawa Status: ready -->
44
<!-- CREDITS: takagi -->
55
<refentry xml:id="function.exit" xmlns="http://docbook.org/ns/docbook">
66
<refnamediv>
77
<refname>exit</refname>
8-
<refpurpose>メッセージを出力し、現在のスクリプトを終了する</refpurpose>
8+
<refpurpose>ステータスコードかメッセージを返して現在のスクリプトを終了する</refpurpose>
99
</refnamediv>
10-
10+
1111
<refsect1 role="description">
1212
&reftitle.description;
1313
<methodsynopsis>
14-
<type>void</type><methodname>exit</methodname>
15-
<methodparam choice="opt"><type>string</type><parameter>status</parameter></methodparam>
16-
</methodsynopsis>
17-
<methodsynopsis>
18-
<type>void</type><methodname>exit</methodname>
19-
<methodparam><type>int</type><parameter>status</parameter></methodparam>
14+
<type>never</type><methodname>exit</methodname>
15+
<methodparam choice="opt"><type class="union"><type>string</type><type>int</type></type><parameter>status</parameter><initializer>0</initializer></methodparam>
2016
</methodsynopsis>
21-
<para>
17+
<simpara>
2218
スクリプトの実行を終了します。
2319
<link linkend="function.register-shutdown-function">シャットダウン関数</link>
2420
や <link linkend="language.oop5.decon.destructor">オブジェクトのデストラクタ</link>
25-
は、<literal>exit</literal> がコールされた場合にも実行されます。
26-
</para>
27-
<para>
28-
<literal>exit</literal> は言語構造です。
29-
<parameter>status</parameter> を指定しない場合は括弧なしでコールできます。
30-
</para>
21+
は、<function>exit</function> がコールされた場合にも実行されます。
22+
ただし、&finally; ブロックは実行されません。
23+
</simpara>
24+
<simpara>
25+
終了コード <literal>0</literal> は、そのタスクでプログラムが成功したことを表します。
26+
他の値は、実行中に何らかのエラーが発生したことを表します。
27+
</simpara>
28+
<simpara>
29+
<function>exit</function> は特殊な関数です。
30+
パーサーに専用のトークンがあるため、文として使用して(つまり、括弧なしで)、
31+
デフォルトのステータスコードでスクリプトを終了させることができます。
32+
</simpara>
33+
<caution>
34+
<simpara>
35+
グローバルな <function>exit</function> を無効にしたり、
36+
名前空間つきの関数でシャドーイングすることはできません。
37+
</simpara>
38+
</caution>
3139
</refsect1>
3240

3341
<refsect1 role="parameters">
3442
&reftitle.parameters;
35-
<para>
36-
<variablelist>
37-
<varlistentry>
38-
<term><parameter>status</parameter></term>
39-
<listitem>
40-
<para>
41-
<parameter>status</parameter> が文字列の場合は、この関数は終了直前に
42-
<parameter>status</parameter> を表示します。
43-
</para>
44-
<para>
45-
<parameter>status</parameter> が <type>int</type> の場合は
46-
その値が終了ステータスとして使われ、表示はされません。終了ステータスは
47-
0 から 254 までの値でなければなりません。終了ステータス 255 は
48-
PHP に予約されており、使用してはいけません。ステータス 0 は、
49-
プログラムを正常終了させる際に使用します。
50-
</para>
51-
</listitem>
52-
</varlistentry>
53-
</variablelist>
54-
</para>
43+
<variablelist>
44+
<varlistentry>
45+
<term><parameter>status</parameter></term>
46+
<listitem>
47+
<simpara>
48+
<parameter>status</parameter> が文字列の場合は、
49+
この関数は終了直前に <parameter>status</parameter> を表示します。
50+
PHP によって返される終了コードは <literal>0</literal> です。
51+
</simpara>
52+
<para>
53+
<parameter>status</parameter> が <type>int</type> の場合は、
54+
この関数は終了直前に <parameter>status</parameter> を表示します。
55+
<note>
56+
<simpara>
57+
終了コードは <literal>0</literal> から <literal>254</literal> の範囲でなければならず、
58+
終了コード <literal>255</literal> は PHP によって予約されているため使用できません。
59+
</simpara>
60+
</note>
61+
</para>
62+
<warning>
63+
<simpara>
64+
PHP 8.4.0 より前のバージョンでは、 <function>exit</function> は PHP の標準的な
65+
<link linkend="language.types.type-juggling.function">型の相互変換のセマンティクス</link>に基づいておらず、
66+
また、<link linkend="language.types.declarations.strict"><literal>strict_types</literal></link> 宣言も適用されませんでした。
67+
</simpara>
68+
<simpara>
69+
また、<type>resource</type> や <type>array</type> を含む、<type>int</type> 型以外の値は
70+
<type>string</type> にキャストされていました。
71+
PHP 8.4.0 以降は、通常の型の相互変換が適用され、無効な値に対しては
72+
<exceptionname>TypeError</exceptionname> をスローします。
73+
</simpara>
74+
</warning>
75+
</listitem>
76+
</varlistentry>
77+
</variablelist>
5578
</refsect1>
5679

5780
<refsect1 role="returnvalues">
5881
&reftitle.returnvalues;
59-
<para>
60-
&return.void;
61-
</para>
82+
<simpara>
83+
この関数は PHP スクリプトを終了するため、値を返すことはありません。
84+
</simpara>
85+
</refsect1>
86+
87+
<refsect1 role="changelog">
88+
&reftitle.changelog;
89+
<informaltable>
90+
<tgroup cols="2">
91+
<thead>
92+
<row>
93+
<entry>&Version;</entry>
94+
<entry>&Description;</entry>
95+
</row>
96+
</thead>
97+
<tbody>
98+
<row>
99+
<entry>8.4.0</entry>
100+
<entry>
101+
<function>exit</function> は言語構造から正式な関数になったので、
102+
通常の
103+
<link linkend="language.types.type-juggling.function">型の相互変換</link>
104+
に従い、
105+
<link linkend="language.types.declarations.strict"><literal>strict_types</literal></link>
106+
宣言も適用されるようになりました。また、名前付き引数や
107+
<link linkend="functions.variable-functions">可変関数</link>
108+
によって呼び出すこともできるようになりました。
109+
</entry>
110+
</row>
111+
</tbody>
112+
</tgroup>
113+
</informaltable>
62114
</refsect1>
63115

64116
<refsect1 role="examples">
65117
&reftitle.examples;
66-
<para>
67-
<example>
68-
<title><literal>exit</literal> の例</title>
69-
<programlisting role="php">
118+
<example>
119+
<title><function>exit</function> の基本的な使用例</title>
120+
<programlisting role="php">
70121
<![CDATA[
71122
<?php
72123
73-
$filename = '/path/to/data-file';
74-
$file = fopen($filename, 'r')
75-
or exit("ファイル ($filename) をオープンできません");
124+
// exit program normally
125+
exit();
126+
exit(0);
127+
128+
// exit with an error code
129+
exit(1);
76130
77131
?>
78132
]]>
79-
</programlisting>
80-
</example>
81-
</para>
82-
<para>
83-
<example>
84-
<title><literal>exit</literal> でステータスを指定する例</title>
85-
<programlisting role="php">
133+
</programlisting>
134+
</example>
135+
<example>
136+
<title><function>exit</function> に<type>string</type>を渡す例</title>
137+
<programlisting role="php">
86138
<![CDATA[
87139
<?php
88140
89-
// 正常終了
90-
exit;
91-
exit();
92-
exit(0);
93-
94-
// エラーコードつきの終了
95-
exit(1);
96-
exit(0376); // 八進数
141+
$filename = '/path/to/data-file';
142+
$file = fopen($filename, 'r')
143+
or exit("unable to open file ($filename)");
97144
98145
?>
99146
]]>
100-
</programlisting>
101-
</example>
102-
</para>
103-
<para>
104-
<example>
105-
<title>シャットダウン関数やデストラクタが実行される例</title>
106-
<programlisting role="php">
147+
</programlisting>
148+
</example>
149+
<example>
150+
<title>シャットダウン関数やデストラクタが実行される例</title>
151+
<programlisting role="php">
107152
<![CDATA[
108153
<?php
109154
class Foo
@@ -126,41 +171,50 @@ exit();
126171
echo 'これは出力されません。';
127172
?>
128173
]]>
129-
</programlisting>
130-
&example.outputs;
131-
<screen>
132-
<![CDATA[
133-
Shutdown: shutdown()
134-
Destruct: Foo::__destruct()
135-
]]>
136-
</screen>
137-
</example>
138-
</para>
174+
</programlisting>
175+
&example.outputs;
176+
<screen>
177+
<![CDATA[
178+
Shutdown: shutdown()
179+
Destruct: Foo::__destruct()
180+
]]>
181+
</screen>
182+
</example>
183+
<example>
184+
<title>文としての <function>exit</function></title>
185+
<programlisting role="php">
186+
<![CDATA[
187+
<?php
188+
189+
// exit program normally with exit code 0
190+
exit;
191+
192+
?>
193+
]]>
194+
</programlisting>
195+
</example>
139196
</refsect1>
140197

141198
<refsect1 role="notes">
142199
&reftitle.notes;
143-
144-
&note.language-construct;
145-
146-
<note>
147-
<para>
148-
この言語構造は、<function>die</function> と等価です。
149-
</para>
150-
</note>
200+
<warning>
201+
<simpara>
202+
PHP 8.4.0 以降は、 <function>exit</function> は関数ではなく言語構造でした。
203+
したがって、 <link linkend="functions.variable-functions">可変関数</link> や <link linkend="functions.named-arguments">名前付き引数</link> を使って関数を呼び出すことはできませんでした。
204+
</simpara>
205+
</warning>
151206
</refsect1>
152207

153208
<refsect1 role="seealso">
154209
&reftitle.seealso;
155-
<para>
156-
<simplelist>
157-
<member><function>register_shutdown_function</function></member>
158-
</simplelist>
159-
</para>
210+
<simplelist>
211+
<member><function>register_shutdown_function</function></member>
212+
<member><link linkend="function.register-shutdown-function">シャットダウン関数</link></member>
213+
<member><link linkend="language.oop5.decon.destructor">オブジェクトのデストラクタ</link></member>
214+
</simplelist>
160215
</refsect1>
161216

162217
</refentry>
163-
164218
<!-- Keep this comment at the end of the file
165219
Local variables:
166220
mode: sgml

0 commit comments

Comments
 (0)