language/predefined/iteratoraggregate.xml
20b4b383127faaf37495d7746885f2bb674a1a33
...
...
@@ -40,32 +40,38 @@
40
40
</section>
41
41

42
42
<section xml:id="iteratoraggregate.examples">
43
+
&reftitle.examples;
43
44
<example xml:id="iteratoraggregate.example.basic"><!-- {{{ -->
44
45
<title>Basic usage</title>
45
46
<programlisting role="php">
46
47
<![CDATA[
47
48
<?php
48
-
class myData implements IteratorAggregate {
49
+

50
+
class myData implements IteratorAggregate
51
+
{
49
52
public $property1 = "Public property one";
50
53
public $property2 = "Public property two";
51
54
public $property3 = "Public property three";
52
55
public $property4 = "";
53
56

54
-
public function __construct() {
57
+
public function __construct()
58
+
{
55
59
$this->property4 = "last property";
56
60
}
57
61

58
-
public function getIterator(): Traversable {
62
+
public function getIterator(): Traversable
63
+
{
59
64
return new ArrayIterator($this);
60
65
}
61
66
}
62
67

63
-
$obj = new myData;
68
+
$obj = new myData();
64
69

65
-
foreach($obj as $key => $value) {
70
+
foreach ($obj as $key => $value) {
66
71
var_dump($key, $value);
67
72
echo "\n";
68
73
}
74
+

69
75
?>
70
76
]]>
71
77
</programlisting>
72
78