svn: /phpdoc/de/trunk/language/predefined/ arrayaccess/offsetget.xml arrayaccess/offsetset.xml arrayaccess.xml

[email protected] (Nikita Popov)
Newsgroups php.doc.de
Message-ID <[email protected]>
nikic                                    Thu, 30 Jun 2011 13:17:15 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=312680

Log:
Sync DE ArrayAccess docs with EN

Changed paths:
    U   phpdoc/de/trunk/language/predefined/arrayaccess/offsetget.xml
    U   phpdoc/de/trunk/language/predefined/arrayaccess/offsetset.xml
    U   phpdoc/de/trunk/language/predefined/arrayaccess.xml

Modified: phpdoc/de/trunk/language/predefined/arrayaccess/offsetget.xml
===================================================================
--- phpdoc/de/trunk/language/predefined/arrayaccess/offsetget.xml	2011-06-30 13:16:27 UTC (rev 312679)
+++ phpdoc/de/trunk/language/predefined/arrayaccess/offsetget.xml	2011-06-30 13:17:15 UTC (rev 312680)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 289713 Maintainer: sammywg Status: ready -->
+<!-- EN-Revision: 305566 Maintainer: sammywg Status: ready -->

 <refentry xml:id="arrayaccess.offsetget" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
  <refnamediv>
@@ -39,6 +39,37 @@
   </para>

  </refsect1>
+
+ <refsect1 role="notes">
+  &reftitle.notes;
+  <note>
+   <para>
+    Beginnend mit PHP 5.3.4 kann <function>ArrayAccess::offsetGet</function>
+    per Referenz zurückgeben. Somit ist es möglich Array Offsets von
+    Objekten welche mit <classname>ArrayAccess</classname> überladen
+    wurden indirekt zu modifizieren.
+   </para>
+   <para>
+    Bei einer direkten Änderung wird der Wert eines Array Offsets
+    komplett ersetzt (beispielsweise <literal>$obj[6] = 7</literal>).
+    Bei einer indirekten Änderung wird nur ein Teil des Array
+    Offsets geändert (<literal>$obj[6][7] = 7</literal>) oder das
+    Array Offset einer Variablen per Referenz zugewiesen
+    (<literal>$var =&amp; $obj[6]</literal>). Auch Inkrementierung
+    mit <literal>++</literal> und Dekrementierung mit <literal>--</literal>
+    sind derartig implementiert, dass sie indirekte Änderung erfordern.
+   </para>
+   <para>
+    Direkte Änderungen führen zu einem Aufruf von
+    <function>ArrayAccess::offsetSet</function>, wohingegen indirekte
+    Änderungen in einem Aufruf von <function>ArrayAccess::offsetGet</function>
+    resultieren. In diesem Fall muss die Implementierung von
+    <function>ArrayAccess::offsetGet</function> in der Lage sein per Referenz
+    zurückzugeben, ansonsten wird ein <constant>E_NOTICE</constant> Fehler
+    generiert.
+   </para>
+  </note>
+ </refsect1>

  <refsect1 role="returnvalues">
   &reftitle.returnvalues;

Modified: phpdoc/de/trunk/language/predefined/arrayaccess/offsetset.xml
===================================================================
--- phpdoc/de/trunk/language/predefined/arrayaccess/offsetset.xml	2011-06-30 13:16:27 UTC (rev 312679)
+++ phpdoc/de/trunk/language/predefined/arrayaccess/offsetset.xml	2011-06-30 13:17:15 UTC (rev 312680)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 291256 Maintainer: sammywg Status: ready -->
+<!-- EN-Revision: 305489 Maintainer: sammywg Status: ready -->

 <refentry xml:id="arrayaccess.offsetset" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
  <refnamediv>
@@ -63,13 +63,37 @@
      <programlisting role="php">
 <![CDATA[
 <?php
-$arrayaccess[] = "Wert";
+$arrayaccess[] = "Erster Wert";
+$arrayaccess[] = "Zweiter Wert";
+print_r($arrayaccess);
 ?>
 ]]>
      </programlisting>
+     &example.outputs;
+     <screen>
+<![CDATA[
+Array
+(
+    [0] => Erster Wert
+    [1] => Zweiter Wert
+)
+]]>
+     </screen>
     </informalexample>
    </para>
   </note>
+
+  <note>
+   <para>
+    Diese Funktion wird nicht aufgerufen, wenn einer Variable ein Array
+    Offset per Referenz zugewiesen wird oder eine andere indirekte
+    Änderungen eines Array Offsets stattfindet (wenn beispielsweise
+    nur ein Sub-Offset oder eine Sub-Eigenschaft geändert wird).
+    Stattdessen wird <function>ArrayAccess::offsetGet</function>
+    aufgerufen. Die Operation wird nur erfolgreich sein, wenn jene Methode
+    per Referenz uzrückgibt, was erst seit PHP 5.3.4 möglich ist.
+   </para>
+  </note>
  </refsect1>

 <!--

Modified: phpdoc/de/trunk/language/predefined/arrayaccess.xml
===================================================================
--- phpdoc/de/trunk/language/predefined/arrayaccess.xml	2011-06-30 13:16:27 UTC (rev 312679)
+++ phpdoc/de/trunk/language/predefined/arrayaccess.xml	2011-06-30 13:17:15 UTC (rev 312680)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 292734 Maintainer: sammywg Status: ready -->
+<!-- EN-Revision: 301180 Maintainer: sammywg Status: ready -->

 <phpdoc:classref xml:id="class.arrayaccess" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">

@@ -56,7 +56,11 @@
         );
     }
     public function offsetSet($offset, $value) {
-        $this->container[$offset] = $value;
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
     }
     public function offsetExists($offset) {
         return isset($this->container[$offset]);
@@ -77,7 +81,10 @@
 var_dump(isset($obj["zwei"]));
 $obj["zwei"] = "Ein Wert";
 var_dump($obj["zwei"]);
-
+$obj[] = 'Anhängen 1';
+$obj[] = 'Anhängen 2';
+$obj[] = 'Anhängen 3';
+print_r($obj);
 ?>
 ]]>
     </programlisting>
@@ -88,6 +95,19 @@
 int(2)
 bool(false)
 string(7) "Ein Wert"
+obj Object
+(
+    [container:obj:private] => Array
+        (
+            [eins] => 1
+            [drei] => 3
+            [zwei] => Ein Wert
+            [0] => Anhängen 1
+            [1] => Anhängen 2
+            [2] => Anhängen 3
+        )
+
+)
 ]]>
     </screen>
    </example><!-- }}} -->
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.