From c91ef660c8251a30d98c1344dc3973c84a99f973 Mon Sep 17 00:00:00 2001 From: Laurent Laville Date: Tue, 16 Apr 2024 12:28:41 +0000 Subject: [PATCH] apply Constructor Property Promotion (https://php.watch/versions/8.0/constructor-property-promotion) and Readonly Properties (https://php.watch/versions/8.1/readonly) --- src/Resource/Feed/Category.php | 5 +---- src/Resource/Feed/Package.php | 5 +---- src/Resource/Feed/User.php | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Resource/Feed/Category.php b/src/Resource/Feed/Category.php index 594413a..6bc2fa1 100644 --- a/src/Resource/Feed/Category.php +++ b/src/Resource/Feed/Category.php @@ -6,11 +6,8 @@ use SimpleXMLElement; final class Category extends News { - private string $categoryName; - - public function __construct(SimpleXMLElement $xml, string $name) { + public function __construct(SimpleXMLElement $xml, private readonly string $categoryName) { parent::__construct($xml); - $this->categoryName = $name; } public function getCategoryName(): string { diff --git a/src/Resource/Feed/Package.php b/src/Resource/Feed/Package.php index 83d2a41..f4a9008 100644 --- a/src/Resource/Feed/Package.php +++ b/src/Resource/Feed/Package.php @@ -6,11 +6,8 @@ use SimpleXMLElement; final class Package extends News { - private string $packageName; - - public function __construct(SimpleXMLElement $xml, string $name) { + public function __construct(SimpleXMLElement $xml, private readonly string $packageName) { parent::__construct($xml); - $this->packageName = $name; } public function getPackageName(): string { diff --git a/src/Resource/Feed/User.php b/src/Resource/Feed/User.php index 6f9fe0e..6cba4d8 100644 --- a/src/Resource/Feed/User.php +++ b/src/Resource/Feed/User.php @@ -6,11 +6,8 @@ use SimpleXMLElement; final class User extends News { - private string $userName; - - public function __construct(SimpleXMLElement $xml, string $name) { + public function __construct(SimpleXMLElement $xml, private readonly string $userName) { parent::__construct($xml); - $this->userName = $name; } public function getUserName(): string {