language/oop5/anonymous.xml
a9edd62d087ab1eb6292c795b7256e14ff9f1234
...
...
@@ -1,12 +1,10 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<sect1 xml:id="language.oop5.anonymous" xmlns="http://docbook.org/ns/docbook">
5
4
<title>Anonymous classes</title>
6
5

7
6
<para>
8
-
Support for anonymous classes was added in PHP 7. Anonymous classes are
9
-
useful when simple, one-off objects need to be created.
7
+
Anonymous classes are useful when simple, one-off objects need to be created.
10
8
</para>
11
9

12
10
<informalexample>
...
...
@@ -14,7 +12,7 @@
14
12
<![CDATA[
15
13
<?php
16
14

17
-
// Pre PHP 7 code
15
+
// Using an explicit class
18
16
class Logger
19
17
{
20
18
public function log($msg)
...
...
@@ -25,7 +23,7 @@ class Logger
25
23

26
24
$util->setLogger(new Logger());
27
25

28
-
// PHP 7+ code
26
+
// Using an anonymous class
29
27
$util->setLogger(new class {
30
28
public function log($msg)
31
29
{
...
...
@@ -176,7 +174,6 @@ class@anonymous/in/oNi1A0x7f8636ad2021
176
174
</informalexample>
177
175
</note>
178
176
</sect1>
179
-
180
177
<!-- Keep this comment at the end of the file
181
178
Local variables:
182
179
mode: sgml
183
180