From 5d8cf41f4e440d0b31e5e89ee601d05360366daa Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Mon, 25 Nov 2024 09:00:31 +0300 Subject: [PATCH 1/3] abstract.xml Fix the error in the last example and CS The only thing I'm not sure about is whether one empty line is required between the hooks that contain the implementation. With an empty string, readability seems to be better. If we imagine that hooks are the same as methods, then, perhaps, it is better to leave one empty string between the "methods" :) --- language/oop5/abstract.xml | 77 +++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/language/oop5/abstract.xml b/language/oop5/abstract.xml index af98d5ef66cb..376ecad1a1ab 100644 --- a/language/oop5/abstract.xml +++ b/language/oop5/abstract.xml @@ -36,47 +36,54 @@ getValue() . "\n"; } } class ConcreteClass1 extends AbstractClass { - protected function getValue() { + protected function getValue() + { return "ConcreteClass1"; } - public function prefixValue($prefix) { + public function prefixValue($prefix) + { return "{$prefix}ConcreteClass1"; } } class ConcreteClass2 extends AbstractClass { - public function getValue() { + public function getValue() + { return "ConcreteClass2"; } - public function prefixValue($prefix) { + public function prefixValue($prefix) + { return "{$prefix}ConcreteClass2"; } } -$class1 = new ConcreteClass1; +$class1 = new ConcreteClass1(); $class1->printOut(); -echo $class1->prefixValue('FOO_') ."\n"; +echo $class1->prefixValue('FOO_'), "\n"; -$class2 = new ConcreteClass2; +$class2 = new ConcreteClass2(); $class2->printOut(); -echo $class2->prefixValue('FOO_') ."\n"; +echo $class2->prefixValue('FOO_'), "\n"; + ?> ]]> @@ -96,18 +103,18 @@ FOO_ConcreteClass2 prefixName("Pacman"), "\n"; echo $class->prefixName("Pacwoman"), "\n"; + ?> ]]> @@ -138,35 +147,44 @@ Mrs. Pacwoman $value; } - // This expands the visibility from protected to public, which is fine. + // This expands the visibility from protected to public, which is fine public string $both; } + ?> ]]> @@ -180,15 +198,20 @@ class C extends A foo = $value }; + + set { + $this->foo = $value; + } } } + ?> ]]> From ccccc99841db23e592bf08bd0f71a829f23762d9 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Wed, 27 Nov 2024 06:19:35 +0300 Subject: [PATCH 2/3] Update language/oop5/abstract.xml Co-authored-by: Kamil Tekiela --- language/oop5/abstract.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/oop5/abstract.xml b/language/oop5/abstract.xml index 376ecad1a1ab..6dac14474d1a 100644 --- a/language/oop5/abstract.xml +++ b/language/oop5/abstract.xml @@ -112,7 +112,7 @@ abstract class AbstractClass class ConcreteClass extends AbstractClass { - // Our child class may define optional parameters not in the parent's signature + // Our child class may define optional parameters which are not present in the parent's signature public function prefixName($name, $separator = ".") { if ($name == "Pacman") { From 24b57e000837dcc99d8984c50a25f16566a697f6 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Wed, 27 Nov 2024 08:07:30 +0300 Subject: [PATCH 3/3] Update abstract.xml remove 'our' --- language/oop5/abstract.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/oop5/abstract.xml b/language/oop5/abstract.xml index 6dac14474d1a..c6122fcf59aa 100644 --- a/language/oop5/abstract.xml +++ b/language/oop5/abstract.xml @@ -106,13 +106,13 @@ FOO_ConcreteClass2 abstract class AbstractClass { - // Our abstract method only needs to define the required arguments + // An abstract method only needs to define the required arguments abstract protected function prefixName($name); } class ConcreteClass extends AbstractClass { - // Our child class may define optional parameters which are not present in the parent's signature + // A child class may define optional parameters which are not present in the parent's signature public function prefixName($name, $separator = ".") { if ($name == "Pacman") {