-
Notifications
You must be signed in to change notification settings - Fork 156
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
Rewrite real examples to PHP 8.2 #39
Comments
To be frank with you, I think the original version is more obvious. However, I might simply need some time getting used to the new syntax. Btw, maybe breaking down the parameters into multiple lines would help, but I'm not sure whether this is allowed per coding convention. |
P.S. Sorry, I forgot to thank you for the offer. I appreciate it very much, but I'm on the fence whether we should do this particular change at the moment. |
Yes, it's allowed and it looks like the code below: class SlackNotification implements Notification
{
public function __construct(
private readonly SlackApi $slack,
private readonly string $chatId
) {
}
public function send(string $title, string $message): void
{
$slackMessage = "#" . $title . "# " . strip_tags($message);
$this->slack->logIn();
$this->slack->sendMessage($this->chatId, $slackMessage);
}
}
Sure, no problem. If you'll ready to make some changes, then we can continue this thread :) |
Hi, PHP 8.2 is the current version, and PHP 8.3 will come faster than we all think, therefore I want to start a new discussion, whether we should rewrite code samples to PHP 8.2 and start using "constructor property promotion" or not. What do you think about it?
Example Adapter code with constructor property promotion:
The text was updated successfully, but these errors were encountered: