Modified: phpdoc/ja/trunk/language/namespaces.xml =================================================================== --- phpdoc/ja/trunk/language/namespaces.xml 2017-05-07 01:27:51 UTC (rev 342457) +++ phpdoc/ja/trunk/language/namespaces.xml 2017-05-07 02:38:00 UTC (rev 342458) @@ -1,6 +1,6 @@ - + 名前空間 @@ -904,45 +904,76 @@ + + + Relative name + + + This is an identifier starting with namespace, such as + namespace\Foo\Bar. + + + 名前解決は、これらの解決ルールによって行われます。 + - 完全修飾された関数、クラス、定数へのコールはコンパイル時に解決されます。 - たとえば、new \A\B は A\B クラスと解釈されます。 + Fully qualified names always resolve to the name without leading namespace separator. + たとえば、\A\B は A\B と解釈されます。 + - 非修飾名および (完全修飾でない) 修飾名の変換は、現在のインポートルールに基づいてコンパイル時に行われます。 - たとえば、名前空間 A\B\C が - C という名前でインポートされている場合、 - C\D\e() へのコールは A\B\C\D\e() - と変換されます。 + Relative names always resolve to the name with namespace replaced by + the current namespace. If the name occurs in the global namespace, the + namespace\ prefix is stripped. For example namespace\A + inside namespace X\Y resolves to X\Y\A. The same name + inside the global namespace resolves to A. - 名前空間内で、インポートルールによる変換が行われなかった修飾名は - 現在の名前空間が先頭に付加されます。たとえば、 - C\D\e() へのコールが名前空間 A\B - 内で行われた場合、それは A\B\C\D\e() に変換されます。 + For qualified names the first segment of the name is translated according to the current + class/namespace import table. For example, if the namespace A\B\C is + imported as C, the name C\D\E is translated to + A\B\C\D\E. - 非修飾クラス名の変換は、現在のインポートルールに基づいてコンパイル時に行われます - (インポートされた短い名前がフルネームに置き換わります)。たとえば、 - 名前空間 A\B\C が C という名前でインポートされている場合、 - new C() は new A\B\C() と変換されます。 + For qualified names, if no import rule applies, the current namespace is prepended to the + name. For example, the name C\D\E inside namespace A\B, + resolves to A\B\C\D\E. - 名前空間内 (ここでは A\B としましょう) で、非修飾な関数へのコールは実行時に解決されます。 + For unqualified names, the name is translated according to the current import table for the + respective symbol type. This means that class-like names are translated according to the + class/namespace import table, function names according to the function import table and + constants according to the constant import table. For example, after + use A\B\C; a usage such as new C() resolves to the name + A\B\C(). Similarly, after use function A\B\fn; a usage + such as fn() resolves to the name A\B\fn. + + + + + For unqualified names, if no import rule applies and the name refers to a class-like symbol, + the current namespace is prepended. For example new C() inside namespace + A\B resolves to name A\B\C. + + + + + For unqualified names, if no import rule applies and the name refers to a function or constant + and the code is outside the global namespace, the name is resolved at runtime. + Assuming the code is in namespace A\B, 関数 foo() のコールは、次のように解決されます。 @@ -960,48 +991,6 @@ - - - 名前空間内 (ここでは A\B としましょう) で、 - 非修飾あるいは (完全修飾でない) 修飾なクラスへのコールは実行時に解決されます。 - new C() や new D\E() - がどのように解決されるかを示します。 - new C() の場合は、 - - - - - まず現在の名前空間からクラス - A\B\C を探します。 - - - - - A\B\C を autoload します。 - - - - - new D\E() の場合は、 - - - - - 現在の名前空間を先頭につけた - A\B\D\E を探します。 - - - - - A\B\D\E を autoload します。 - - - - - グローバル名前空間内のグローバルクラスを参照するには、完全修飾形式の - new \C() を使わなければなりません。 - - Modified: phpdoc/ja/trunk/language/oop5/visibility.xml =================================================================== --- phpdoc/ja/trunk/language/oop5/visibility.xml 2017-05-07 01:27:51 UTC (rev 342457) +++ phpdoc/ja/trunk/language/oop5/visibility.xml 2017-05-07 02:38:00 UTC (rev 342458) @@ -1,12 +1,12 @@ - + アクセス権 - プロパティまたはメソッドのアクセス権 (visibility) は、 + プロパティ、メソッドまたは (PHP 7.1.0 以降) 定数のアクセス権 (visibility) は、 キーワード: public, protected または private を指定することにより定義できます。 public 宣言されたクラスのメンバーには、どこからでもアクセス可能です。 @@ -58,7 +58,7 @@ */ class MyClass2 extends MyClass { - // public および protected メソッドは再定義できますが、 + // public および protected プロパティは再定義できますが、 // private はできません。 public $public = 'Public2'; protected $protected = 'Protected2'; @@ -194,6 +194,73 @@ + + 定数のアクセス権 + + + As of PHP 7.1.0, class constants may be defined as public, private, or + protected. Constants declared without any explicit visibility + keyword are defined as public. + + + + Constant Declaration as of PHP 7.1.0 + +foo(); // Public, Protected and Private work + + +/** + * Define MyClass2 + */ +class MyClass2 extends MyClass +{ + // This is public + function foo2() + { + echo self::MY_PUBLIC; + echo self::MY_PROTECTED; + echo self::MY_PRIVATE; // Fatal Error + } +} + +$myclass2 = new MyClass2; +echo MyClass2::MY_PUBLIC; // Works +$myclass2->foo2(); // Public and Protected work, not Private +?> +]]> + + + + + 他のオブジェクトからのアクセス権