hirokawa Sat Mar 10 21:56:46 2001 EDT
Modified files:
/phpdoc/ja/functions gmp.xml misc.xml mysql.xml pcre.xml posix.xml
recode.xml strings.xml yaz.xml
/phpdoc/ja/language oop.xml
/phpdoc/ja/pear pear.xml standards.xml
Log:
update translation, fixed typos.
Index: phpdoc/ja/functions/gmp.xml
diff -u phpdoc/ja/functions/gmp.xml:1.4 phpdoc/ja/functions/gmp.xml:1.5
--- phpdoc/ja/functions/gmp.xml:1.4 Thu Mar 1 07:24:45 2001
+++ phpdoc/ja/functions/gmp.xml Sat Mar 10 21:56:43 2001
@@ -367,7 +367,7 @@
<title>説明</title>
<funcsynopsis>
<funcprototype>
- <funcdef>resource <function>gmp_divexact</function></funcdef>
+ <funcdef>resource <function>gmp_div</function></funcdef>
<paramdef>resource <parameter>a</parameter></paramdef>
<paramdef>resource <parameter>b</parameter></paramdef>
</funcprototype>
Index: phpdoc/ja/functions/misc.xml
diff -u phpdoc/ja/functions/misc.xml:1.15 phpdoc/ja/functions/misc.xml:1.16
--- phpdoc/ja/functions/misc.xml:1.15 Thu Jan 4 22:29:04 2001
+++ phpdoc/ja/functions/misc.xml Sat Mar 10 21:56:43 2001
@@ -76,6 +76,52 @@
</refsect1>
</refentry>
+ <refentry id="function.constant">
+ <refnamediv>
+ <refname>constant</refname>
+ <refpurpose>定数の値を返す</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>説明</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>mixed <function>constant</function></funcdef>
+ <paramdef>string <parameter>name</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <simpara>
+ <function>constant</function> は、<parameter>name</parameter>で指
+ 定した定数の値を返します。
+ </simpara>
+ <simpara>
+ <function>constant</function> はある定数の値を取得する必要がある
+
+が、その名前が不明な場合に有用です。これは、定数が変数に保存され
+ ているか、関数により返されるかの場合です。
+ </simpara>
+ <para>
+ <example>
+ <title><function>constant</function> の例</title>
+ <programlisting role="php">
+<php
+
+define ("MAXSIZE", 100);
+
+echo MAXSIZE;
+echo constant("MAXSIZE"); // 前の行と動作は同じ
+
+?>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ <function>define</function>,
+ <function>defined</function>,
+ <function>constant</function> および <link
+ linkend="language.constants">定数</link> の節を参照下さい。
+ </para>
+ </refsect1>
+ </refentry>
+
<refentry id="function.define">
<refnamediv>
<refname>define</refname>
@@ -148,7 +194,8 @@
返します。
</para>
<para>
- <function>defined</function>および
+ <function>defined</function>,
+ <function>constant</function> および
<link linkend="language.constants">定数</link>の節も参照下さい。
</para>
</refsect1>
@@ -174,7 +221,8 @@
true、その他の場合にfalseを返します。
</para>
<para>
- <function>define</function>および
+ <function>define</function>,
+ <function>constant</function> および
<link linkend="language.constants">定数</link> の節も参照下さい。
</para>
</refsect1>
@@ -195,21 +243,49 @@
<paramdef>string <parameter>message</parameter></paramdef>
</funcprototype>
</funcsynopsis>
+ <simpara>
+ <function>die</function> は、<parameter>message</parameter> を出
+
+力し、スクリプトの処理を終了します。この関数は値を何も返しません。
+ </simpara>
<simpara>
-
この言語構造は、メッセージを出力し、スクリプトの処理を終了します。
- この関数は、リターンを行いません。
+ また、<function>die</function>
+には、パラメータとして関数も指定可
+ 能です。この関数は、<function>die</function>
+がスクリプトのパース
+ を終了する前に実行されます。
</simpara>
<para>
<example>
- <title>die の例</title>
+ <title><function>die</function> の例</title>
<programlisting role="php">
<?php
+
$filename = '/path/to/data-file';
-$file = fopen($filename, 'r')
- or die "ファイルunable to open file ($filename)";
+$file = fopen ($filename, 'r')
+ or die("unable to open file ($filename)");
+
?>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ <example>
+ <title>関数を使用する <function>die</function> の例</title>
+ <programlisting role="php">
+<?php
+
+function handle_error($msg) {
+ if ($fp = @fopen("/tmp/error.log", "a")) {
+ fwrite($fp, $msg, strlen($msg));
+ fclose($fp);
+ }
+}
+
+if ($bad) {
+ die(handle_error("Something bad happened.\n"));
+}
+
+?>
+ </programlisting>
+ </example>
</para>
<simpara>
<function>exit</function>も参照下さい。
@@ -422,8 +498,17 @@
関数 <function>highlight_file</function>は、
<parameter>filename</parameter>の中のコードをPHP組込の構文ハイラ
イタで定義されたカラーを使用して構文ハイライト表示したものを出力
- します。
+
+します。この関数は、成功時にtrue、その他の場合にfalseを返します。
+ (PHP 4)
</simpara>
+ <note>
+ <simpara>
+ 関数 <function>show_source</function> および
+ <function>highlight_file</function>を使用する場合には、パスワー
+
+ドや潜在的なセキュリティ上の危険を生む類の他の情報のような重要な
+
+情報を不注意で公開してしまわないように注意する必要があります。
+ </simpara>
+ </note>
<para>
<example>
<title>URLのソースハイライト表示の作成</title>
@@ -790,7 +875,7 @@
型や構造を失わずにPHPの値を保存または渡す際に有効です。
</simpara>
<simpara>
- シリアル化さ?た文字列をPHPの値に戻すには、
+ シリアル化された文字列をPHPの値に戻すには、
<function>unserialize</function>を使用して下さい。
<function>serialize</function>は型<type>integer</type>,
<type>double</type>,<type>string</type>,<type>array</type>
@@ -842,10 +927,16 @@
構文ハイライト表示を出力します。
成功時にtrue、そうでない場合にfalseを返します。(PHP 4)
</simpara>
+ <simpara>
+ この関数は、関数<function>highlight_file</function>のエイリアスで
+ す。
+ </simpara>
<note>
<simpara>
- この関数は、関数<function>highlight_file</function>のエイリアス
- です。
+ 関数 <function>show_source</function> および
+ <function>highlight_file</function>を使用する場合には、パスワー
+
+ドや潜在的なセキュリティ上の危険を生む類の他の情報のような重要な
+
+情報を不注意で公開してしまわないように注意する必要があります。
</simpara>
</note>
<simpara>
Index: phpdoc/ja/functions/mysql.xml
diff -u phpdoc/ja/functions/mysql.xml:1.16 phpdoc/ja/functions/mysql.xml:1.17
--- phpdoc/ja/functions/mysql.xml:1.16 Sun Feb 18 15:29:44 2001
+++ phpdoc/ja/functions/mysql.xml Sat Mar 10 21:56:43 2001
@@ -45,18 +45,44 @@
</funcsynopsis>
<para>
<function>mysql_affected_rows</function>は、指定した
- link_identifierが指すサーバーにおいて直近のINSERT、UPDATE、DELETE
-
クエリーにより変更された行の数を返します。link_identifierが指定さ
- れない場合、最後にオープンされたリンクが仮定されます。
+ <parameter>link_identifier</parameter> が指すサーバーにおいて直近
+
+のINSERT、UPDATE、DELETEクエリーにより変更された行の数を返します。
+ link_identifierが指定されない場合、
+ <function>mysql_connect</function> により直近にオープンされたリン
+ クが指定されたと仮定されます。
</para>
+ <note>
+ <para>
+ トランザクションを使用する場合には、
+コミット後ではなく、INSERT,
+ UPDATE, DELETE クエリの後に
+ <function>mysql_affected_rows</function> をコールする必要があり
+ ます。
+ </para>
+ </note>
<para>
直近のクエリーがWHERE節のないDELETEクエリーであった場合、全レコー
ドはテーブルから削除されていますが、この関数はゼロを返します。
</para>
+ <note>
+ <para>
+ UPDATEを使用する場合、MySQL
+は新しい値が古い値と同じ場合にはカラ
+ ムを更新しません。このため、
+ <function>mysql_affected_rows</function> はマッチした行の数には
+
+一致しない可能性があり、単にクエリにより文字の上で作用された行
+ の数となります。
+ </para>
+ </note>
+ <para>
+ <function>mysql_affected_rows</function> は、SELECT文には使用でき
+
+ません。レコードを修正する文でのみ使用できます。SELECTから返され
+ る行の数を得る際には、<function>mysql_num_rows</function>を使用し
+ て下さい。
+ </para>
+ <para>
+ 直近のクエリが失敗した場合、この関数は-1を返します。
+ </para>
<para>
-
このコマンドは、SELECT文には使用できません。レコードを修正する文
-
でのみ使用できます。SELECTから返される行の数を得る際には、
- <function>mysql_num_rows</function>を使用して下さい。
+ <function>mysql_num_rows</function> も参照下さい。
</para>
</refsect1>
</refentry>
@@ -228,11 +254,13 @@
<title>MySQL に接続する例</title>
<programlisting role="php">
<?php
- $link = mysql_connect ("kraemer", "marliesle", "secret")
+
+ $link = mysql_connect ("localhost", "username", "secret")
or die ("接続できませんでした");
print ("接続に成功しました");
mysql_close ($link);
-?>
+
+?>
</programlisting>
</example>
<para>
@@ -1411,28 +1439,30 @@
<para>
<function>mysql_num_rows</function>は結果セットにおける行の数を返
します。このコマンドはSELECT文でのみ有効です。
- INSERT、UPDATE、DELETEから返される行の数を取得する際には、
+ INSERT、UPDATE、DELETE
+クエリから返される行の数を取得する際には、
<function>mysql_affected_rows</function>を使用して下さい。
<example>
- <title>
- [EMAIL PROTECTED] による <function>mysql_num_rows</function>
- の例
- </title>
+ <title><function>mysql_num_rows</function>の例</title>
<programlisting role="php">
<?php
-$conn = mysql_connect("hostaddress", "username", "password");
-mysql_select_db("database",$conn); //
複数のデータベースがある場合は必要
-$Resultfornummembers = mysql_query("SELECT * FROM Accounts",$conn);
-$NumMembers = mysql_num_rows($Resultfornummembers);
-echo "$NumMembers Members";
-?>
+
+$link = mysql_connect("localhost", "username", "password");
+mysql_select_db("database", $link);
+
+$result = mysql_query("SELECT * FROM table1", $link);
+$num_rows = mysql_num_rows($result);
+
+echo "$num_rows 行\n";
+
+?>
</programlisting>
</example>
</para>
<para>
- <function>mysql_db_query</function>、
- <function>mysql_query</function>、
- <function>mysql_fetch_row</function> も参照下さい。
+ <function>mysql_affected_rows</function>,
+ <function>mysql_connect</function>,
+ <function>mysql_select_db</function>,
+ <function>mysql_query</function> も参照下さい。
</para>
<para>
下位互換性の維持のため、<function>mysql_numrows</function>
Index: phpdoc/ja/functions/pcre.xml
diff -u phpdoc/ja/functions/pcre.xml:1.18 phpdoc/ja/functions/pcre.xml:1.19
--- phpdoc/ja/functions/pcre.xml:1.18 Sat Mar 3 16:53:36 2001
+++ phpdoc/ja/functions/pcre.xml Sat Mar 10 21:56:43 2001
@@ -939,9 +939,11 @@
</literallayout>
</refsect1>
- <refsect1>
+ <refsect1 id="regexp.reference">
<title>正規表現の詳細</title>
- <literallayout>
+ <refsect2 id="regexp.introduction">
+ <title>導入</title>
+ <literallayout>
PCRE
によりサポートされる正規表現の構文を以下に示します。
正規表現は、Perl のドキュメントや他の多くの書籍において
豊富な例と共に説明されています。
@@ -958,6 +960,12 @@
The quick brown fox
は、検索対象文字列のそれ自体と同じ部分にマッチします。
+ </literallayout>
+ </refsect2>
+
+ <refsect2 id="regexp.reference.meta">
+ <title>メタ文字</title>
+ <literallayout>
正規表現の強力さは、パターン中に複数の選択肢や繰り返し
を含む能力によるものです。
これらは、<emphasis>メタ</emphasis>-<emphasis>文字</emphasis> を
@@ -992,8 +1000,13 @@
] 文字クラスの終了
次のセクションで、各メタ文字の使用法の説明を行います。
+
+ </literallayout>
+ </refsect2>
-バックスラッシュ
+ <refsect2 id="regexp.reference.backslash">
+ <title>バックスラッシュ</title>
+ <literallayout>
バックスラッシュには、いくつかの使用法があります。まず、
英字でない文字が後に続く場合、そてև字が有する
特別な意味は失われます。このバックスラッシュの使い方は、
@@ -1127,8 +1140,12 @@
受けません。\Z 及び \z の違いは、\Z
は、文字列の終端と同時に
文字列の最後の文字が改行の場合に前の文字にマャÁするのに対し、
\z は終端にのみマッチします。
+ </literallayout>
+ </refsect2>
-ハット記号及びドル記号
+ <refsect2 id="regexp.reference.circudollar">
+ <title>ハット記号及びドル記号</title>
+ <literallayout>
文字クラスの外側の場合、デフォルトのマッチモードでは、ハット記号は
現在マッチングを行っている位置が対象文字列の始端である場合にのみ
trueとなる言明です。
@@ -1170,18 +1187,24 @@
両方のモードで対象の始端および終端にマッチさせるために
シーケンス \A, \Z, \z を使用出来ることに注意してください。
- パターンの兣fの枝が \A を付けて始まる場合、
+ パターンの枝が \A を付けて始まる場合、
PCRE_MULTILINE の設定によらず、常にアンカー付きとなります。
-
-終止符 (ピリオド, ドット)
+ </literallayout>
+ </refsect2>
+ <refsect2 id="regexp.reference.dot">
+ <title>終止符</title>
+ <literallayout>
文字クラスの外側では、パターンの中のドットは非出力文字を含む
(デフォルトでは)改行以外の対象の全ての1文字にマッチします。
PCRE_DOTALL
オプションを設定した場合、ドットは改行にもマッチ
します。ドットの処理は、ハット記号およびドル記号とは完全に独立し
ています。共通な点は共に改行文字を含むことだけです。
ドットは、文字クラスの中では特別な意味を持ちません。
-
-ブラケット
+ </literallayout>
+ </refsect2>
+ <refsect2 id="regexp.reference.squarebrackets">
+ <title>角括弧</title>
+ <literallayout>
左ブラケットは文字クラスの開始を表し、右ブラケットにより終了
します。右ブラケットは、それ自体特別なものではありません。
右ブラケットがクラスのメンバーとして必要な場合、(もしあるな
@@ -1247,9 +1270,11 @@
\, -, (始端の)^ 以外の全ての英数字でない文字および終端の
] は、
文字クラスにおいて特別でない文字ですが、エスケープした場合でも
悪影響はありません。
-
-
-垂直バー
+ </literallayout>
+ </refsect2>
+ <refsect2 id="regexp.reference.verticalbar">
+ <title>垂直バー</title>
+ <literallayout>
垂直バー文字は、選択肢を指定するパターンで使用されます。例えば、パターン
gilbert|sullivan
@@ -1261,9 +1286,13 @@
で説明する)サブパターンの中にある場合、"成功した"ということは
サブパターンの選択肢と同様にメインパターンの残りの部分もマッチ
したということを意?Wます。
+ </literallayout>
+ </refsect2>
+ <refsect2 id="regexp.reference.internal_options">
+ <title>内部オプション設定</title>
+ <literallayout>
-内部オプション設定
PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, PCRE_EXTENDED の
設定は、"(?" および ")" で括った Perl オプション文字により
パターン内部で変更可能です。
@@ -1324,7 +1353,11 @@
内で他の設定をオンにする前に指定する必要があります。
このフラグは、最初に指定するのが最善です。
-サブパターン
+ </literallayout>
+ </refsect2>
+ <refsect2 id="regexp.reference.subpatterns">
+ <title>サブパターン</title>
+ <literallayout>
サブパターンは括弧(丸括弧)で区分され、ネストが可能です。
パターンの一部をサブパターンとして指定するためには、2つのこ
とを行います。
@@ -1378,7 +1411,13 @@
このため、上のパターンは、"Saturday" と同様に"SUNDAY" にも
マッチします。
-繰り返し
+ </literallayout>
+ </refsect2>
+
+ <refsect2 id="regexp.reference.repetition">
+ <title>繰り返し</title>
+ <literallayout>
+
繰り返しは、反復指定子により指定します。次の要素の後に付ける
ことが出来ます。
@@ -1502,8 +1541,13 @@
を "aba"
にマッチさせると、2番目に取得される部分文字列は、
"b" になります。
+
+ </literallayout>
+ </refsect2>
-後方参照
+ <refsect2 id="regexp.reference.back_references">
+ <title>後方参照</title>
+ <literallayout>
文字クラスの外で、バックスラッシュの後に 0
より大きい数字を
付けたものはパターンで以前に(すなわち左にある)値を取得した
サブパターンに対する後方参照であり、前にある値の取得を行う
@@ -1563,8 +1607,12 @@
あります。これは上の例のように選択を使用するか、ゼロを最小と
する反復指定子により行うことができます。
+ </literallayout>
+ </refsect2>
-言明
+ <refsect2 id="regexp.reference.assertions">
+ <title>言明</title>
+ <literallayout>
言明は、現在マッチを行っている位置の後に続くか前にある文字に
対するテストであり、実際には文字への作用を行いません。
@@ -1670,8 +1718,12 @@
言明の括弧で括られたサブパターンの数は、最大 200 です。
+ </literallayout>
+ </refsect2>
-一回だけ使用するサブパターン
+ <refsect2 id="regexp.reference.onlyonce">
+ <title>一回だけ使用するサブパターン</title>
+ <literallayout>
反復を最大化および最小化する場合は共に、後に続くものへのマッ
チが失敗した場合、反復数を変えた場合にパターンの残りにマッチ
することができるかどうかを調べるために反復する項目が再評価さ
@@ -1772,7 +1824,12 @@
数字以外の並びにより不備を生じることがなくなり、失敗は早期に生じ
ます。
-条件付きサブパターン
+ </literallayout>
+ </refsect2>
+
+ <refsect2 id="regexp.reference.conditional">
+ <title>条件付きサブパターン</title>
+ <literallayout>
言明の結果または前の値を取得するサブパターンがマッチしたかど
うかにより、サブパターンのマッチ処理を行ったり、サブパターンの
2つの選択肢を選択したりすることが可能です。条件付きサブパター
@@ -1820,8 +1877,13 @@
は、2番目にマッチします。このパターンは、2つの形式
dd-aaa-dd
または dd-dd-dd
のどちらかの文字列にマッチします。ただし、
aaa は英字、dd は数字です。
+
+ </literallayout>
+ </refsect2>
-コメント
+ <refsect2 id="regexp.reference.comments">
+ <title>コメント</title>
+ <literallayout>
(?#
という並びは、開始を指定します。コメントは、次の右括弧まで
続きます。括弧のネストは許可されません。コメント中の文字は、
パターンマッチングには全く関係しません。
@@ -1829,8 +1891,13 @@
PCRE_EXTENDED
オプションが設定されている場合、文字クラスの外
にあるエスケープされていない #
文字は、コメントを指定します。
コメントは、パターン中の次の改行文字まで続きます。
+
+ </literallayout>
+ </refsect2>
-再帰的パターン
+ <refsect2 id="regexp.reference.recursive">
+ <title>再帰的パターン</title>
+ <literallayout>
無制限のネストを許容する括弧を含む文字列にマッチを行う問題を考え
てみましょう。再帰を使用しない場合、実現可能な最良の方法は、何ら
かの固定した深さのネストまでマッチを行うパターンを使用することで
@@ -1878,8 +1945,12 @@
得できない場合、メモリ不足エラーを再帰の内側から出力する手段
はないため、最初の15個の取得用括弧についてのみデータが保存さ
れます。
+ </literallayout>
+ </refsect2>
-性能
+ <refsect2 id="regexp.reference.performances">
+ <title>性能</title>
+ <literallayout>
パターンの幾つかの要素は、他の要素よりもより効率的です。
(a|e|i|o|u) のような選択肢の集合よりも [aeiou] のような文字ク
ラスの方がより効率的です。一般に、構成が最も簡単なものが
@@ -1939,7 +2010,8 @@
前者は、全体が "a"
文字である行に適用された場合にほぼ瞬間的に失敗
と判定します。一方、後者では、およそ20文字より長い文字列ではかな
りの時間がかかります。
- </literallayout>
+ </literallayout>
+ </refsect2>
</refsect1>
</refentry>
</reference>
Index: phpdoc/ja/functions/posix.xml
diff -u phpdoc/ja/functions/posix.xml:1.5 phpdoc/ja/functions/posix.xml:1.6
--- phpdoc/ja/functions/posix.xml:1.5 Fri Oct 13 08:30:56 2000
+++ phpdoc/ja/functions/posix.xml Sat Mar 10 21:56:44 2001
@@ -545,7 +545,7 @@
<title>説明</title>
<funcsynopsis>
<funcprototype>
- <funcdef>bool <function>posix_getcwd</function></funcdef>
+ <funcdef>bool <function>posix_mkfifo</function></funcdef>
<paramdef>string <parameter>pathname</parameter></paramdef>
<paramdef>int <parameter>mode</parameter></paramdef>
</funcprototype>
Index: phpdoc/ja/functions/recode.xml
diff -u phpdoc/ja/functions/recode.xml:1.5 phpdoc/ja/functions/recode.xml:1.6
--- phpdoc/ja/functions/recode.xml:1.5 Sat Nov 11 16:23:31 2000
+++ phpdoc/ja/functions/recode.xml Sat Mar 10 21:56:44 2001
@@ -62,7 +62,7 @@
<title>説明</title>
<funcsynopsis>
<funcprototype>
- <funcdef>string <function>recode_string</function></funcdef>
+ <funcdef>string <function>recode</function></funcdef>
<paramdef>string <parameter>request</parameter></paramdef>
<paramdef>string <parameter>string</parameter></paramdef>
</funcprototype>
Index: phpdoc/ja/functions/strings.xml
diff -u phpdoc/ja/functions/strings.xml:1.27 phpdoc/ja/functions/strings.xml:1.28
--- phpdoc/ja/functions/strings.xml:1.27 Sat Feb 24 17:00:02 2001
+++ phpdoc/ja/functions/strings.xml Sat Mar 10 21:56:44 2001
@@ -1668,13 +1668,14 @@
<funcsynopsis>
<funcprototype>
<funcdef>string <function>setlocale</function></funcdef>
- <paramdef>string <parameter>category</parameter></paramdef>
+ <paramdef>mixed <parameter>category</parameter></paramdef>
<paramdef>string <parameter>locale</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
- <parameter>category</parameter>は、ロケール設定により影響を
-
受ける関数のカテゴリを指定する文字列です。以下のものがあります。
+ <parameter>category</parameter>は、名前付きの定数(または文字列)で
+
+あり、ロケール設定により影響を受ける関数のカテゴリを指定します。
+ カテゴリには、以下のものがあります。
<itemizedlist>
<listitem>
<simpara>
@@ -1720,7 +1721,8 @@
<para>
Setlocale
は現在の新しいロケールを返し、ロケール機能が未実装、
指定されたロケールが存在しない、カテゴリ名が無効などの場合は
-
偽を返します。また、カテゴリ名が無効の場合は警告メッセージが発せられます。
+
+偽を返します。また、カテゴリ名が無効の場合は警告メッセージが発せ
+ られます。
</para>
</refsect1>
</refentry>
Index: phpdoc/ja/functions/yaz.xml
diff -u phpdoc/ja/functions/yaz.xml:1.5 phpdoc/ja/functions/yaz.xml:1.6
--- phpdoc/ja/functions/yaz.xml:1.5 Mon Feb 19 01:57:19 2001
+++ phpdoc/ja/functions/yaz.xml Sat Mar 10 21:56:44 2001
@@ -281,7 +281,7 @@
<title>説明</title>
<funcsynopsis>
<funcprototype>
- <funcdef>int <function>yaz_range</function></funcdef>
+ <funcdef>int <function>yaz_element</function></funcdef>
<paramdef>int <parameter>id</parameter></paramdef>
<paramdef>string <parameter>elementset</parameter></paramdef>
</funcprototype>
Index: phpdoc/ja/language/oop.xml
diff -u phpdoc/ja/language/oop.xml:1.6 phpdoc/ja/language/oop.xml:1.7
--- phpdoc/ja/language/oop.xml:1.6 Sat Feb 24 17:00:02 2001
+++ phpdoc/ja/language/oop.xml Sat Mar 10 21:56:44 2001
@@ -30,7 +30,7 @@
}
}
}
-?>
+?>
</programlisting>
</informalexample>
</para>
@@ -194,6 +194,179 @@
</caution>
</sect1>
+ <sect1 id="language.oop.newref">
+ <title>コンストラクタの中での参照</title>
+ <para>
+
+コンストラクタの中で参照を作成すると結果が混乱する可能性があります。
+
+本節ではチュートリアル形式で説明しますが、この問題を避けるために役
+ 立つはずです。
+
+ <informalexample>
+ <programlisting role="php">
+
+class foo {
+ function foo($name) {
+ // 内部への参照グローバル配列 $globalref を作成
+ global $globalref;
+ $globalref[] = &$this;
+ // name を指定した値に設定
+ $this->setName($name);
+ // それを出力
+ $this->echoName();
+ }
+
+ function echoName() {
+ echo "<br>",$this->Name;
+ }
+
+ function setName($name) {
+ $this->Name = $name;
+ }
+}
+ </programlisting>
+ </informalexample>
+ </para>
+
+ <para>
+ コピー演算子 <literal>=</literal> により作成された
+ <varname>$bar1</varname> と 参照演算子 <literal>=&</literal>
+ により作成された <varname>$bar2</varname>
+の間の差異があるかどうか
+ を確認してみましょう。
+
+ <informalexample>
+ <programlisting role="php">
+
+ $bar1 = new foo('set in constructor');
+ $bar1->echoName();
+ $globalref[0]->echoName();
+
+ /* 出力:
+ set in constructor
+ set in constructor
+ set in constructor */
+
+ $bar2 =& new foo('set in constructor');
+ $bar2->echoName();
+ $globalref[1]->echoName();
+
+ /* 出力:
+ set in constructor
+ set in constructor
+ set in constructor */
+
+ </programlisting>
+ </informalexample>
+ </para>
+ <para>
+
+明らかに違いはありませんが、実際には動作は非常に異なっています。つ
+ まり、<varname>$bar1</varname> と <varname>$globalref[0]</varname>
+ は、 参照されておらず、同じ変数でもありません。
+ これは、"new"
+がデフォルトで参照を返さず、代わりにコピーを返すため
+ です。
+ <note>
+ <simpara>
+ (PHP
+4以降ではリファレンスカウンティングを使用しているため、)参
+
+照ではなくコピーを返すことで性能が低下することはありません。逆に
+
+多くの場合、参照を使うよりも単純にコピーを使った方が良い結果とな
+
+ります。これは、参照の作成には時間がかかりますが、コピーの作成に
+
+は理想的には時間が全くかからないからです。(ただし、大きな配列ま
+
+たはオブジェクトでその一つが変更されると、次々に参照先の他の要素
+ に参照先に波及するといった場合を除きます)
+ </simpara>
+ </note>
+
+上記の記述が正しいことを示すために以下のコードを見てみましょう。
+
+ <informalexample>
+ <programlisting role="php">
+// ここで、name を変更してみます。どうなるでしょうか?
+// $bar と $globalref[0]
+の両方共名前が変わると予想するかもしれません...
+$bar1->setName('set from outside');
+
+// 前記のようにこの場合は違います。
+$bar1->echoName();
+$globalref[0]->echoName();
+
+/* 出力:
+set on object creation set from outside */
+
+// $bar2 と $globalref[1] の差を見てみましょう
+$bar2->setName('set from outside');
+
+//
+うまく行けば、値が等しいだけでなく、同じ変数となります。
+// つまり、$bar2->Name と $globalref[1]->Name も同じになります。
+$bar2->echoName();
+$globalref[1]->echoName();
+
+/* 出力:
+set from outside set from outside */
+
+ </programlisting>
+ </informalexample>
+ </para>
+ <para>
+ 別の最後の例について考えてみて下さい。
+
+ <informalexample>
+ <programlisting role="php">
+
+class a {
+ function a($i) {
+ $this->value = $i;
+ // ここで参照を使う必要がない理由を考えてみて下さい
+ $this->b = new b($this);
+ }
+
+ function createRef() {
+ $this->c = new b($this);
+ }
+
+ function echoValue() {
+ echo "<br>","class ",get_class($this),': ',$this->value;
+ }
+}
+
+
+class b {
+
+ function b(&$a) {
+ $this->a = &$a;
+ }
+
+ function echoValue() {
+ echo "<br>","class ",get_class($this),': ',$this->a->value;
+ }
+
+}
+
+// 以下の単純なコピーが、*
+印を付けた行で望ましくない結果を生む理由を
+// 考えてみて下さい。
+$a =& new a(10);
+$a->createRef();
+
+$a->echoValue();
+$a->b->echoValue();
+$a->c->echoValue();
+
+$a->value = 11;
+
+$a->echoValue();
+$a->b->echoValue(); // *
+$a->c->echoValue();
+
+/*
+出力:
+class a: 10
+class b: 10
+class b: 10
+class a: 11
+class b: 11
+class b: 11
+*/
+ </programlisting>
+ </informalexample>
+ </para>
+ </sect1>
+
</chapter>
<!-- Keep this comment at the end of the file
Index: phpdoc/ja/pear/pear.xml
diff -u phpdoc/ja/pear/pear.xml:1.1 phpdoc/ja/pear/pear.xml:1.2
--- phpdoc/ja/pear/pear.xml:1.1 Fri Mar 9 07:33:04 2001
+++ phpdoc/ja/pear/pear.xml Sat Mar 10 21:56:44 2001
@@ -12,7 +12,7 @@
<refentry id="class.pear">
<refnamediv>
<refname>PEAR</refname>
- <refpurpose>PEAR ベースクラス</refpurpose>
+ <refpurpose>PEAR基底クラス</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>class <replaceable>classname</replaceable> extends
<classname>PEAR</classname> { ... }</synopsis>
@@ -20,7 +20,7 @@
<refsect1>
<title>説明</title>
<simpara>
-
PEARベースクラスは、多くのPEARクラスで使用される標準的な機能を提
+
+PEAR基底クラスは、多くのPEARクラスで使用される標準的な機能を提
供します。通常、PEARクラスのインスタンスを直接作成することはあり
ません。このクラスのサブクラス化して使用して下さい。
</simpara>
@@ -38,59 +38,60 @@
<refsect2>
<title>PEAR "デストラクタ"</title>
<simpara>
- If you inherit <classname>PEAR</classname> in a class called
- <replaceable>ClassName</replaceable>, you can define a method in
- it called called _<replaceable>ClassName</replaceable> (the
- class name with an underscore prepended) that will be invoked
- when the request is over. This is not a destructor in the sense
- that you can "delete" an object and have the destructor called,
- but in the sense that PHP gives you a callback in the object
- when it is done executing. See <link
- linkend="example.pear.destructors">the example</link> below.
+ <replaceable>ClassName</replaceable>という名前のクラスで
+ <classname>PEAR</classname> を継承する場合、
+ _<replaceable>ClassName</replaceable> (クラス名の前にアンダース
+
+コアを付けたもの)というメソッドを定義できます。これは、リクエス
+
+トの終了時にコールされます。これは、オブジェクトを"削除"できると
+
+いう意味でのデストラクタではなく、実行が終了した際にオブジェクト
+
+内でPHPからのコールバックを指定するという意味で、デストラクタと
+ 呼ばれます。以下の <link linkend="example.pear.destructors">例
+ </link> を参照下さい。
</simpara>
</refsect2>
+
<refsect2>
<title>PEARのエラー処理</title>
<simpara>
- PEAR's base class also provides a way of passing around more
- complex errors than a true/false value or a numeric code. A
- PEAR error is an object that is either an instance of the class
- <classname>PEAR_Error</classname>, or some class inheriting
- <classname>PEAR_Error</classname>.
+
+PEARの基底クラスは、true/false値や数値コードよりも複雑なエラーを
+ 渡す手段を提供します。PEARのエラーは、クラス
+ <classname>PEAR_Error</classname>または
+ <classname>PEAR_Error</classname>を継承したクラスのインスタンス
+ です。
</simpara>
<simpara>
- One of the design criteria of PEAR's errors is that it should
- not force a particular type of output on the user, it should be
- possible to handle errors without any output at all if that is
- desireable. This makes it possible to handle errors gracefully,
- also when your output format is different from HTML (for example
- WML or some other XML format).
+
+PEARのエラーの設計指針の一つは、ユーザに特定の型の出力を強制する
+
+べきではなく、必要ならば出力を全く行うことなくエラーを処理するこ
+
+とを可能にするべきであるというものです。これにより、エラー処理を
+
+柔軟に行うことが可能になり、また、出力形式をHTML以外となる場合
+
+(例えば、WMLまたは他のXML形式)でも処理を行うことが可能となります。
</simpara>
<simpara>
- The error object can be configured to do a number of things when
- it is created, such as printing an error message, printing the
- message and exiting, raising an error with PHP's
- <function>trigger_error</function> function, invoke a callback,
- or none of the above. This is typically specified in
- <classname>PEAR_Error</classname>'s constructor, but all of the
- parameters are optional, and you can set up defaults for errors
- generated from each object based on the
- <classname>PEAR</classname> class. See the <link
- linkend="example.pear.error1">PEAR error examples</link> for how
- to use it and the <classname>PEAR_Error</classname> reference
- for the full details.
+
+エラーオブジェクトは、作成時にエラーメッセージを出力したり、メッ
+ セージを出力し終了したり、PHPの
+ <function>trigger_error</function>関数でエラーを発生しコールバッ
+
+ク関数を呼び出したり、こうしたことを何もしないといったように何ら
+ かの動作を行うように設定可能です。この動作は、通常、
+ <classname>PEAR_Error</classname>のコンストラクタで指定されます
+ が、全てのパラメータはオプションであり、
+
+<classname>PEAR</classname>クラスに基づく各オブジェクトから生成
+
+されるエラー用にデフォルト値を設定可能です。使用法については
+ <link linkend="example.pear.error1">PEARエラーの例</link>、詳細
+ については、<classname>PEAR_Error</classname>のリファレンスを参
+ 照下さい。
</simpara>
</refsect2>
</refsect1>
+
<refsect1>
<title>例</title>
<para>
- The example below shows how to use the PEAR's "poor man's kinda
- emulated destructors" to implement a simple class that holds the
- contents of a file, lets you append data to the object and
- flushes the data back to the file at the end of the request:
+
+以下の例は、PEARの「貧乏人のデストラクタもどき」の使用法を示すも
+
+ので、定数をファイルに保存する簡単なクラスを実装しており、オブジェ
+
+クトにデータを追加し、リクエストの終了時にファイルにデータを書き
+ 戻します。
<example id="example.pear.destructors">
- <title>PEAR: emulated destructors</title>
+ <title>PEAR: デストラクタのエミュレーション</title>
<programlisting role="php">
require_once "PEAR.php";
@@ -102,7 +103,7 @@
function FileContainer($file)
{
- $this->PEAR(); // this calls the parent class constructor
+ $this->PEAR(); //
+これにより親クラスのコンストラクタをコールします
$fp = fopen($file, "r");
if (!is_resource($fp)) {
return;
@@ -119,8 +120,8 @@
$this->modified++;
}
- // The "destructor" is named like the constructor
- // but with an underscore in front.
+ // "destructor"
+は、コンストラクタと同様な名前が付けられていますが、
+ // 先頭にアンダースコアが付きます。
function _FileContainer()
{
if ($this->modified) {
@@ -137,28 +138,28 @@
$fileobj = new FileContainer("testfile");
$fileobj->append("this ends up at the end of the file\n");
-// When the request is done and PHP shuts down, $fileobj's
-// "destructor" is called and updates the file on disk.
+// リクエストが終了し、PHPがシャットダウンした場合、$fileobjの
+// "デストラクタ"
+がコールされ、ディスク上のファイルが更新されます。
-</programlisting>
+ </programlisting>
</example>
<note>
<simpara>
- PEAR "destructors" use PHP's shutdown callbacks
- (<function>register_shutdown_function</function>), and you
- can't output anything from these when PHP is running in a web
- server. So anything printed in a "destructor" gets lost except
- when PHP is used in command-line mode. Bummer.
+ PEARの"デストラクタ"は、PHPのシャットダウンコールバック
+ (<function>register_shutdown_function</function>)を使用します。
+
+PHPをWebサーバ上で実行している場合には、これらから出力を行うこ
+
+とはできません。このため、"デストラクタ"から出力されたものは、
+
+コマンドラインモードでPHPを使用している場合以外は失われます。
</simpara>
</note>
</para>
<simpara>
- The next examples illustrate different ways of using PEAR's error
- handling mechanism.
+
+次の例は、PEARのエラー処理機構を使用する別の手法について説明する
+ ものです。
</simpara>
<para>
<example id="example.pear.error1">
- <title>PEAR error の例 (1)</title>
+ <title>PEAR エラーの例 (1)</title>
<programlisting role="php">
function mysockopen($host = "localhost", $port = 8090)
{
@@ -173,27 +174,28 @@
if (PEAR::isError($sock)) {
print "mysockopen error: ".$sock->getMessage()."<BR>\n"
}
-</programlisting>
+ </programlisting>
</example>
</para>
<simpara>
- This example shows a wrapper to <function>fsockopen</function>
- that delivers the error code and message (if any) returned by
- fsockopen in a PEAR error object. Notice that
- <function>PEAR::isError</function> is used to detect whether a
- value is a PEAR error.
+ この例は、エラーコードとメッセージを返す
+ <function>fsockopen</function>へのラッパーの例で、(必要な場合に)
+ fsockopen
+により返されたメッセージをPEARエラーオブジェクトに渡し
+ ています。値がPEARエラーかどうかを調べるために
+ <function>PEAR::isError</function> が使用されていることに注意して
+ 下さい。
</simpara>
<simpara>
- PEAR_Error's mode of operation in this example is simply
- returning the error object and leaving the rest to the user
- (programmer). This is the default error mode.
+
+この例でのPEAR_Errorの処理モードは、単にエラーオブジェクトを返し、
+
+他の処理はユーザ(プログラマ)にまかせています。これがデフォルトの
+ エラーモードです。
</simpara>
<simpara>
- In the next example we're showing how to use default error modes:
+
+次の例では、デフォルトのエラーモードの使用法を示します。
</simpara>
<para>
<example id="example.pear.error2">
- <title>PEAR error example (2)</title>
+ <title>PEAR エラーの例 (2)</title>
<programlisting role="php">
class TCP_Socket extends PEAR
{
@@ -217,18 +219,19 @@
$sock->setErrorHandling(PEAR_ERROR_DIE);
$sock->connect("localhost", 8090);
print "still alive<BR>\n";
-</programlisting>
+ </programlisting>
</example>
</para>
<simpara>
- Here, we set the default error mode to
- <constant>PEAR_ERROR_DIE</constant>, and since we don't specify
- any error mode in the raiseError call (that'd be the third
- parameter), raiseError uses the default error mode and exits if
- fsockopen fails.
+ ここでは、デフォルトのエラーモードを
+ <constant>PEAR_ERROR_DIE</constant>に設定しており、
+
+raiseErrorコールで(3番目のパラメータにより)エラーモードを指定して
+
+いないため、raiseErrorはデフォルトのエラーモードを使用し、
+ fsockopenが失敗した場合に終了します。
</simpara>
</refsect1>
</refentry>
+
<refentry id="class.pear-error">
<refnamediv>
<refname>PEAR_Error</refname>
@@ -240,36 +243,35 @@
<refsect1>
<title>エラーモード</title>
<para>
-
- An error object has a mode of operation that can be set with one
- of the following constants:
+
+エラーオブジェクトは処理モードを有しており、次のどれかを設定可能
+ です。
<variablelist id="pear.error-modes">
- <varlistentry id="constant.pear-error-return">
+ <varlistentry id="constant.pear-error-return">
<term>PEAR_ERROR_RETURN</term>
- <listitem>
- <simpara>
- Just return the object, don't do anything special in
- PEAR_Error's constructor.
- </simpara>
- </listitem>
- </varlistentry>
+ <listitem>
+ <simpara>
+
+オブジェクトを返すだけであり、PEAR_Errorのコンストラクタで特
+ 別なことは何もしません。
+ </simpara>
+ </listitem>
+ </varlistentry>
<varlistentry id="constant.pear-error-print">
<term>PEAR_ERROR_PRINT</term>
<listitem>
<simpara>
- Print the error message in the constructor. The execution is
- not interrupted.
- </simpara>
+
+エラーメッセージをコンストラクタで出力します。実行は中断しま
+ せん。
+ </simpara>
</listitem>
</varlistentry>
<varlistentry id="constant.pear-error-trigger">
<term>PEAR_ERROR_TRIGGER</term>
<listitem>
<simpara>
- Use PHP's <function>trigger_error</function> function to
- raise an internal error in PHP. The execution is aborted if
- you have defined your own PHP error handler or if you set the
- error severity to E_USER_ERROR.
+ PHPで内部エラーを発生するためにPHPの
+ <function>trigger_error</function>関数を使用します。ユーザが
+ PHPエラーハンドラを定義しているかエラーのseverityを
+ E_USER_ERRORに設定している場合に実行は終了します。
</simpara>
</listitem>
</varlistentry>
@@ -277,8 +279,8 @@
<term>PEAR_ERROR_DIE</term>
<listitem>
<simpara>
- Print the error message and exit. Execution is of course
- aborted.
+
+エラーメッセージを出力し、終了します。実行はもちろん終了しま
+ す。
</simpara>
</listitem>
</varlistentry>
@@ -286,18 +288,20 @@
<term>PEAR_ERROR_CALLBACK</term>
<listitem>
<simpara>
- Use a callback function or method to handle errors.
- Execution is aborted.
+
+エラー処理にコールバック関数またはメソッドを使用します。実行
+ は終了されます。
</simpara>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
+
<refsect1>
<title>プロパティ</title>
<simpara></simpara>
</refsect1>
+
<refsect1>
<title>メソッド</title>
<funcsynopsis>
@@ -315,13 +319,13 @@
<refsect2>
<title>説明</title>
<para>
- PEAR_Error constructor. Parameters:
+ PEAR_Error のコンストラクタ。パラメータ:
<variablelist>
<varlistentry>
<term>message</term>
<listitem>
<simpara>
- error message, defaults to "unknown error"
+ エラーメッセージ。デフォルトは、"unknown error"
</simpara>
</listitem>
</varlistentry>
@@ -329,7 +333,7 @@
<term>code</term>
<listitem>
<simpara>
- error code (optional)
+ エラーコード (オプション)
</simpara>
</listitem>
</varlistentry>
@@ -337,9 +341,8 @@
<term>mode</term>
<listitem>
<simpara>
- Mode of operation. See the <link
- linkend="pear.error-modes">error modes</link> section for
- details.
+ 処理モード。詳細は、<link linkend="pear.error-modes">エラー
+ モード</link> の節を参照下さい。
</simpara>
</listitem>
</varlistentry>
@@ -347,15 +350,15 @@
<term>options</term>
<listitem>
<simpara>
- If the mode of can have any options specified, use this
- parameter. Currently the "trigger" and "callback" modes are
- the only using the options parameter. For trigger mode,
- this parameter is one of <constant>E_USER_NOTICE</constant>,
- <constant>E_USER_WARNING</constant> or
- <constant>E_USER_ERROR</constant>. For callback mode, this
- parameter should contain either the callback function name
- (string), or a two-element (object, string) array
- representing an object and a method name.
+
+オプションが指定可能なモードの場合、このパラメータを使用して
+ 下さい。現在、"trigger" と "callback"
+モードのみがオプション
+
+パラメータを使用しています。triggerモードの場合、このパラメー
+ タは、<constant>E_USER_NOTICE</constant>、
+ <constant>E_USER_WARNING</constant>、
+ <constant>E_USER_ERROR</constant>のどれかです。callbackモー
+
+ドの場合、このパラメータは、コールバック関数名(文字列)または
+
+オブジェクトとメソッド名を表す二つの要素(オブジェクト、文字
+ 列)からなる配列のどちらかを指定する必要があります。
</simpara>
</listitem>
</varlistentry>
Index: phpdoc/ja/pear/standards.xml
diff -u phpdoc/ja/pear/standards.xml:1.1 phpdoc/ja/pear/standards.xml:1.2
--- phpdoc/ja/pear/standards.xml:1.1 Fri Mar 9 07:33:04 2001
+++ phpdoc/ja/pear/standards.xml Sat Mar 10 21:56:45 2001
@@ -4,32 +4,34 @@
<sect1 id="pear.standards.indenting">
<title>インデント</title>
<para>
- Use an indent of 4 spaces, with no tabs. If you use Emacs to edit PEAR
- code, you should set indent-tabs-mode to nil. Here is an example mode
- hook that will set up Emacs according to these guidelines (you will
- need to ensure that it is called when you are editing php files):
+
+インデントとして空白4つを使用し、タブは使用しないで下さい。PEARコー
+ ドを編集するためにEmacsを使用している場合、 indent-tabs-mode
+を
+ nil
+に設定して下さい。以下にこれらの指針に沿ってEmacsを設定するた
+
+めのモードフックの例を示します。(PHPファイルを編集する際にこのフッ
+ クがコールされるようにする必要があります。)
<programlisting role="elisp">
(defun php-mode-hook ()
(setq tab-width 4
c-basic-offset 4
c-hanging-comment-ender-p nil
indent-tabs-mode nil))
-</programlisting>
+ </programlisting>
</para>
- <para>Here are vim rules for the same thing:
+ <para>
+ 同じことを行う vim 用の設定を示します。
<programlisting role="vim">
set expandtab
set shiftwidth=4
set tabstop=4
-</programlisting>
+ </programlisting>
</para>
</sect1>
<sect1 id="pear.standards.control">
<title>制御構造</title>
<para>
- These include if, for, while, switch, etc. Here is an example if
- statement, since it is the most complicated of them:
+ 制御構造には、if, for, while, switch,
+等が含まれます。制御構造の中
+ で最も複雑なif文の例を以下に示します。
<programlisting role="php">
if ((condition1) || (condition2)) {
action1;
@@ -41,18 +43,17 @@
</programlisting>
</para>
<simpara>
- Control statements should have one space between the control keyword
- and opening parenthesis, to distinguish them from function calls.
+
+制御文は、関数のコールと区別するために制御用のキーワードと開き括弧
+ の間に空白を一つおく必要があります。
</simpara>
<simpara>
- You are strongly encouraged to always use curly braces even in
- situations where they are technically optional. Having them
- increases readability and decreases the likelihood of logic errors
- being introduced when new lines are added.
+
+文法的には他の選択肢もありますが、常に波括弧を使用することが強く推
+
+奨されます。このようにすることにより、可読性が向上し、改行が追加さ
+
+れた際に発生するかもしれない論理構造上のエラーが減少します。
</simpara>
<para>
- For switch statements:
- <programlisting role="php">
+ switch 文の場合は次のようにします。
+ <programlisting role="php">
switch (condition) {
case 1:
action1;
@@ -67,38 +68,36 @@
break;
}
-</programlisting>
+ </programlisting>
</para>
</sect1>
<sect1 id="pear.standards.funcalls">
<title>関数のコール</title>
<para>
- Functions should be called with no spaces between the function
- name, the opening parenthesis, and the first parameter; spaces
- between commas and each parameter, and no space between the last
- parameter, the closing parenthesis, and the semicolon. Here's an
- example:
+
+関数は、関数名、開き括弧、最初のパラメータの間に空白を付けてコール
+
+するべきではありません。また、カンマと各パラメータの間には、空白を
+
+置き、最後のパラメータと閉じ括弧およびセミコロンの間には空白を置か
+ ないようにします。以下に例を示します。
<programlisting role="php">
$var = foo($bar, $baz, $quux);
</programlisting>
</para>
<para>
- As displayed above, there should be one space on either side of an
- equals sign used to assign the return value of a function to a
- variable. In the case of a block of related assignments, more space
- may be inserted to promote readability:
+
+上記のように、関数の値を変数に代入するために使用される等号の両側に
+
+は、空白を一つ置きます。関連する代入のブロックの場合には、可読性を
+ 向上させるために複数の空白を挿入することも可能です。
<programlisting role="php">
$short = foo($bar);
$long_variable = foo($baz);
-</programlisting>
+ </programlisting>
</para>
</sect1>
<sect1 id="pear.standards.funcdef">
<title>関数の定義</title>
<para>
- Function declaractions follow the "one true brace" convention:
+
+関数選言の後には、次のように波括弧を一つ置く流儀とします。
<programlisting role="php">
function fooFunction($arg1, $arg2 = '')
{
@@ -107,12 +106,12 @@
}
return $val;
}
-</programlisting>
+ </programlisting>
</para>
<para>
- Arguments with default values go at the end of the argument list.
- Always attempt to return a meaningful value from a function if one
- is appropriate. Here is a slightly longer example:
+
+デフォルト値を有する引数は、引数リストの最後につけます。関数の動作
+
+が正常である場合には、常にその関数から意味のある値を返すようにして
+ 下さい。以下にやや長い例を示します。
<programlisting role="php">
function connect(&$dsn, $persistent = false)
{
@@ -135,39 +134,39 @@
<sect1 id="pear.standards.comments">
<title>コメント</title>
<para>
- Inline documentation for classes should follow the PHPDoc
- convention, similar to Javadoc. More information about PHPDoc can
- be found here: <ulink url="&url.phpdoc;">&url.phpdoc;</ulink>
+
+クラス用のインラインドキュメントは、Javadocに似たPHPDocの流儀に沿っ
+ ている必要があります。PHPDocに関するより詳細な情報は、
+ <ulink url="&url.phpdoc;">&url.phpdoc;</ulink> にあります。
</para>
<para>
- Non-documentation comments are strongly encouraged. A general rule of
- thumb is that if you look at a section of code and think "Wow, I don't
- want to try and describe that", you need to comment it before you
- forget how it works.
+
+ドキュメント以外のコメントも強く推奨されます。一般的な指針としてあ
+
+るコードのブロックを見て、「これを説明したいとは思わない」と思った
+
+場合には、動作内容を忘れる前にコメントを書く必要があります。
</para>
<para>
- C++ style comments (/* */) and standard C comments (// ) are both
- fine. Use of perl/shell style comments (# ) is discouraged.
+ C 形式のコメント (/* */) と標準的な C++ のコメント (// )
+は共に使
+ 用可能です。Per/シェル形式のコメント (# )
+の使用は推奨されません。
</para>
</sect1>
<sect1 id="pear.standards.including">
<title>コードの読み込み</title>
<para>
- Anywhere you are unconditionally including a class file, use
- <function>require_once</function>. Anywhere you are conditionally
- including a class file (for example, factory methods), use
- <function>include_once</function>. Either of these will ensure
- that class files are included only once. They share the same file
- list, so you don't need to worry about mixing them - a file
- included with <function>require_once</function> will not be
- included again by <function>include_once</function>.
+ クラスファイルを無条件にどこかに読む込む場合には、
+ <function>require_once</function> を使用して下さい。条件付きでクラ
+
+スファイルをどこかに読み込む場合(例えば、factoryメソッド)には、
+ <function>include_once</function>を使用して下さい。どちらの場合も
+
+クラスファイルが一度だけ読み込まれるようにして下さい。これらの手法
+
+は、同じファイルリストを共有しているため、これらを混用することを心
+ 配する必要はありません。つまり、あるファイルを
+ <function>require_once</function> で読み込むと、
+ <function>include_once</function>で再度読み込まれることはありませ
+ ん。
<note>
<simpara>
- <function>include_once</function> and
- <function>require_once</function> are statements, not
- functions. You don't <emphasis>need</emphasis> parentheses
- around the filename to be included.
+ <function>include_once</function> と
+ <function>require_once</function> は命令であり、関数ではありませ
+ ん。読み込むファイル名の前後に括弧は必要ありません。
</simpara>
</note>
</para>
@@ -176,18 +175,19 @@
<sect1 id="pear.standards.tags">
<title>PHPコードのタグ</title>
<para>
- <emphasis>Always</emphasis> use <literal><?php ?></literal> to
- delimit PHP code, not the <literal><? ?></literal> shorthand.
- This is required for PEAR compliance and is also the most portable
- way to include PHP code on differing operating systems and setups.
+ PHPコードを記述する際に、短縮形の <literal><? ?></literal>
+では
+ なく <emphasis>常に</emphasis> <literal><?php ?></literal> を使
+
+用して下さい。これは、PEAR互換とするために必要であり、PHPコードを
+
+異なったシステムや設定で読み込む際に最も移植性のある手法でもありま
+ す。
</para>
</sect1>
<sect1 id="pear.standards.header">
<title>ヘッダのコメント部</title>
<para>
- All source code files in the core PEAR distribution should contain
- the following comment block as the header:
+
+PEARのコアな配布ファイルにある全てのソースコードファイルには、以下
+
+のようなコメントブロックがヘッダとして記述されています。
<programlisting role="php">
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
@@ -211,36 +211,36 @@
</programlisting>
</para>
<para>
- There's no hard rule to determine when a new code contributer
- should be added to the list of authors for a given source file.
- In general, their changes should fall into the "substantial"
- category (meaning somewhere around 10% to 20% of code changes).
- Exceptions could be made for rewriting functions or contributing
- new logic.
+
+新たなコードに貢献した人が、ソースファイル中の作者リストに追加され
+
+るかどうかを定義する明確なルールはありません。一般に、行った変更が
+
+「本質的な」区分に属する場合(よよそ10%から20%のコード変更を意味し
+
+ます)に行われます。関数を書き直したり、新たなロジックを作成した場
+ 合にはこの例外となる場合があります。
</para>
<para>
- Simple code reorganization or bug fixes would not justify the
- addition of a new individual to the list of authors.
+
+簡単なコードの再構成やバグ修正は、作者のリストへ新たに人を追加する
+ にはあたらないと思われます。
</para>
<para>
- Files not in the core PEAR repository should have a similar block
- stating the copyright, the license, and the authors. All files
- should include the modeline comments to encourage consistency.
+
+PEARのコアなレポジトリにないファイルも同様に著作権、ライセンス、作
+
+者に関する記述を行う必要があります。全てのファイルには、互換性を保
+
+つために、モード指定用のコメントを挿入しておくべきです。
</para>
</sect1>
<sect1 id="pear.standards.cvstags">
<title>CVS タグ</title>
<para>
- Include the $Id$ CVS vendor tag in each file. As each file
- is edited, add this tag if it's not yet present (or replace
- existing forms such as "Last Modified:", etc.).
+ 各ファイルには、CVSベンダータグ $Id$
+を挿入して下さ
+
+い。各ファイルを編集した際に、まだない場合にはこのタグを追加して下
+ さい。(もしくは、 "Last
+Modified:"のような既存の形式を置換して下さ
+ い。)
<note>
<simpara>
- We have a custom $Horde tag in Horde cvs to track our versions
- seperately; we could do the same and make a $PEAR tag, that
- would remain even if PEAR files were put into another source
- control system, etc...]
+ Horde cvs には、べージョンを別個に管理するために特別な
+$Horde タ
+
+グがあります。同様に$PEARタグを作成することもできます。この場合、
+
+PEARファイルが他のソースコード管理システム等に処理された場合でも、
+ タグは保持されます。
</simpara>
</note>
</para>
@@ -249,18 +249,17 @@
<sect1 id="pear.standards.exampleurls">
<title>URLの例</title>
<para>
- Use "example.com" for all example URLs, per RFC 2606.
+ RFC 2606に基づき、例えば"example.com" のようにして下さい。
</para>
</sect1>
<sect1 id="pear.standards.constants">
<title>定数の名前</title>
<para>
- Constants should always be uppercase, with underscores to seperate
- words. Prefix constant names with the name of the class/package
- they are used in. For example, the constants used by the
- <literal>DB::</literal> package all begin with
- "<literal>DB_</literal>".
+
+定数は常に大文字とし、単語を区切るさいには、アンダースコアを使用し
+
+て下さい。含まれているクラス/パッケージの名前を定数の接頭辞として
+
+付けて下さい。例えば、<literal>DB::</literal>パッケージで使用され
+ る定数は全て"<literal>DB_</literal>"で始まります。
</para>
</sect1>