diff --git a/composer.json b/composer.json index c02ed1f..c77d6cc 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "keywords": ["console", "cli", "framework", "package", "tools"], "minimum-stability": "stable", "license": "MIT", - "version": "v2.1.0", + "version": "v2.1.1", "authors": [ { "name": "chop1k", diff --git a/docs/changelog.md b/docs/changelog.md index 6106548..91d8bf9 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,9 @@ # Changelog Here is a list of versions with changes from first to last. +## v2.1.1 +- Fixed bug where all arguments were ignored when using the default command. + ## v2.1.0 - Added FormatterInterface and Formatter with test: - DistributorInterface and Distributor: diff --git a/src/Distributor/Distributor.php b/src/Distributor/Distributor.php index c48447d..110deb3 100644 --- a/src/Distributor/Distributor.php +++ b/src/Distributor/Distributor.php @@ -34,9 +34,9 @@ class Distributor implements DistributorInterface /** * Contains a position of the command in the arguments. * - * @var int $commandPosition + * @var int|null $commandPosition */ - protected int $commandPosition; + protected ?int $commandPosition; /** * Contains a formatter instance. @@ -52,7 +52,7 @@ class Distributor implements DistributorInterface */ public function __construct(FormatterInterface $formatter) { - $this->commandPosition = 0; + $this->commandPosition = null; $this->formatter = $formatter; } @@ -189,7 +189,7 @@ protected function sortArguments(): array $values = []; for ($i = 0; $i < count($this->arguments); $i++) { - if ($i >= $this->commandPosition) { + if ($this->commandPosition !== null && $i >= $this->commandPosition) { break; } @@ -350,6 +350,6 @@ protected function handle(array $options, array $values, array $commandOptions, */ public function getNextArguments(): array { - return array_slice($this->arguments, $this->commandPosition + 1); + return ($this->commandPosition !== null) ? array_slice($this->arguments, $this->commandPosition + 1) : []; } }