Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding php8 constructor property promotion support #14

Closed
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
13 changes: 4 additions & 9 deletions src/Component/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@

class Currency extends Component
{
protected float $amount;

/**
* Currency code as defined in ISO 4217.
* @param float $amount
* @param string $code Currency code as defined in ISO 4217.
*/
protected string $code;

public function __construct(float $amount, string $code = 'EUR')
public function __construct(protected float $amount,protected string $code = 'EUR')
{
$this->amount = $amount;
$this->code = $code;
}

public function toArray(): array
Expand All @@ -27,4 +22,4 @@ public function toArray(): array
],
];
}
}
}
10 changes: 2 additions & 8 deletions src/Component/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@

class DateTime extends Component
{
protected \DateTimeImmutable $dateTime;

protected string $format;

public function __construct(\DateTimeImmutable $dateTime, string $format = 'Y-m-d H:i:s')
public function __construct(protected \DateTimeImmutable $dateTime,protected string $format = 'Y-m-d H:i:s')
{
$this->dateTime = $dateTime;
$this->format = $format;
}

public function toArray(): array
Expand All @@ -23,4 +17,4 @@ public function toArray(): array
],
];
}
}
}
8 changes: 3 additions & 5 deletions src/Component/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
class Image extends Component
{
/**
* @param string $link
* Link to the image; e.g. https://URL.
*/
protected string $link;

public function __construct(string $link)
public function __construct(protected string $link)
{
$this->link = $link;
}

public function toArray(): array
Expand All @@ -23,4 +21,4 @@ public function toArray(): array
],
];
}
}
}
7 changes: 2 additions & 5 deletions src/Component/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

class Text extends Component
{
protected string $text;

public function __construct(string $text)
public function __construct(protected string $text)
{
$this->text = $text;
}

public function toArray(): array
Expand All @@ -18,4 +15,4 @@ public function toArray(): array
'text' => $this->text,
];
}
}
}
7 changes: 3 additions & 4 deletions src/Component/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
class Video extends Component
{
/**
* @param string $link
* Link to the video; e.g. https://URL.
*/
protected string $link;

public function __construct(string $link)
public function __construct(protected string $link)
{
$this->link = $link;
}

public function toArray(): array
Expand All @@ -23,4 +22,4 @@ public function toArray(): array
],
];
}
}
}
6 changes: 2 additions & 4 deletions src/WhatsAppChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ class WhatsAppChannel
/*
* HTTP WhatsApp Cloud API wrapper
*/
private WhatsAppCloudApi $whatsapp;

public function __construct(WhatsAppCloudApi $whatsapp)
public function __construct(private WhatsAppCloudApi $whatsapp)
{
$this->whatsapp = $whatsapp;
}

/**
Expand Down Expand Up @@ -50,4 +48,4 @@ public function send($notifiable, Notification $notification): ?Response
throw CouldNotSendNotification::serviceRespondedWithAnError($e->response()->body());
}
}
}
}
Loading