Skip to content

Commit

Permalink
Fix static analysis errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean85 committed Feb 2, 2024
1 parent bd2b231 commit d1d9ca9
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Bin/run-paraunit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace Paraunit\Bin;

if (! ini_get('date.timezone') && ! date_default_timezone_get()) {
/** @psalm-suppress RiskyTruthyFalsyComparison */
if (! ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
// HOTFIX -- needed to fool the Symfony's WebTestCase
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/PHPUnitBinFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getPhpUnitBin(): string
private function setPhpUnitBin(string $phpUnitBin): void
{
$realpath = realpath($phpUnitBin);
if (! $realpath) {
if (false === $realpath) {
throw new \RuntimeException('Unable set PHPUnit binary real path');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/ParallelConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function tagEventSubscribers(ContainerBuilder $container): void

$class = $definition->getClass() ?? $id;
$implements = class_implements($class);
if ($implements && array_key_exists(EventSubscriberInterface::class, $implements)) {
if (array_key_exists(EventSubscriberInterface::class, $implements ?: [])) {
$definition->addTag(self::TAG_EVENT_SUBSCRIBER);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Logs/ValueObject/LogData.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function jsonSerialize(): array
'test' => $this->test->name,
];

if ($this->message) {
if (null !== $this->message) {
$data['message'] = $this->message;
}

Expand All @@ -58,6 +58,7 @@ public function jsonSerialize(): array

private function convertToUtf8(string $string): string
{
/** @psalm-suppress RiskyTruthyFalsyComparison */
if (! \mb_detect_encoding($string, 'UTF-8', true)) {
return \mb_convert_encoding($string, 'UTF-8');
}
Expand Down
6 changes: 6 additions & 0 deletions src/TestResult/ValueObject/TestIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function getSymbol(): string
};
}

/**
* @psalm-suppress InternalMethod
*/
public function isMoreImportantThan(?ComparableTestStatus $status): bool
{
if (! $status instanceof ComparableTestStatus) {
Expand All @@ -42,6 +45,9 @@ public function isMoreImportantThan(?ComparableTestStatus $status): bool
return $this->toPHPUnit()->isMoreImportantThan($status->toPHPUnit());
}

/**
* @psalm-suppress InternalClass, InternalMethod
*/
public function toPHPUnit(): TestStatus
{
return match ($this) {
Expand Down
6 changes: 6 additions & 0 deletions src/TestResult/ValueObject/TestOutcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function getSymbol(): string
};
}

/**
* @psalm-suppress InternalMethod
*/
public function isMoreImportantThan(?ComparableTestStatus $status): bool
{
if (! $status instanceof ComparableTestStatus) {
Expand All @@ -54,6 +57,9 @@ public function isMoreImportantThan(?ComparableTestStatus $status): bool
return $this->toPHPUnit()->isMoreImportantThan($status->toPHPUnit());
}

/**
* @psalm-suppress InternalClass, InternalMethod
*/
public function toPHPUnit(): TestStatus
{
return match ($this) {
Expand Down
2 changes: 1 addition & 1 deletion src/TestResult/ValueObject/TestResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(

public static function from(LogData $log): self
{
if ($log->message) {
if (null !== $log->message && '' !== $log->message) {
return new TestResultWithMessage($log->test, $log->status->toTestStatus(), $log->message);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Logs/TestHook/ExecutionStartedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ protected function createEvent(): TestSuiteExecutionStarted

protected function getExpectedMessage(): ?string
{
return null;
return '0';
}
}
3 changes: 3 additions & 0 deletions tests/Unit/Logs/TestHook/PhpUnitDeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ protected function createEvent(): PhpUnitDeprecationTriggered
);
}

/**
* @return non-empty-string
*/
protected function getExpectedMessage(): string
{
return 'test message';
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Logs/TestHook/PhpUnitWarningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ protected function createEvent(): PhpunitWarningTriggered
);
}

/**
* @return non-empty-string
*/
protected function getExpectedMessage(): string
{
return 'test warning message';
Expand Down

0 comments on commit d1d9ca9

Please sign in to comment.