From 8d50eac70c2bc0d6111bb596f895723ac4637579 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 --- .github/workflows/tests.yml | 2 +- composer.json | 2 +- src/Commands/Command.php | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 34b2a0b..4ed432e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-versions: ['7.3', '7.4', '8.0'] + php-versions: ['8.0', '8.1', '8.2'] name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} steps: - name: Checkout 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;