Skip to content

Commit

Permalink
Merge pull request #8 from chop1k/v2.1.1-dev
Browse files Browse the repository at this point in the history
v2.1.1
  • Loading branch information
chop1k authored Apr 19, 2021
2 parents cd8b555 + 7ac6cae commit c534e7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 5 additions & 5 deletions src/Distributor/Distributor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -52,7 +52,7 @@ class Distributor implements DistributorInterface
*/
public function __construct(FormatterInterface $formatter)
{
$this->commandPosition = 0;
$this->commandPosition = null;
$this->formatter = $formatter;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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) : [];
}
}

0 comments on commit c534e7d

Please sign in to comment.