diff --git a/psalm.xml b/psalm.xml index 81388c1..05ade37 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ + + + + + + + + diff --git a/src/Command/AddCommandBuilder.php b/src/Command/AddCommandBuilder.php index 482abfe..2af7e1a 100644 --- a/src/Command/AddCommandBuilder.php +++ b/src/Command/AddCommandBuilder.php @@ -175,6 +175,7 @@ public function ignoreMissing() */ public function execute($pathspec = null, $_ = null) { + /** @var list $args */ $args = \func_get_args(); if (\count($args)) { $this->arguments[] = '--'; diff --git a/src/Command/BranchCommandBuilder.php b/src/Command/BranchCommandBuilder.php index 4e5ba4e..ff9a0e9 100644 --- a/src/Command/BranchCommandBuilder.php +++ b/src/Command/BranchCommandBuilder.php @@ -336,13 +336,13 @@ public function execute($branchName = null) if ($branchName) { $this->arguments[] = $branchName; } - return $this->run(); + return (string) $this->run(); } /** * Retrieve the branch names. * - * @return string[] + * @return list */ public function getNames() { @@ -350,13 +350,12 @@ public function getNames() $branches = \explode("\n", $branches); $branches = \array_map( function ($branch) { - return \ltrim($branch, '*'); + return \trim(\ltrim($branch, '*')); }, $branches ); - $branches = \array_map('trim', $branches); $branches = \array_filter($branches); - return $branches; + return \array_values($branches); } } diff --git a/src/Command/CheckoutCommandBuilder.php b/src/Command/CheckoutCommandBuilder.php index 87fe062..9b9f514 100644 --- a/src/Command/CheckoutCommandBuilder.php +++ b/src/Command/CheckoutCommandBuilder.php @@ -217,12 +217,13 @@ public function patch() */ public function execute($branchOrTreeIsh = null, $path = null, $_ = null) { + /** @var list $paths */ + $paths = \func_get_args(); if ($branchOrTreeIsh) { + \array_shift($paths); $this->arguments[] = $branchOrTreeIsh; } - $paths = \func_get_args(); - \array_shift($paths); if (\count($paths)) { $this->arguments[] = '--'; foreach ($paths as $path) { diff --git a/src/Command/CommitCommandBuilder.php b/src/Command/CommitCommandBuilder.php index 2208ebb..f209f86 100644 --- a/src/Command/CommitCommandBuilder.php +++ b/src/Command/CommitCommandBuilder.php @@ -461,6 +461,7 @@ public function execute($pathspec = null, $_ = null) $this->gpgSign($this->repository->getConfig()->getSignCommitUser()); } + /** @var list $args */ $args = \func_get_args(); if (\count($args)) { $this->arguments[] = '--'; @@ -469,6 +470,6 @@ public function execute($pathspec = null, $_ = null) } } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/DescribeCommandBuilder.php b/src/Command/DescribeCommandBuilder.php index d1f2415..504bc1d 100644 --- a/src/Command/DescribeCommandBuilder.php +++ b/src/Command/DescribeCommandBuilder.php @@ -197,6 +197,6 @@ public function firstParent() public function execute($commit = 'HEAD') { $this->arguments[] = $commit; - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/FetchCommandBuilder.php b/src/Command/FetchCommandBuilder.php index 2dc6812..e9a0a39 100644 --- a/src/Command/FetchCommandBuilder.php +++ b/src/Command/FetchCommandBuilder.php @@ -295,12 +295,13 @@ public function execute($repository = 'origin', $refspec = null, $_ = null) { $this->arguments[] = $repository; + /** @var list $refspecs */ $refspecs = \func_get_args(); \array_shift($refspecs); foreach ($refspecs as $refspec) { $this->arguments[] = $refspec; } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/InitCommandBuilder.php b/src/Command/InitCommandBuilder.php index 55b3b50..d4ab1da 100644 --- a/src/Command/InitCommandBuilder.php +++ b/src/Command/InitCommandBuilder.php @@ -120,6 +120,6 @@ public function shared($share) public function execute() { $this->arguments[] = $this->repository->getRepositoryPath(); - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/LogCommandBuilder.php b/src/Command/LogCommandBuilder.php index 41926ea..bbf920a 100644 --- a/src/Command/LogCommandBuilder.php +++ b/src/Command/LogCommandBuilder.php @@ -1078,6 +1078,7 @@ public function t() */ public function execute($pathspec = null, $_ = null) { + /** @var list $args */ $args = \func_get_args(); if (\count($args)) { $this->arguments[] = '--'; @@ -1085,6 +1086,6 @@ public function execute($pathspec = null, $_ = null) $this->arguments[] = $pathspec; } } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/LsRemoteCommandBuilder.php b/src/Command/LsRemoteCommandBuilder.php index a2b20ec..a89e596 100644 --- a/src/Command/LsRemoteCommandBuilder.php +++ b/src/Command/LsRemoteCommandBuilder.php @@ -103,13 +103,14 @@ public function execute($remote, $refSpec = null, $_ = null) { $this->arguments[] = $remote; + /** @var list $refSpec */ $refSpec = \func_get_args(); \array_shift($refSpec); foreach ($refSpec as $ref) { $this->arguments[] = $ref; } - return $this->run(); + return (string) $this->run(); } /** @@ -129,7 +130,7 @@ public function execute($remote, $refSpec = null, $_ = null) */ public function getRefs($remote, $refSpec = null, $_ = null) { - $output = \call_user_func_array([$this, 'execute'], \func_get_args()); + $output = (string) \call_user_func_array([$this, 'execute'], \func_get_args()); $output = \explode("\n", $output); $output = \array_map('trim', $output); $output = \array_filter($output); diff --git a/src/Command/MergeCommandBuilder.php b/src/Command/MergeCommandBuilder.php index 82c40a7..87548da 100644 --- a/src/Command/MergeCommandBuilder.php +++ b/src/Command/MergeCommandBuilder.php @@ -78,12 +78,13 @@ public function strategy($strategy) */ public function execute($branchOrTreeIsh = null, $path = null, $_ = null) { + /** @var list $paths */ + $paths = \func_get_args(); if ($branchOrTreeIsh) { + \array_shift($paths); $this->arguments[] = $branchOrTreeIsh; } - $paths = \func_get_args(); - \array_shift($paths); if (\count($paths)) { $this->arguments[] = '--'; foreach ($paths as $path) { diff --git a/src/Command/PullCommandBuilder.php b/src/Command/PullCommandBuilder.php index 443e686..8558b56 100644 --- a/src/Command/PullCommandBuilder.php +++ b/src/Command/PullCommandBuilder.php @@ -95,12 +95,13 @@ public function execute($repository = 'origin', $refspec = null, $_ = null) { $this->arguments[] = $repository; + /** @var list $refspecs */ $refspecs = \func_get_args(); \array_shift($refspecs); foreach ($refspecs as $refspec) { $this->arguments[] = $refspec; } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/PushCommandBuilder.php b/src/Command/PushCommandBuilder.php index fb4cd9e..32725de 100644 --- a/src/Command/PushCommandBuilder.php +++ b/src/Command/PushCommandBuilder.php @@ -302,12 +302,13 @@ public function execute($repository, $refspec = null, $_ = null) { $this->arguments[] = $repository; + /** @var list $refspecs */ $refspecs = \func_get_args(); \array_shift($refspecs); foreach ($refspecs as $refspec) { $this->arguments[] = $refspec; } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/RemoteCommandBuilder.php b/src/Command/RemoteCommandBuilder.php index 5d56c6b..b565274 100644 --- a/src/Command/RemoteCommandBuilder.php +++ b/src/Command/RemoteCommandBuilder.php @@ -347,7 +347,7 @@ public function update($groupOrRemote, $prune = false) */ public function execute() { - return $this->run(); + return (string) $this->run(); } /** diff --git a/src/Command/ResetCommandBuilder.php b/src/Command/ResetCommandBuilder.php index 11235ca..12be4f7 100644 --- a/src/Command/ResetCommandBuilder.php +++ b/src/Command/ResetCommandBuilder.php @@ -142,10 +142,15 @@ public function commit($commit) */ public function execute($path = null, $_ = null) { - $this->arguments[] = '--'; - foreach (\func_get_args() as $path) { - $this->arguments[] = $path; + /** @var list $args */ + $args = \func_get_args(); + if (\count($args)) { + $this->arguments[] = '--'; + foreach ($args as $pathSpec) { + $this->arguments[] = $pathSpec; + } } - return $this->run(); + + return (string) $this->run(); } } diff --git a/src/Command/RevParseCommandBuilder.php b/src/Command/RevParseCommandBuilder.php index ab13c82..c5dc151 100644 --- a/src/Command/RevParseCommandBuilder.php +++ b/src/Command/RevParseCommandBuilder.php @@ -434,9 +434,11 @@ public function before($date) */ public function execute($arg = null, $_ = null) { - foreach (\func_get_args() as $arg) { + /** @var list $args */ + $args = \func_get_args(); + foreach ($args as $arg) { $this->arguments[] = $arg; } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/RmCommandBuilder.php b/src/Command/RmCommandBuilder.php index 3911aef..b2e96a2 100644 --- a/src/Command/RmCommandBuilder.php +++ b/src/Command/RmCommandBuilder.php @@ -118,6 +118,7 @@ public function quiet() */ public function execute($pathspec = null, $_ = null) { + /** @var list $args */ $args = \func_get_args(); if (\count($args)) { $this->arguments[] = '--'; @@ -125,6 +126,6 @@ public function execute($pathspec = null, $_ = null) $this->arguments[] = $pathspec; } } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/ShortLogCommandBuilder.php b/src/Command/ShortLogCommandBuilder.php index a871d9a..d065330 100644 --- a/src/Command/ShortLogCommandBuilder.php +++ b/src/Command/ShortLogCommandBuilder.php @@ -151,6 +151,7 @@ public function w($width, $indent1 = null, $indent2 = null) */ public function execute($pathSpec = null, $_ = null) { + /** @var list $args */ $args = \func_get_args(); if (\count($args)) { $this->arguments[] = '--'; @@ -159,6 +160,6 @@ public function execute($pathSpec = null, $_ = null) } } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/ShowCommandBuilder.php b/src/Command/ShowCommandBuilder.php index f405b3f..ed5068f 100644 --- a/src/Command/ShowCommandBuilder.php +++ b/src/Command/ShowCommandBuilder.php @@ -206,6 +206,6 @@ public function noPatch() public function execute($object) { $this->arguments[] = $object; - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/StatusCommandBuilder.php b/src/Command/StatusCommandBuilder.php index 3e213e1..94e47c0 100644 --- a/src/Command/StatusCommandBuilder.php +++ b/src/Command/StatusCommandBuilder.php @@ -198,7 +198,7 @@ public function getStatus($pathspec = null, $_ = null) { $this->porcelain(); - $status = \call_user_func_array([$this, 'execute'], \func_get_args()); + $status = (string) \call_user_func_array([$this, 'execute'], \func_get_args()); $status = \explode("\n", $status); $files = []; @@ -245,7 +245,7 @@ public function getIndexStatus($pathspec = null, $_ = null) { $this->porcelain(); - $status = \call_user_func_array([$this, 'execute'], \func_get_args()); + $status = (string) \call_user_func_array([$this, 'execute'], \func_get_args()); $status = \explode("\n", $status); $files = []; @@ -288,7 +288,7 @@ public function getWorkTreeStatus($pathspec = null, $_ = null) { $this->porcelain(); - $status = \call_user_func_array([$this, 'execute'], \func_get_args()); + $status = (string) \call_user_func_array([$this, 'execute'], \func_get_args()); $status = \explode("\n", $status); $files = []; @@ -321,6 +321,7 @@ public function getWorkTreeStatus($pathspec = null, $_ = null) */ public function execute($pathspec = null, $_ = null) { + /** @var list $args */ $args = \func_get_args(); if (\count($args)) { $this->arguments[] = '--'; @@ -328,6 +329,6 @@ public function execute($pathspec = null, $_ = null) $this->arguments[] = $pathspec; } } - return $this->run(); + return (string) $this->run(); } } diff --git a/src/Command/TagCommandBuilder.php b/src/Command/TagCommandBuilder.php index 7ffac6f..a64e699 100644 --- a/src/Command/TagCommandBuilder.php +++ b/src/Command/TagCommandBuilder.php @@ -276,7 +276,7 @@ public function execute($tagName = null, $commit = null) $this->arguments[] = $commit; } - return $this->run(); + return (string) $this->run(); } /**