diff --git a/language/oop5/anonymous.xml b/language/oop5/anonymous.xml index e2281847d315..a551897f0f7b 100644 --- a/language/oop5/anonymous.xml +++ b/language/oop5/anonymous.xml @@ -153,11 +153,11 @@ same class - + 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. - + - + The spl_autoload_register 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. - + Any class-like construct may be autoloaded the same way. That includes classes, interfaces, traits, and enumerations. - + Prior to PHP 8.0.0, it was possible to use __autoload to autoload classes and interfaces. However, it is a less flexible alternative to spl_autoload_register and __autoload is deprecated as of PHP 7.2.0, and removed as of PHP 8.0.0. - + diff --git a/language/oop5/changelog.xml b/language/oop5/changelog.xml index bc711a7c29e9..00dd1bb97d99 100644 --- a/language/oop5/changelog.xml +++ b/language/oop5/changelog.xml @@ -43,7 +43,7 @@ 7.4.0 - Changed: It is now possible to throw exception within + Changed: It is now possible to throw an exception within __toString. @@ -299,7 +299,7 @@ echo or print. But now, it is called in any &string; context (e.g. in printf with %s modifier) but not - in other types contexts (e.g. with %d modifier). + in other type contexts (e.g. with %d modifier). As of PHP 5.2.0, converting &object;s without a __toString method to &string; emits a E_RECOVERABLE_ERROR level error. diff --git a/language/oop5/cloning.xml b/language/oop5/cloning.xml index 836cd0babcc0..5b7b91cfed02 100644 --- a/language/oop5/cloning.xml +++ b/language/oop5/cloning.xml @@ -3,17 +3,17 @@ Object Cloning - + 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. - + An object copy is created by using the clone keyword @@ -40,11 +40,11 @@ $copy_of_object = clone $object; - + Once the cloning is complete, if a __clone() method is defined, then the newly created object's __clone() method will be called, to allow any - necessary properties that need to be changed. - + necessary properties to be changed. + Cloning an object diff --git a/language/oop5/constants.xml b/language/oop5/constants.xml index cf4ac7b47e41..ba5449c0f28f 100644 --- a/language/oop5/constants.xml +++ b/language/oop5/constants.xml @@ -2,11 +2,11 @@ Class Constants - + It is possible to define constants - on a per-class basis remaining the same and unchangeable. + on a per-class basis. The default visibility of class constants is public. - + Class constants can be redefined by a child class. diff --git a/language/oop5/decon.xml b/language/oop5/decon.xml index dd17425e800c..ccea97efc23a 100644 --- a/language/oop5/decon.xml +++ b/language/oop5/decon.xml @@ -156,11 +156,11 @@ class Point { - - Object properties may not be typed callable due to engine ambiguity that would + + Object properties may not be typed callable due to engine ambiguity that this would introduce. Promoted arguments, therefore, may not be typed callable either. Any other type declaration is permitted, however. - + @@ -352,7 +352,7 @@ $obj = new MyDestructableClass(); a second time when the reference count reaches zero again or during the shutdown sequence. - + As of PHP 8.4.0, when cycle collection occurs during the execution of a @@ -364,9 +364,9 @@ $obj = new MyDestructableClass(); The previous gc_destructor_fiber 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. - + Destructors called during the script shutdown have HTTP headers already diff --git a/language/oop5/inheritance.xml b/language/oop5/inheritance.xml index 445fa5930463..e49ab4a36693 100644 --- a/language/oop5/inheritance.xml +++ b/language/oop5/inheritance.xml @@ -26,16 +26,16 @@ restriction that is enforced is private final constructors, as that is a common way to "disable" the constructor when using static factory methods instead. - + The visibility of methods, properties and constants can be relaxed, e.g. a protected method can be marked as public, but they cannot be restricted, e.g. marking a public property as private. - An exception are constructors, whose visibility can be restricted, e.g. + One exception is constructors, whose visibility can be restricted, e.g. a public constructor can be marked as private in a child class. - + diff --git a/language/oop5/interfaces.xml b/language/oop5/interfaces.xml index 3979da93a2ba..b4fe86d4dd6a 100644 --- a/language/oop5/interfaces.xml +++ b/language/oop5/interfaces.xml @@ -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 Iterable, Cacheable, Renderable, - or so on to describe the significance of the behavior. + and so on to describe the significance of the behavior. diff --git a/language/oop5/iterations.xml b/language/oop5/iterations.xml index 7266838fb1f2..f15b1ee419c5 100644 --- a/language/oop5/iterations.xml +++ b/language/oop5/iterations.xml @@ -2,14 +2,12 @@ Object Iteration - - + 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 visible properties will be used for the iteration. - - + Simple Object Iteration diff --git a/language/oop5/late-static-bindings.xml b/language/oop5/late-static-bindings.xml index 60fb5cf41e74..01a637c91330 100644 --- a/language/oop5/late-static-bindings.xml +++ b/language/oop5/late-static-bindings.xml @@ -2,10 +2,10 @@ Late Static Bindings - + PHP implements a feature called late static bindings which - can be used to reference the called class in a context of static inheritance. - + can be used to reference the called class in the context of static inheritance. + More precisely, late static bindings work by storing the class named in the diff --git a/language/oop5/magic.xml b/language/oop5/magic.xml index 425f3c0a6c6f..c37257eed24c 100644 --- a/language/oop5/magic.xml +++ b/language/oop5/magic.xml @@ -2,13 +2,13 @@ Magic Methods - - Magic methods are special methods which override PHP's default's action + + Magic methods are special methods which override PHP's default action when certain actions are performed on an object. - + - All methods names starting with __ are reserved by PHP. + All method names starting with __ are reserved by PHP. Therefore, it is not recommended to use such method names unless overriding PHP's behavior. @@ -549,8 +549,9 @@ object(A)#2 (2) { internal classes. - 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 __set_state will + be re-imported. diff --git a/language/oop5/object-comparison.xml b/language/oop5/object-comparison.xml index a47afaccf40e..d3cff6988ab6 100644 --- a/language/oop5/object-comparison.xml +++ b/language/oop5/object-comparison.xml @@ -96,10 +96,10 @@ o1 !== o2 : TRUE - - Extensions can define own rules for their objects comparison + + Extensions can define their own rules for comparing their objects (==). - + Objects and references - - 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. + + 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. - + A PHP reference is an alias, which allows two different variables to write diff --git a/language/oop5/serialization.xml b/language/oop5/serialization.xml index a141530a9ab6..1965bf999d2c 100644 --- a/language/oop5/serialization.xml +++ b/language/oop5/serialization.xml @@ -15,18 +15,18 @@ the class. - + In order to be able to unserialize 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 spl_autoload_register function. - + @@ -66,14 +66,14 @@ - + 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 __PHP_Incomplete_Class_Name, which has no methods and would render the object useless. - + So if in the example above $a became part of a session diff --git a/language/oop5/traits.xml b/language/oop5/traits.xml index 2fab3a7290a0..b9866d6e2b4d 100644 --- a/language/oop5/traits.xml +++ b/language/oop5/traits.xml @@ -209,12 +209,12 @@ Hello World! Conflict Resolution - + In this example, Talker uses the traits A and B. - Since A and B have conflicting methods, it defines to use + Since A and B have conflicting methods, it specifies that it uses the variant of smallTalk from trait B, and the variant of bigTalk from trait A. - + The Aliased_Talker makes use of the as operator to be able to use B's bigTalk implementation under an additional alias diff --git a/language/oop5/variance.xml b/language/oop5/variance.xml index 79d19ea47187..22cfd92b529a 100644 --- a/language/oop5/variance.xml +++ b/language/oop5/variance.xml @@ -40,17 +40,17 @@ - A type class is considered less specific if the opposite is true. + A type declaration is considered less specific if the opposite is true. Covariance - + To illustrate how covariance works, a simple abstract parent class, Animal - is created. Animal will be extended by children classes, + is created. Animal will be extended by child classes, Cat, and Dog. - +