Skip to content

Commit

Permalink
apply Constructor Property Promotion (https://php.watch/versions/8.0/…
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Apr 16, 2024
1 parent 21cf6d7 commit c91ef66
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/Resource/Feed/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions src/Resource/Feed/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions src/Resource/Feed/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c91ef66

Please sign in to comment.