language/oop5/abstract.xml
9ee9eccf455188ab6eb352194eb6f9eb99e15606
...
...
@@ -4,25 +4,19 @@
4
4
<title>Class Abstraction</title>
5
5

6
6
<para>
7
-
PHP 5 introduces abstract classes and methods. Classes defined as
8
-
abstract cannot be instantiated, and any class that
9
-
contains at least one abstract method must also be abstract. Methods
10
-
defined as abstract simply declare the method's signature - they cannot
11
-
define the implementation.
7
+
PHP has abstract classes and methods.
8
+
Classes defined as abstract cannot be instantiated, and any class that
9
+
contains at least one abstract method must also be abstract.
10
+
Methods defined as abstract simply declare the method's signature;
11
+
they cannot define the implementation.
12
12
</para>
13
13

14
14
<para>
15
15
When inheriting from an abstract class, all methods marked abstract in
16
-
the parent's class declaration must be defined by the child; additionally,
17
-
these methods must be defined with the same (or a less restricted)
18
-
<link linkend="language.oop5.visibility">visibility</link>. For example,
19
-
if the abstract method is defined as protected, the function implementation
20
-
must be defined as either protected or public, but not private. Furthermore
21
-
the signatures of the methods must match, i.e. the type hints and the number
22
-
of required arguments must be the same. For example, if the child class
23
-
defines an optional argument, where the abstract method's signature does
24
-
not, there is no conflict in the signature. This also applies to constructors
25
-
as of PHP 5.4. Before 5.4 constructor signatures could differ.
16
+
the parent's class declaration must be defined by the child class,
17
+
and follow the usual
18
+
<link linkend="language.oop5.inheritance">inheritance</link> and
19
+
<link linkend="language.oop.lsp">signature compatibility</link> rules.
26
20
</para>
27
21

28
22
<example>
...
...
@@ -127,13 +121,7 @@ Mrs. Pacwoman
127
121
]]>
128
122
</screen>
129
123
</example>
130
-

131
-
<para>
132
-
Old code that has no user-defined classes or functions named
133
-
'abstract' should run without modifications.
134
-
</para>
135
124
</sect1>
136
-

137
125
<!-- Keep this comment at the end of the file
138
126
Local variables:
139
127
mode: sgml
140
128