language/oop5/basic.xml
f94d903985119d3ac00f4528551df947f57b667f
...
...
@@ -139,7 +139,7 @@ Stack trace:
139
139
<classname>AllowDynamicProperties</classname> attribute. Attempting to do so
140
140
will trigger a compile-time error.
141
141
</para>
142
-
<example>
142
+
<informalexample>
143
143
<programlisting role="php">
144
144
<![CDATA[
145
145
<?php
...
...
@@ -151,14 +151,14 @@ readonly class Foo {
151
151
?>
152
152
]]>
153
153
</programlisting>
154
-
</example>
154
+
</informalexample>
155
155

156
156
<para>
157
-
As neither untyped, nor static properties can be marked with the
157
+
As neither untyped nor static properties can be marked with the
158
158
<literal>readonly</literal> modifier, readonly classes cannot declare
159
159
them either:
160
160
</para>
161
-
<example>
161
+
<informalexample>
162
162
<programlisting role="php">
163
163
<![CDATA[
164
164
<?php
...
...
@@ -183,7 +183,7 @@ readonly class Foo
183
183
?>
184
184
]]>
185
185
</programlisting>
186
-
</example>
186
+
</informalexample>
187
187
<para>
188
188
A <modifier>readonly</modifier> class can be
189
189
<link linkend="language.oop5.basic.extends">extended</link>
...
...
@@ -204,7 +204,7 @@ readonly class Foo
204
204
requirement).
205
205
</para>
206
206
<para>
207
-
If a <type>string</type> containing the name of a class is used with
207
+
If a variable containing a <type>string</type> with the name of a class is used with
208
208
<literal>new</literal>, a new instance of that class will be created. If
209
209
the class is in a namespace, its fully qualified name must be used when
210
210
doing this.
...
...
@@ -330,26 +330,27 @@ object(SimpleClass)#1 (1) {
330
330
<programlisting role="php">
331
331
<![CDATA[
332
332
<?php
333
+

333
334
class Test
334
335
{
335
-
static public function getNew()
336
+
public static function getNew()
336
337
{
337
-
return new static;
338
+
return new static();
338
339
}
339
340
}
340
341

341
-
class Child extends Test
342
-
{}
342
+
class Child extends Test {}
343
343

344
-
$obj1 = new Test();
345
-
$obj2 = new $obj1;
344
+
$obj1 = new Test(); // By the class name
345
+
$obj2 = new $obj1(); // Through the variable containing an object
346
346
var_dump($obj1 !== $obj2);
347
347

348
-
$obj3 = Test::getNew();
348
+
$obj3 = Test::getNew(); // By the class method
349
349
var_dump($obj3 instanceof Test);
350
350

351
-
$obj4 = Child::getNew();
351
+
$obj4 = Child::getNew(); // Through a child class method
352
352
var_dump($obj4 instanceof Child);
353
+

353
354
?>
354
355
]]>
355
356
</programlisting>
356
357