Skip to content

Commit

Permalink
Cleanup of phpstan-baseline.neon ignored errors
Browse files Browse the repository at this point in the history
  • Loading branch information
theimbender committed Sep 17, 2023
1 parent 7bad8ea commit d758edc
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 296 deletions.
195 changes: 0 additions & 195 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Only booleans are allowed in &&, mixed given on the left side\\.$#"
count: 1
path: src/Builder/ArchiveBuilder.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 4
Expand All @@ -15,56 +10,11 @@ parameters:
count: 1
path: src/Builder/PackagesBuilder.php

-
message: "#^Only booleans are allowed in an if condition, int\\<min, 2\\> given\\.$#"
count: 1
path: src/Builder/PackagesBuilder.php

-
message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#"
count: 1
path: src/Builder/PackagesBuilder.php

-
message: "#^Only booleans are allowed in a negated boolean, string\\|null given\\.$#"
count: 1
path: src/Builder/WebBuilder.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 2
path: src/Console/Command/AddCommand.php

-
message: "#^Only booleans are allowed in a negated boolean, Composer\\\\Repository\\\\Vcs\\\\VcsDriverInterface\\|null given\\.$#"
count: 1
path: src/Console/Command/AddCommand.php

-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
count: 2
path: src/Console/Command/BuildCommand.php

-
message: "#^Only booleans are allowed in \\|\\|, mixed given on the right side\\.$#"
count: 1
path: src/Console/Command/BuildCommand.php

-
message: "#^Only booleans are allowed in &&, string\\|null given on the left side\\.$#"
count: 1
path: src/Console/Command/InitCommand.php

-
message: "#^Strict comparison using \\!\\=\\= between '' and non\\-falsy\\-string will always evaluate to true\\.$#"
count: 1
path: src/Console/Command/InitCommand.php

-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
path: src/Console/Command/PurgeCommand.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
Expand All @@ -75,171 +25,26 @@ parameters:
count: 2
path: src/Console/Command/PurgeCommand.php

-
message: "#^Only booleans are allowed in a negated boolean, int given\\.$#"
count: 1
path: src/Console/Command/PurgeCommand.php

-
message: "#^Only booleans are allowed in a negated boolean, string\\|null given\\.$#"
count: 1
path: src/Console/Command/PurgeCommand.php

-
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 1
path: src/Console/Command/PurgeCommand.php

-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 5
path: src/PackageSelection/PackageSelection.php

-
message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#"
count: 1
path: src/PackageSelection/PackageSelection.php

-
message: "#^Casting to bool something that's already bool\\.$#"
count: 1
path: src/PackageSelection/PackageSelection.php

-
message: "#^Only booleans are allowed in &&, string given on the left side\\.$#"
count: 1
path: src/PackageSelection/PackageSelection.php

-
message: "#^Only booleans are allowed in a negated boolean, int\\<0, max\\> given\\.$#"
count: 1
path: src/PackageSelection/PackageSelection.php

-
message: "#^Only booleans are allowed in a ternary operator condition, string given\\.$#"
count: 1
path: src/PackageSelection/PackageSelection.php

-
message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#"
count: 2
path: src/PackageSelection/PackageSelection.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
count: 2
path: tests/Builder/ArchiveBuilderHelperTest.php

-
message: "#^AnonymousClassdd4f4d5d0a10081f3f8b9c19006facf2\\:\\:__construct\\(\\) does not call parent constructor from Composer\\\\Package\\\\Archiver\\\\ArchiveManager\\.$#"
count: 1
path: tests/Builder/ArchiveBuilderTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#"
count: 2
path: tests/Builder/ArchiveBuilderTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\TestCase\\:\\:returnCallback\\(\\)\\.$#"
count: 1
path: tests/Builder/ArchiveBuilderTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\TestCase\\:\\:returnValue\\(\\)\\.$#"
count: 1
path: tests/Builder/ArchiveBuilderTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\)\\.$#"
count: 1
path: tests/Builder/PackagesBuilderDumpTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayNotHasKey\\(\\)\\.$#"
count: 1
path: tests/Builder/PackagesBuilderDumpTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
count: 3
path: tests/Builder/PackagesBuilderDumpTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\)\\.$#"
count: 1
path: tests/Builder/PackagesBuilderDumpTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\)\\.$#"
count: 2
path: tests/Builder/PackagesBuilderDumpTest.php

-
message: "#^Only booleans are allowed in a negated boolean, string\\|null given\\.$#"
count: 1
path: tests/Builder/PackagesBuilderDumpTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\)\\.$#"
count: 1
path: tests/Builder/WebBuilderDumpTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertMatchesRegularExpression\\(\\)\\.$#"
count: 6
path: tests/Builder/WebBuilderDumpTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
count: 3
path: tests/Builder/WebBuilderTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\)\\.$#"
count: 1
path: tests/Builder/WebBuilderTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#"
count: 3
path: tests/Builder/WebBuilderTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEmpty\\(\\)\\.$#"
count: 3
path: tests/PackageSelection/PackageSelectionLoadTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotEmpty\\(\\)\\.$#"
count: 3
path: tests/PackageSelection/PackageSelectionLoadTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotInstanceOf\\(\\)\\.$#"
count: 1
path: tests/PackageSelection/PackageSelectionLoadTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#"
count: 2
path: tests/PackageSelection/PackageSelectionLoadTest.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
path: tests/PackageSelection/PackageSelectionTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
count: 6
path: tests/PackageSelection/PackageSelectionTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#"
count: 2
path: tests/PackageSelection/PackageSelectionTest.php

-
message: "#^Implicit array creation is not allowed \\- variable \\$data does not exist\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/ArchiveBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function dump(array $packages): void
$progressBar = null;
$hasStarted = false;
$verbosity = $this->output->getVerbosity();
$renderProgress = $this->input->getOption('stats') && OutputInterface::VERBOSITY_NORMAL == $verbosity;
$renderProgress = (bool) $this->input->getOption('stats') && OutputInterface::VERBOSITY_NORMAL == $verbosity;

if ($renderProgress) {
$packageCount = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/PackagesBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private function dumpPackageIncludeJson(array $packages, string $includesUrl, st
}
}

if ($path) {
if (is_string($path)) {
$this->writeToFile($path, $contents);
$this->output->writeln("<info>Wrote packages to $path</info>");
}
Expand Down Expand Up @@ -296,7 +296,7 @@ private function writeToFile(string $path, string $contents): void
file_put_contents($path, $contents);
break;
} catch (\Exception $e) {
if ($retries) {
if ($retries > 0) {
usleep(500000);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/WebBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function dump(array $packages): void
$this->output->writeln('Define a "name" property in your json config to name the repository');
}

if (!$this->rootPackage->getHomepage()) {
if (is_null($this->rootPackage->getHomepage())) {
$this->output->writeln('Define a "homepage" property in your json config to configure the repository URL');
}

Expand Down
3 changes: 2 additions & 1 deletion src/Console/Command/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ protected function isRepositoryValid(string $repositoryUrl, string $type): bool
$downloader = new HttpDownloader($io, $config);
$repository = new VcsRepository(['url' => $repositoryUrl, 'type' => $type], $io, $config, $downloader);

if (!($driver = $repository->getDriver())) {
$driver = $repository->getDriver();
if (is_null($driver)) {
return false;
}

Expand Down
8 changes: 5 additions & 3 deletions src/Console/Command/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// disable packagist by default
unset(Config::$defaultRepositories['packagist'], Config::$defaultRepositories['packagist.org']);

if (!$outputDir = $input->getArgument('output-dir')) {
$outputDir = $input->getArgument('output-dir');
if (!(bool) $outputDir) {
$outputDir = $config['output-dir'] ?? null;
}

Expand Down Expand Up @@ -251,8 +252,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$packagesBuilder = new PackagesBuilder($output, $outputDir, $config, $skipErrors, $minify);
$packagesBuilder->dump($packages);

if ($htmlView = !$input->getOption('no-html-output')) {
$htmlView = !isset($config['output-html']) || $config['output-html'];
$htmlView = (bool) $input->getOption('no-html-output');
if (!$htmlView) {
$htmlView = !isset($config['output-html']) || (bool) $config['output-html'];
}

if ($htmlView) {
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function prompt(InputInterface $input, OutputInterface $output, string

protected function getQuestion(string $prompt, ?string $default): Question
{
$prompt = ($default && '' !== $default ? sprintf('%s (%s)', $prompt, $default) : $prompt) . ': ';
$prompt = (is_string($default) && '' !== $default ? sprintf('%s (%s)', $prompt, $default) : $prompt) . ': ';

return new Question($prompt, $default);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Console/Command/PurgeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$length = strlen($prefix);
$needed = [];
foreach ($packages as $package) {
if (!$package->getDistType()) {
if (is_null($package->getDistType())) {
continue;
}
$url = $package->getDistUrl();
Expand All @@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
->in($distDirectory)
;

if (!$finder->count()) {
if (0 === $finder->count()) {
$output->writeln('<warning>No archives found.</warning>');

return 0;
Expand All @@ -115,7 +115,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$unreferenced = [];
foreach ($finder as $file) {
$filename = strtr($file->getRelativePathname(), DIRECTORY_SEPARATOR, '/');
if (!in_array($filename, $needed)) {
if (!in_array($filename, $needed, true)) {
$unreferenced[] = $file;
}
}
Expand Down
Loading

0 comments on commit d758edc

Please sign in to comment.