From e941b32a7863dc8d86dc0181daaba220e4389d23 Mon Sep 17 00:00:00 2001 From: ppshobi <8536607+ppshobi@users.noreply.github.com> Date: Sun, 11 Dec 2022 17:14:03 +0100 Subject: [PATCH] support php 8 and typehints on abstract command --- composer.json | 2 +- src/Commands/Command.php | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 35f4f6e..7ffb8a2 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "search engine" ], "require": { - "php": "^7.3|^8.0" + "php": "^8.0" }, "require-dev": { "phpunit/phpunit": "^7.0|^9.0", diff --git a/src/Commands/Command.php b/src/Commands/Command.php index e3a32fa..b8f3991 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -6,10 +6,16 @@ abstract class Command implements CommandInterface { - private $command; - private $parameters; + private string $command; + /** + * @var array + */ + private array $parameters; - public function __construct($command, $parameters = []) + /** + * @param array $parameters + */ + public function __construct(string $command, array $parameters = []) { $this->command = $command; $this->parameters = $parameters; @@ -18,8 +24,9 @@ public function __construct($command, $parameters = []) /** * Wrap the string in quotes, and normalize whitespace. Also remove double quotes. */ - protected function wrapInQuotes($string) + protected function wrapInQuotes(string $string):string { + /** @var string $string */ $string = preg_replace('/[\r\n\t"]/', ' ', $string); $string = '"' . str_replace('"', '\"', $string) . '"'; return $string;