Skip to content

Commit

Permalink
Fix RiskyTruthyFalsyComparison issues
Browse files Browse the repository at this point in the history
Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jan 22, 2024
1 parent 111cfc0 commit 56a7fb2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/PhoneNumberValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function type(): int
private static function regionCodeForNumber(LibPhoneNumber $number, ?string $givenCode): ?string
{
$dialingCode = $number->getCountryCode();
if (! $dialingCode) {
if ($dialingCode === null) {
return $givenCode;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validator/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function setAllowedTypes(int $types): void
/** @param array<string, mixed> $validationContext */
private function resolveCountry(?array $validationContext): ?CountryCode
{
if (! is_array($validationContext) || ! $this->countryContext) {
if (! is_array($validationContext) || $this->countryContext === null) {
return $this->country;
}

Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/PhoneNumberFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __invoke(): self
*/
private function coalesceCountryCode(?string $countryCodeOrLocale): CountryCode
{
$code = $countryCodeOrLocale ? CountryCode::tryFromString($countryCodeOrLocale) : null;
$code = $countryCodeOrLocale !== null ? CountryCode::tryFromString($countryCodeOrLocale) : null;

return $code ?? $this->defaultCountryCode;
}
Expand Down
6 changes: 4 additions & 2 deletions test/ProjectIntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;

use function is_array;

Check failure on line 11 in test/ProjectIntegrationTestCase.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Type is_array is not used in this file.

Check failure on line 11 in test/ProjectIntegrationTestCase.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Type is_array is not used in this file.

/**
* @psalm-import-type ServiceManagerConfigurationType from Laminas\ServiceManager\ConfigInterface
* @phpcs:disable WebimpressCodingStandard.NamingConventions.AbstractClass.Prefix
Expand All @@ -32,9 +34,9 @@ protected static function getContainer(array $userConfig = []): ContainerInterfa
$config = $aggregator->getMergedConfig();
$dependencies = $config['dependencies'] ?? [];
self::assertIsArray($dependencies);
/** @psalm-var ServiceManagerConfigurationType $dependencies */
unset($dependencies['services']['config']);
/** @psalm-suppress MixedArrayAssignment */
$dependencies['services']['config'] = $config;
/** @psalm-var ServiceManagerConfigurationType $dependencies */

return new Laminas\ServiceManager\ServiceManager($dependencies);
}
Expand Down

0 comments on commit 56a7fb2

Please sign in to comment.