Skip to content

Commit

Permalink
Fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Oct 27, 2024
1 parent 9abe633 commit 85b4d8d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
10 changes: 4 additions & 6 deletions src/Collection/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public function get(string $name): mixed
{
if ($this->has($name)) {
return $this->values[$name];
} else {
$this->throwNotFound($name);
}
throw $this->notFound($name);
}

public function has(string $name): bool
Expand All @@ -45,9 +44,8 @@ public function remove(string $name): void
{
if ($this->has($name)) {
unset($this->values[$name]);
} else {
$this->throwNotFound($name);
}
throw $this->notFound($name);
}

public function count(): int
Expand Down Expand Up @@ -77,8 +75,8 @@ public function getIterator()
return new \ArrayIterator($this->values);
}

protected function throwNotFound(string $name): void
protected function notFound(string $name): \InvalidArgumentException
{
throw new \InvalidArgumentException("Element \"$name\" not found in collection.");
return new \InvalidArgumentException("Element \"$name\" not found in collection.");
}
}
4 changes: 2 additions & 2 deletions src/Host/HostCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
class HostCollection extends Collection
{
protected function throwNotFound(string $name): void
protected function notFound(string $name): \InvalidArgumentException
{
throw new \InvalidArgumentException("Host \"$name\" not found.");
return new \InvalidArgumentException("Host \"$name\" not found.");
}
}
6 changes: 0 additions & 6 deletions src/Ssh/SshClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,4 @@ public function run(Host $host, string $command, array $config = []): string

return $output;
}

private function parseExitStatus(Process $process): int
{
preg_match('/\[exit_code:(\d*)]/', $process->getOutput(), $match);
return (int) ($match[1] ?? -1);
}
}
4 changes: 2 additions & 2 deletions src/Task/TaskCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
class TaskCollection extends Collection
{
protected function throwNotFound(string $name): void
protected function notFound(string $name): \InvalidArgumentException
{
throw new \InvalidArgumentException("Task `$name` not found.");
return new \InvalidArgumentException("Task `$name` not found.");
}

public function add(Task $task): void
Expand Down

0 comments on commit 85b4d8d

Please sign in to comment.