Skip to content

Commit

Permalink
support php 8 and typehints on abstract command
Browse files Browse the repository at this point in the history
  • Loading branch information
ppshobi committed Dec 11, 2022
1 parent 9a0871f commit 8d50eac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"search engine"
],
"require": {
"php": "^7.3|^8.0"
"php": "^8.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0|^9.0",
Expand Down
15 changes: 11 additions & 4 deletions src/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@

abstract class Command implements CommandInterface
{
private $command;
private $parameters;
private string $command;
/**
* @var array<mixed>
*/
private array $parameters;

public function __construct($command, $parameters = [])
/**
* @param array<mixed> $parameters
*/
public function __construct(string $command, array $parameters = [])
{
$this->command = $command;
$this->parameters = $parameters;
Expand All @@ -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;
Expand Down

0 comments on commit 8d50eac

Please sign in to comment.