Skip to content

Commit

Permalink
Reduce psalm error level to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
discordier committed Aug 16, 2023
1 parent 40fdd80 commit 4f733e1
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 34 deletions.
10 changes: 9 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="8"
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand All @@ -12,4 +12,12 @@
<projectFiles>
<directory name="src"/>
</projectFiles>
<issueHandlers>
<DeprecatedClass>
<errorLevel type="suppress">
<!-- See https://github.com/vimeo/psalm/issues/10116 -->
<file name="src/Command/CommandBuilderTrait.php"/>
</errorLevel>
</DeprecatedClass>
</issueHandlers>
</psalm>
1 change: 1 addition & 0 deletions src/Command/AddCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public function ignoreMissing()
*/
public function execute($pathspec = null, $_ = null)
{
/** @var list<string> $args */
$args = \func_get_args();
if (\count($args)) {
$this->arguments[] = '--';
Expand Down
9 changes: 4 additions & 5 deletions src/Command/BranchCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,27 +336,26 @@ 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<string>
*/
public function getNames()
{
$branches = $this->execute();
$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);
}
}
5 changes: 3 additions & 2 deletions src/Command/CheckoutCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,13 @@ public function patch()
*/
public function execute($branchOrTreeIsh = null, $path = null, $_ = null)
{
/** @var list<string> $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) {
Expand Down
3 changes: 2 additions & 1 deletion src/Command/CommitCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ public function execute($pathspec = null, $_ = null)
$this->gpgSign($this->repository->getConfig()->getSignCommitUser());
}

/** @var list<string> $args */
$args = \func_get_args();
if (\count($args)) {
$this->arguments[] = '--';
Expand All @@ -469,6 +470,6 @@ public function execute($pathspec = null, $_ = null)
}
}

return $this->run();
return (string) $this->run();
}
}
2 changes: 1 addition & 1 deletion src/Command/DescribeCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,6 @@ public function firstParent()
public function execute($commit = 'HEAD')
{
$this->arguments[] = $commit;
return $this->run();
return (string) $this->run();
}
}
3 changes: 2 additions & 1 deletion src/Command/FetchCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,13 @@ public function execute($repository = 'origin', $refspec = null, $_ = null)
{
$this->arguments[] = $repository;

/** @var list<string> $refspecs */
$refspecs = \func_get_args();
\array_shift($refspecs);
foreach ($refspecs as $refspec) {
$this->arguments[] = $refspec;
}

return $this->run();
return (string) $this->run();
}
}
2 changes: 1 addition & 1 deletion src/Command/InitCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ public function shared($share)
public function execute()
{
$this->arguments[] = $this->repository->getRepositoryPath();
return $this->run();
return (string) $this->run();
}
}
3 changes: 2 additions & 1 deletion src/Command/LogCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1078,13 +1078,14 @@ public function t()
*/
public function execute($pathspec = null, $_ = null)
{
/** @var list<string> $args */
$args = \func_get_args();
if (\count($args)) {
$this->arguments[] = '--';
foreach ($args as $pathspec) {
$this->arguments[] = $pathspec;
}
}
return $this->run();
return (string) $this->run();
}
}
5 changes: 3 additions & 2 deletions src/Command/LsRemoteCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ public function execute($remote, $refSpec = null, $_ = null)
{
$this->arguments[] = $remote;

/** @var list<string> $refSpec */
$refSpec = \func_get_args();
\array_shift($refSpec);
foreach ($refSpec as $ref) {
$this->arguments[] = $ref;
}

return $this->run();
return (string) $this->run();
}

/**
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/Command/MergeCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ public function strategy($strategy)
*/
public function execute($branchOrTreeIsh = null, $path = null, $_ = null)
{
/** @var list<string> $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) {
Expand Down
3 changes: 2 additions & 1 deletion src/Command/PullCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ public function execute($repository = 'origin', $refspec = null, $_ = null)
{
$this->arguments[] = $repository;

/** @var list<string> $refspecs */
$refspecs = \func_get_args();
\array_shift($refspecs);
foreach ($refspecs as $refspec) {
$this->arguments[] = $refspec;
}

return $this->run();
return (string) $this->run();
}
}
3 changes: 2 additions & 1 deletion src/Command/PushCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,13 @@ public function execute($repository, $refspec = null, $_ = null)
{
$this->arguments[] = $repository;

/** @var list<string> $refspecs */
$refspecs = \func_get_args();
\array_shift($refspecs);
foreach ($refspecs as $refspec) {
$this->arguments[] = $refspec;
}

return $this->run();
return (string) $this->run();
}
}
2 changes: 1 addition & 1 deletion src/Command/RemoteCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public function update($groupOrRemote, $prune = false)
*/
public function execute()
{
return $this->run();
return (string) $this->run();
}

/**
Expand Down
13 changes: 9 additions & 4 deletions src/Command/ResetCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> $args */
$args = \func_get_args();
if (\count($args)) {
$this->arguments[] = '--';
foreach ($args as $pathSpec) {
$this->arguments[] = $pathSpec;
}
}
return $this->run();

return (string) $this->run();
}
}
6 changes: 4 additions & 2 deletions src/Command/RevParseCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,11 @@ public function before($date)
*/
public function execute($arg = null, $_ = null)
{
foreach (\func_get_args() as $arg) {
/** @var list<string> $args */
$args = \func_get_args();
foreach ($args as $arg) {
$this->arguments[] = $arg;
}
return $this->run();
return (string) $this->run();
}
}
3 changes: 2 additions & 1 deletion src/Command/RmCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ public function quiet()
*/
public function execute($pathspec = null, $_ = null)
{
/** @var list<string> $args */
$args = \func_get_args();
if (\count($args)) {
$this->arguments[] = '--';
foreach ($args as $pathspec) {
$this->arguments[] = $pathspec;
}
}
return $this->run();
return (string) $this->run();
}
}
3 changes: 2 additions & 1 deletion src/Command/ShortLogCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public function w($width, $indent1 = null, $indent2 = null)
*/
public function execute($pathSpec = null, $_ = null)
{
/** @var list<string> $args */
$args = \func_get_args();
if (\count($args)) {
$this->arguments[] = '--';
Expand All @@ -159,6 +160,6 @@ public function execute($pathSpec = null, $_ = null)
}
}

return $this->run();
return (string) $this->run();
}
}
2 changes: 1 addition & 1 deletion src/Command/ShowCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,6 @@ public function noPatch()
public function execute($object)
{
$this->arguments[] = $object;
return $this->run();
return (string) $this->run();
}
}
9 changes: 5 additions & 4 deletions src/Command/StatusCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -321,13 +321,14 @@ public function getWorkTreeStatus($pathspec = null, $_ = null)
*/
public function execute($pathspec = null, $_ = null)
{
/** @var list<string> $args */
$args = \func_get_args();
if (\count($args)) {
$this->arguments[] = '--';
foreach ($args as $pathspec) {
$this->arguments[] = $pathspec;
}
}
return $this->run();
return (string) $this->run();
}
}
2 changes: 1 addition & 1 deletion src/Command/TagCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function execute($tagName = null, $commit = null)
$this->arguments[] = $commit;
}

return $this->run();
return (string) $this->run();
}

/**
Expand Down

0 comments on commit 4f733e1

Please sign in to comment.