Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
on:
push:
branches:
- '*.*'
- '2.x'
pull_request: null

name: static analysis

permissions:
contents: read

jobs:
psalm:
uses: spiral/gh-actions/.github/workflows/psalm.yml@master
Expand Down
155 changes: 0 additions & 155 deletions psalm-baseline.xml

This file was deleted.

4 changes: 1 addition & 3 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
errorLevel="1"
hoistConstants="true"
resolveFromConfigFile="true"
Expand All @@ -16,8 +15,7 @@
>
<issueHandlers>
<MissingClassConstType errorLevel="suppress" />
<!-- Psalm 6 reports; temporarily suppressed until the static analysis pass -->
<MissingOverrideAttribute errorLevel="suppress" />
<!-- Making public classes final would break BC for users who extend them -->
<ClassMustBeFinal errorLevel="suppress" />
</issueHandlers>
<projectFiles>
Expand Down
5 changes: 4 additions & 1 deletion src/Archive/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
$this->bootDefaultMatchers();
}

#[\Override]
public function extend(\Closure $matcher): self
{
\array_unshift($this->matchers, $matcher);

return $this;
}

#[\Override]
public function create(\SplFileInfo $file): ArchiveInterface
{
$errors = [];
Expand All @@ -48,18 +50,19 @@
return $archive;
}
} catch (\Throwable $e) {
$errors[] = ' - ' . $e->getMessage();

Check warning on line 53 in src/Archive/Factory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ return $archive; } } catch (\Throwable $e) { - $errors[] = ' - ' . $e->getMessage(); + $errors[] = $e->getMessage(); continue; } }

Check warning on line 53 in src/Archive/Factory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "Concat": @@ @@ return $archive; } } catch (\Throwable $e) { - $errors[] = ' - ' . $e->getMessage(); + $errors[] = $e->getMessage() . ' - '; continue; } }
continue;

Check warning on line 54 in src/Archive/Factory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "Continue_": @@ @@ } } catch (\Throwable $e) { $errors[] = ' - ' . $e->getMessage(); - continue; + break; } }
}
}

$error = \sprintf('Can not open the archive "%s":%s', $file->getFilename(), \PHP_EOL) .

Check warning on line 58 in src/Archive/Factory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "Concat": @@ @@ } } - $error = \sprintf('Can not open the archive "%s":%s', $file->getFilename(), \PHP_EOL) . - \implode(\PHP_EOL, $errors) + $error = \implode(\PHP_EOL, $errors) . \sprintf('Can not open the archive "%s":%s', $file->getFilename(), \PHP_EOL) ; throw new \InvalidArgumentException($error);
\implode(\PHP_EOL, $errors)
;

throw new \InvalidArgumentException($error);
}

#[\Override]
public function fromAsset(AssetInterface $asset, ?\Closure $progress = null, ?string $temp = null): ArchiveInterface
{
$temp = $this->getTempDirectory($temp) . '/' . $asset->getName();
Expand Down Expand Up @@ -91,7 +94,7 @@
static fn(\SplFileInfo $info): ArchiveInterface => new TarPharArchive($info),
));

$this->extend($this->matcher(

Check warning on line 97 in src/Archive/Factory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ static fn(\SplFileInfo $info): ArchiveInterface => new TarPharArchive($info), )); - $this->extend($this->matcher( - 'phar', - static fn(\SplFileInfo $info): ArchiveInterface => new PharArchive($info), - )); + } /**
'phar',
static fn(\SplFileInfo $info): ArchiveInterface => new PharArchive($info),
));
Expand All @@ -104,14 +107,14 @@
private function matcher(string $extension, \Closure $then): \Closure
{
return static fn(\SplFileInfo $info): ?ArchiveInterface =>
\str_ends_with(\strtolower($info->getFilename()), '.' . $extension) ? $then($info) : null

Check warning on line 110 in src/Archive/Factory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ private function matcher(string $extension, \Closure $then): \Closure { return static fn(\SplFileInfo $info): ?ArchiveInterface => - \str_ends_with(\strtolower($info->getFilename()), '.' . $extension) ? $then($info) : null + \str_ends_with(\strtolower($info->getFilename()), $extension) ? $then($info) : null ; }
;
}

private function getTempDirectory(?string $temp): string
{
if ($temp) {
if ($temp !== null && $temp !== '') {
if (! \is_dir($temp) || ! \is_writable($temp)) {

Check warning on line 117 in src/Archive/Factory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "LogicalOr": @@ @@ private function getTempDirectory(?string $temp): string { if ($temp !== null && $temp !== '') { - if (! \is_dir($temp) || ! \is_writable($temp)) { + if (! \is_dir($temp) && ! \is_writable($temp)) { throw new \LogicException(\sprintf('Directory "%s" is not writeable', $temp)); }
throw new \LogicException(\sprintf('Directory "%s" is not writeable', $temp));
}

Expand Down
1 change: 1 addition & 0 deletions src/Archive/PharArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

final class PharArchive extends PharAwareArchive
{
#[\Override]
protected function open(\SplFileInfo $file): \PharData
{
return new \PharData($file->getPathname());
Expand Down
1 change: 1 addition & 0 deletions src/Archive/PharAwareArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(\SplFileInfo $archive)
* @param iterable<string, string> $mappings
* @return \Generator<mixed, \SplFileInfo>
*/
#[\Override]
public function extract(iterable $mappings): \Generator
{
$phar = $this->open($this->archive);
Expand Down
1 change: 1 addition & 0 deletions src/Archive/TarPharArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

final class TarPharArchive extends PharAwareArchive
{
#[\Override]
protected function open(\SplFileInfo $file): \PharData
{
return new \PharData($file->getPathname());
Expand Down
1 change: 1 addition & 0 deletions src/Archive/ZipPharArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

final class ZipPharArchive extends PharAwareArchive
{
#[\Override]
protected function open(\SplFileInfo $file): \PharData
{
$format = \Phar::ZIP | \Phar::GZ;

Check warning on line 19 in src/Archive/ZipPharArchive.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "BitwiseOr": @@ @@ #[\Override] protected function open(\SplFileInfo $file): \PharData { - $format = \Phar::ZIP | \Phar::GZ; + $format = \Phar::ZIP & \Phar::GZ; return new \PharData($file->getPathname(), 0, null, $format); }

return new \PharData($file->getPathname(), 0, null, $format);

Check warning on line 21 in src/Archive/ZipPharArchive.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "IncrementInteger": @@ @@ { $format = \Phar::ZIP | \Phar::GZ; - return new \PharData($file->getPathname(), 0, null, $format); + return new \PharData($file->getPathname(), 1, null, $format); } }

Check warning on line 21 in src/Archive/ZipPharArchive.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "DecrementInteger": @@ @@ { $format = \Phar::ZIP | \Phar::GZ; - return new \PharData($file->getPathname(), 0, null, $format); + return new \PharData($file->getPathname(), -1, null, $format); } }
}
}
2 changes: 1 addition & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function getRepository(): RepositoryInterface

$client = HttpClient::create([
'headers' => \array_filter([
'authorization' => $token ? 'token ' . $token : null,
'authorization' => $token !== null && $token !== '' ? 'token ' . $token : null,
]),
]);

Expand Down
3 changes: 3 additions & 0 deletions src/Command/ArchitectureOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(Command $command, string $name = 'arch', string $sho
parent::__construct($command, $name, $short);
}

#[\Override]
public function get(InputInterface $input, StyleInterface $io): string
{
$architecture = parent::get($input, $io);
Expand All @@ -35,11 +36,13 @@ public function get(InputInterface $input, StyleInterface $io): string
return $architecture;
}

#[\Override]
protected function getDescription(): string
{
return 'Required processor architecture (one of: ' . $this->choices() . ')';
}

#[\Override]
protected function default(): string
{
return Architecture::createFromGlobals();
Expand Down
3 changes: 3 additions & 0 deletions src/Command/InstallationLocationOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct(Command $command, string $name = 'location', string
parent::__construct($command, $name, $short);
}

#[\Override]
public function get(InputInterface $input, StyleInterface $io): string
{
$location = parent::get($input, $io);
Expand All @@ -38,11 +39,13 @@ public function get(InputInterface $input, StyleInterface $io): string
return $location;
}

#[\Override]
protected function getDescription(): string
{
return 'Installation directory';
}

#[\Override]
protected function default(): string
{
return \getcwd() ?: '.';
Expand Down
3 changes: 3 additions & 0 deletions src/Command/OperatingSystemOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(Command $command, string $name = 'os', string $short
parent::__construct($command, $name, $short);
}

#[\Override]
public function get(InputInterface $input, StyleInterface $io): string
{
$os = parent::get($input, $io);
Expand All @@ -35,11 +36,13 @@ public function get(InputInterface $input, StyleInterface $io): string
return $os;
}

#[\Override]
protected function getDescription(): string
{
return 'Required operating system (one of: ' . $this->choices() . ')';
}

#[\Override]
protected function default(): string
{
return OperatingSystem::createFromGlobals();
Expand Down
11 changes: 8 additions & 3 deletions src/Command/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public function __construct(Command $command, string $name, ?string $short = nul
$this->register($command, $name, $short ?? $name);
}

#[\Override]
public function getName(): string
{
return $this->name;
}

#[\Override]
public function get(InputInterface $input, StyleInterface $io): string
{
$result = $input->getOption($this->name) ?: $this->default();

return \is_string($result) ? $result : '';
return self::toString($input->getOption($this->name) ?: $this->default());
}

/**
Expand All @@ -54,6 +54,11 @@ abstract protected function getDescription(): string;

abstract protected function default(): ?string;

private static function toString(mixed $value): string
{
return \is_string($value) ? $value : '';
}

private function register(Command $command, string $name, string $short): void
{
$command->addOption($name, $short, $this->getMode(), $this->getDescription(), $this->default());
Expand Down
3 changes: 3 additions & 0 deletions src/Command/StabilityOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct(Command $command, string $name = 'stability', string
*
* @return StabilityType|string
*/
#[\Override]
public function get(InputInterface $input, StyleInterface $io): string
{
$stability = parent::get($input, $io);
Expand All @@ -42,11 +43,13 @@ public function get(InputInterface $input, StyleInterface $io): string
return $stability;
}

#[\Override]
protected function getDescription(): string
{
return 'Release minimum stability flag';
}

#[\Override]
protected function default(): string
{
return Stability::STABILITY_STABLE;
Expand Down
Loading
Loading