From dea71e83b465b49721b39c411bee2f659e1de534 Mon Sep 17 00:00:00 2001 From: Roman Martinuk Date: Tue, 13 Apr 2021 00:29:24 +0300 Subject: [PATCH] PHP 8 --- Behavioral/Interpreter/AndExp.php | 9 ++------- Behavioral/Interpreter/OrExp.php | 7 +------ Behavioral/Interpreter/VariableExp.php | 5 +---- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Behavioral/Interpreter/AndExp.php b/Behavioral/Interpreter/AndExp.php index 9715ddb..68b126d 100644 --- a/Behavioral/Interpreter/AndExp.php +++ b/Behavioral/Interpreter/AndExp.php @@ -4,17 +4,12 @@ namespace DesignPatterns\Behavioral\Interpreter; class AndExp extends AbstractExp { - private AbstractExp $first; - private AbstractExp $second; - - public function __construct(AbstractExp $first, AbstractExp $second) + public function __construct(private AbstractExp $first, private AbstractExp $second) { - $this->first = $first; - $this->second = $second; } public function interpret(Context $context): bool { - return (bool) $this->first->interpret($context) && $this->second->interpret($context); + return $this->first->interpret($context) && $this->second->interpret($context); } } diff --git a/Behavioral/Interpreter/OrExp.php b/Behavioral/Interpreter/OrExp.php index db3ba1b..5245424 100644 --- a/Behavioral/Interpreter/OrExp.php +++ b/Behavioral/Interpreter/OrExp.php @@ -4,13 +4,8 @@ namespace DesignPatterns\Behavioral\Interpreter; class OrExp extends AbstractExp { - private AbstractExp $first; - private AbstractExp $second; - - public function __construct(AbstractExp $first, AbstractExp $second) + public function __construct(private AbstractExp $first, private AbstractExp $second) { - $this->first = $first; - $this->second = $second; } public function interpret(Context $context): bool diff --git a/Behavioral/Interpreter/VariableExp.php b/Behavioral/Interpreter/VariableExp.php index f7fc871..202480d 100644 --- a/Behavioral/Interpreter/VariableExp.php +++ b/Behavioral/Interpreter/VariableExp.php @@ -4,11 +4,8 @@ namespace DesignPatterns\Behavioral\Interpreter; class VariableExp extends AbstractExp { - private string $name; - - public function __construct(string $name) + public function __construct(private string $name) { - $this->name = $name; } public function interpret(Context $context): bool