svn: /phpdoc/ja/trunk/language/ oop5/traits.xml types/array.xml
| From: | Satoru Yoshida | Date: | Sat, 06 May 2017 15:05:25 +0000 |
| Subject: | svn: /phpdoc/ja/trunk/language/ oop5/traits.xml types/array.xml | ||
| Groups: | php.doc.ja | ||
| Request: | Send a blank email to doc-ja+get-4693@lists.php.net to get a copy of this message | ||
satoruyoshida Sat, 06 May 2017 15:05:25 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=342456
Log:
sync en
Changed paths:
U phpdoc/ja/trunk/language/oop5/traits.xml
U phpdoc/ja/trunk/language/types/array.xml
Modified: phpdoc/ja/trunk/language/oop5/traits.xml
===================================================================
--- phpdoc/ja/trunk/language/oop5/traits.xml 2017-05-06 01:15:48 UTC (rev 342455)
+++ phpdoc/ja/trunk/language/oop5/traits.xml 2017-05-06 15:05:25 UTC (rev 342456)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 339838 Maintainer: takagi Status: ready -->
+<!-- EN-Revision: 342154 Maintainer: takagi Status: working -->
<sect1 xml:id="language.oop5.traits" xmlns="http://docbook.org/ns/docbook">
<title>トレイト</title>
<para>
@@ -19,7 +19,6 @@
昔ながらの継承に機能を加えて、振る舞いを水平方向で構成できるようになります。
つまり、継承しなくてもクラスのメンバーに追加できるようになります。
</para>
-
<example xml:id="language.oop5.traits.basicexample">
<title>トレイトの例</title>
<programlisting role="php">
@@ -238,6 +237,14 @@
]]>
</programlisting>
</example>
+ <note>
+ <para>
+ <!-- to be translated -->
+ Prior to PHP 7.0, defining a property in a class with the same name as in a trait
+ would throw an <constant>E_STRICT</constant> if the class definition was
compatible
+ (same visibility and initial value).
+ </para>
+ </note>
</sect2>
<sect2 xml:id="language.oop5.traits.visibility">
@@ -433,9 +440,11 @@
</example>
<para>
トレイトでプロパティを定義したときは、クラスでは同じ名前のプロパティを定義できません。
-
定義しようとすると、エラーが発生します。クラス側での定義がトレイトでの定義と互換性がある
- (可視性も初期値も同じ) 場合は <constant>E_STRICT</constant>、
- それ以外の場合は fatal error となります。
+ <!-- to be translated -->
+ unless it is compatible (same visibility and initial value),
+ otherwise a fatal error is issued.
+ Before PHP 7.0.0, defining a property in the class with the same visibility
+ and initial value as in the trait, raised an E_STRICT notice.
</para>
<example xml:id="language.oop5.traits.properties.conflicts">
<title>衝突の解決</title>
@@ -449,7 +458,7 @@
class PropertiesExample {
use PropertiesTrait;
- public $same = true; // Strict Standards
+ public $same = true; // Allowed as of PHP 7.0.0; E_STRICT notice formerly
public $different = true; // Fatal error
}
?>
Modified: phpdoc/ja/trunk/language/types/array.xml
===================================================================
--- phpdoc/ja/trunk/language/types/array.xml 2017-05-06 01:15:48 UTC (rev 342455)
+++ phpdoc/ja/trunk/language/types/array.xml 2017-05-06 15:05:25 UTC (rev 342456)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 340030 Maintainer: takagi Status: ready -->
+<!-- EN-Revision: 341143 Maintainer: takagi Status: ready -->
<!-- CREDITS: hirokawa,shimooka -->
<sect1 xml:id="language.types.array">
<title>配列</title>
@@ -589,9 +589,8 @@
<para>
これは間違っていますが、動作します。では、なぜ間違っているのでしょう?
- その理由は、このコードには文字列 ('bar' -
引用符で括られている)
- ではなく未定義の定数 (bar) が使用されており、PHP
-
が同じ名前の定数を不幸にして同じコードの中に定義する可能性があるためです。
+ それは、このコードには文字列 (<literal>'bar'</literal> -
引用符で括られている)
+ ではなく未定義の定数 (<literal>bar</literal>)
が使用されているためです。
下位互換性の維持のため、未定義の定数は同じ名前の文字列に自動的に変換されます。
そのため、このコードは動作します。
例えば、<constant>bar</constant>
という名前の定義されていない定数があるとすると、
@@ -982,8 +981,7 @@
</example>
<para>
- PHP 5
以降では、配列を参照渡しすることでその値を直接変更できるようになりました。
- それ以前のバージョンでは、以下のような回避策が必要です。
+ 配列を参照渡しすることでその値を直接変更できます。
</para>
<example xml:id="language.types.array.examples.changeloop">
@@ -991,18 +989,12 @@
<programlisting role="php">
<![CDATA[
<?php
-// PHP 5
foreach ($colors as &$color) {
$color = strtoupper($color);
}
unset($color); /* これ以降の $color への書き込みが
配列の要素を書き換えてしまわないことを保証する */
-// 旧バージョンでの回避策
-foreach ($colors as $key => $color) {
- $colors[$key] = strtoupper($color);
-}
-
print_r($colors);
?>
]]>