Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions language/oop5/anonymous.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ same class
</informalexample>

<note>
<para>
<simpara>
Note that anonymous classes are assigned a name by the engine, as
demonstrated in the following example. This name has to be regarded an
demonstrated in the following example. This name has to be regarded as an
implementation detail, which should not be relied upon.
</para>
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
Expand Down
10 changes: 5 additions & 5 deletions language/oop5/autoload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
annoyances is having to write a long list of needed includes
at the beginning of each script (one for each class).
</para>
<para>
<simpara>
The <function>spl_autoload_register</function> function registers any number of
autoloaders, enabling for classes and interfaces to be automatically loaded
autoloaders, enabling classes and interfaces to be automatically loaded
if they are currently not defined. By registering autoloaders, PHP is given
a last chance to load the class or interface before it fails with an error.
</para>
</simpara>
<para>
Any class-like construct may be autoloaded the same way. That includes classes,
interfaces, traits, and enumerations.
</para>
<caution>
<para>
<simpara>
Prior to PHP 8.0.0, it was possible to use <function>__autoload</function>
to autoload classes and interfaces. However, it is a less flexible
alternative to <function>spl_autoload_register</function> and
<function>__autoload</function> is deprecated as of PHP 7.2.0, and removed
as of PHP 8.0.0.
</para>
</simpara>
</caution>
<note>
<para>
Expand Down
4 changes: 2 additions & 2 deletions language/oop5/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<row>
<entry>7.4.0</entry>
<entry>
Changed: It is now possible to throw exception within
Changed: It is now possible to throw an exception within
<function>__toString</function>.
</entry>
</row>
Expand Down Expand Up @@ -299,7 +299,7 @@
<function>echo</function> or <function>print</function>.
But now, it is called in any &string; context (e.g. in
<function>printf</function> with <literal>%s</literal> modifier) but not
in other types contexts (e.g. with <literal>%d</literal> modifier).
in other type contexts (e.g. with <literal>%d</literal> modifier).
As of PHP 5.2.0, converting &object;s without a
<link linkend="object.tostring">__toString</link> method to &string;
emits a <constant>E_RECOVERABLE_ERROR</constant> level error.
Expand Down
12 changes: 6 additions & 6 deletions language/oop5/cloning.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<sect1 xml:id="language.oop5.cloning" xmlns="http://docbook.org/ns/docbook">
<title>Object Cloning</title>

<para>
<simpara>
Creating a copy of an object with fully replicated properties is not
always the wanted behavior. A good example of the need for copy
constructors, is if you have an object which represents a GTK window and the
constructors is if you have an object which represents a GTK window and the
object holds the resource of this GTK window, when you create a duplicate
you might want to create a new window with the same properties and have the
new object hold the resource of the new window. Another example is if your
object holds a reference to another object which it uses and when you
replicate the parent object you want to create a new instance of this other
object so that the replica has its own separate copy.
</para>
</simpara>

<para>
An object copy is created by using the <literal>clone</literal> keyword
Expand All @@ -40,11 +40,11 @@ $copy_of_object = clone $object;
<void/>
</methodsynopsis>

<para>
<simpara>
Once the cloning is complete, if a <link linkend="object.clone">__clone()</link> method is defined, then
the newly created object's <link linkend="object.clone">__clone()</link> method will be called, to allow any
necessary properties that need to be changed.
</para>
necessary properties to be changed.
</simpara>

<example>
<title>Cloning an object</title>
Expand Down
6 changes: 3 additions & 3 deletions language/oop5/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<!-- $Revision$ -->
<sect1 xml:id="language.oop5.constants" xmlns="http://docbook.org/ns/docbook">
<title>Class Constants</title>
<para>
<simpara>
It is possible to define <link linkend="language.constants">constants</link>
on a per-class basis remaining the same and unchangeable.
on a per-class basis.
The default visibility of class constants is <literal>public</literal>.
</para>
</simpara>
<note>
<para>
Class constants can be redefined by a child class.
Expand Down
12 changes: 6 additions & 6 deletions language/oop5/decon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ class Point {
</para>
</note>
<note>
<para>
Object properties may not be typed <type>callable</type> due to engine ambiguity that would
<simpara>
Object properties may not be typed <type>callable</type> due to engine ambiguity that this would
introduce. Promoted arguments, therefore, may not be typed <type>callable</type> either. Any
other <link linkend="language.types.declarations">type declaration</link> is permitted, however.
</para>
</simpara>
</note>
<note>
<para>
Expand Down Expand Up @@ -352,7 +352,7 @@ $obj = new MyDestructableClass();
a second time when the reference count reaches zero again or during the
shutdown sequence.
</para>
<para>
<simpara>
As of PHP 8.4.0, when
<link linkend="features.gc.collecting-cycles">cycle collection</link>
occurs during the execution of a
Expand All @@ -364,9 +364,9 @@ $obj = new MyDestructableClass();
The previous <literal>gc_destructor_fiber</literal> will no longer be
referenced by the garbage collector and may be collected if it is not
referenced elsewhere.
Objects whose destructor are suspended will not be collected until the
Objects whose destructor is suspended will not be collected until the
destructor returns or the Fiber itself is collected.
</para>
</simpara>
<note>
<para>
Destructors called during the script shutdown have HTTP headers already
Expand Down
6 changes: 3 additions & 3 deletions language/oop5/inheritance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
restriction that is enforced is <literal>private final</literal> constructors, as that
is a common way to "disable" the constructor when using static factory methods instead.
</para>
<para>
<simpara>
The <link linkend="language.oop5.visibility">visibility</link>
of methods, properties and constants can be relaxed, e.g. a
<literal>protected</literal> method can be marked as
<literal>public</literal>, but they cannot be restricted, e.g.
marking a <literal>public</literal> property as <literal>private</literal>.
An exception are constructors, whose visibility can be restricted, e.g.
One exception is constructors, whose visibility can be restricted, e.g.
a <literal>public</literal> constructor can be marked as <literal>private</literal>
in a child class.
</para>
</simpara>

<note>
<para>
Expand Down
2 changes: 1 addition & 1 deletion language/oop5/interfaces.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
To allow a function or method to accept and operate on a parameter that conforms to an
interface, while not caring what else the object may do or how it is implemented. These interfaces
are often named like <literal>Iterable</literal>, <literal>Cacheable</literal>, <literal>Renderable</literal>,
or so on to describe the significance of the behavior.
and so on to describe the significance of the behavior.
</member>
</simplelist>
<para>
Expand Down
8 changes: 3 additions & 5 deletions language/oop5/iterations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
<!-- $Revision$ -->
<sect1 xml:id="language.oop5.iterations" xmlns="http://docbook.org/ns/docbook">
<title>Object Iteration</title>
<para>

<simpara>
PHP provides a way for objects to be defined so it is possible to iterate
through a list of items, with, for example a &foreach; statement. By default,
through a list of items with, for example, a &foreach; statement. By default,
all <link linkend="language.oop5.visibility">visible</link> properties will be used
for the iteration.

</para>
</simpara>

<example>
<title>Simple Object Iteration</title>
Expand Down
6 changes: 3 additions & 3 deletions language/oop5/late-static-bindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<!-- $Revision$ -->
<sect1 xml:id="language.oop5.late-static-bindings" xmlns="http://docbook.org/ns/docbook">
<title>Late Static Bindings</title>
<para>
<simpara>
PHP implements a feature called late static bindings which
can be used to reference the called class in a context of static inheritance.
</para>
can be used to reference the called class in the context of static inheritance.
</simpara>

<para>
More precisely, late static bindings work by storing the class named in the
Expand Down
13 changes: 7 additions & 6 deletions language/oop5/magic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<!-- $Revision$ -->
<sect1 xml:id="language.oop5.magic" xmlns="http://docbook.org/ns/docbook">
<title>Magic Methods</title>
<para>
Magic methods are special methods which override PHP's default's action
<simpara>
Magic methods are special methods which override PHP's default action
when certain actions are performed on an object.
</para>
</simpara>
<caution>
<simpara>
All methods names starting with <literal>__</literal> are reserved by PHP.
All method names starting with <literal>__</literal> are reserved by PHP.
Therefore, it is not recommended to use such method names unless overriding
PHP's behavior.
</simpara>
Expand Down Expand Up @@ -549,8 +549,9 @@ object(A)#2 (2) {
internal classes.
</simpara>
<simpara>
It is the responsibility of the programmer to verify that only objects will
be re-imported, whose class implements __set_state().
It is the responsibility of the programmer to verify that only objects
whose class implements <methodname>__set_state</methodname> will
be re-imported.
</simpara>
</note>
</sect2>
Expand Down
6 changes: 3 additions & 3 deletions language/oop5/object-comparison.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ o1 !== o2 : TRUE
</example>
</para>
<note>
<para>
Extensions can define own rules for their objects comparison
<simpara>
Extensions can define their own rules for comparing their objects
(<literal>==</literal>).
</para>
</simpara>
</note>
</sect1>
<!-- Keep this comment at the end of the file
Expand Down
6 changes: 3 additions & 3 deletions language/oop5/paamayim-nekudotayim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ OtherClass::doubleColon();
</programlisting>
</example>

<para>
<simpara>
When an extending class overrides the parent's definition of a method,
PHP will not call the parent's method. It's up to the extended class
on whether or not the parent's method is called. This also applies to <link
whether or not the parent's method is called. This also applies to <link
linkend="language.oop5.decon">Constructors and Destructors</link>, <link
linkend="language.oop5.overloading">Overloading</link>, and <link
linkend="language.oop5.magic">Magic</link> method definitions.
</para>
</simpara>

<example>
<title>Calling a parent's method</title>
Expand Down
10 changes: 5 additions & 5 deletions language/oop5/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
must be a <link linkend="language.constants">constant</link> value.
</para>
<note>
<para>
An obsolete way of declaring class properties, is by using the
<simpara>
An obsolete way of declaring class properties is by using the
<literal>var</literal> keyword instead of a modifier.
</para>
</simpara>
</note>
<note>
<simpara>
Expand Down Expand Up @@ -164,7 +164,7 @@ class Shape

$triangle = new Shape();
$triangle->setName("triangle");
$triangle->setNumberofSides(3);
$triangle->setNumberOfSides(3);
var_dump($triangle->getName());
var_dump($triangle->getNumberOfSides());

Expand Down Expand Up @@ -379,7 +379,7 @@ var_dump($test2->prop); // NULL
To handle arbitrary property names, the class should implement the magic
methods <link linkend="object.get">__get()</link> and
<link linkend="object.set">__set()</link>.
At last resort the class can be marked with the
As a last resort the class can be marked with the
<code>#[\AllowDynamicProperties]</code> attribute.
</simpara>
</warning>
Expand Down
6 changes: 3 additions & 3 deletions language/oop5/property-hooks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class Example
A property may implement zero, one, or both hooks as the situation requires.
All shorthand versions are mutually-independent.
That is, using a short-get with a long-set,
or a short-set with an explicit type, or so on is all valid.
a short-set with an explicit type, and so on is all valid.
</simpara>
<simpara>
On a backed property, omitting a <literal>get</literal> or <literal>set</literal>
Expand Down Expand Up @@ -379,7 +379,7 @@ class Person {
<sect2>
<title>References</title>
<simpara>
Because the presence of hooks intercept the read and write process for properties,
Because the presence of hooks intercepts the read and write process for properties,
they cause issues when acquiring a reference to a property or with indirect
modification, such as <code>$this->arrayProp['key'] = 'value';</code>.
That is because any attempted modification of the value by reference would bypass a set hook,
Expand Down Expand Up @@ -407,7 +407,7 @@ class Person {
</simpara>
<simpara>
Overwriting the entire array property is fine, and behaves the same as any other property.
Only working with elements of the array require special care.
Only working with elements of the array requires special care.
</simpara>
</sect2>
<sect2>
Expand Down
8 changes: 4 additions & 4 deletions language/oop5/references.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<!-- $Revision$ -->
<sect1 xml:id="language.oop5.references" xmlns="http://docbook.org/ns/docbook">
<title>Objects and references</title>
<para>
One of the key-points of PHP OOP that is often mentioned is that
"objects are passed by references by default". This is not completely true.
<simpara>
One of the key-points of PHP OOP that is often mentioned is that
"objects are passed by reference by default". This is not completely true.
This section rectifies that general thought using some examples.
</para>
</simpara>

<para>
A PHP reference is an alias, which allows two different variables to write
Expand Down
14 changes: 7 additions & 7 deletions language/oop5/serialization.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
the class.
</para>

<para>
<simpara>
In order to be able to <function>unserialize</function> an object, the
class of that object needs to be defined. That is, if you have an object
of class A and serialize this, you'll
of class A and serialize this, you'll
get a string that refers to class A and contains all values of variables
contained in it. If you want to be able to unserialize
this in another file, an object of class A, the
an object of class A in another file, the
definition of class A must be present in that file first.
This can be done for example by storing the class definition of class A
in an include file and including this file or making use of the
<function>spl_autoload_register</function> function.
</para>
</simpara>

<informalexample>
<programlisting role="php">
Expand Down Expand Up @@ -66,14 +66,14 @@
</programlisting>
</informalexample>

<para>
<simpara>
It is strongly recommended that if an application serializes objects, for use
later in the application, that the application includes the class definition
later in the application, the application includes the class definition
for that object throughout the application. Not doing so might result in an
object being unserialized without a class definition, which will result in
PHP giving the object a class of <classname>__PHP_Incomplete_Class_Name</classname>,
which has no methods and would render the object useless.
</para>
</simpara>

<para>
So if in the example above <varname>$a</varname> became part of a session
Expand Down
Loading