Skip to content

Commit

Permalink
fix coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
azjezz committed Feb 17, 2021
1 parent 25f2ed7 commit 76fbe09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 14 additions & 1 deletion src/Psl/Internal/internal_encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@
function internal_encoding(?string $encoding = null): string
{
Psl\invariant(null === $encoding || is_encoding_valid($encoding), 'Invalid encoding.');
if (null !== $encoding) {
return $encoding;
}

/**
* @psalm-suppress ImpureFunctionCall
*/
$internal_encoding = mb_internal_encoding();

/**
* @psalm-suppress ImpureFunctionCall - see https://github.com/azjezz/psl/issues/130
* @psalm-suppress ImpureMethodCall - see https://github.com/azjezz/psl/issues/130
*/
return $encoding ?? (Type\string()->matches($internal_encoding = mb_internal_encoding()) ? $internal_encoding : 'UTF-8');
if (Type\string()->matches($internal_encoding)) {
return $internal_encoding;
}

return 'UTF-8';
}
4 changes: 1 addition & 3 deletions src/Psl/Type/Internal/NullType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use Psl\Type\Exception\AssertException;
use Psl\Type\Exception\CoercionException;

use function is_null;

/**
* @extends Type\Type<null>
*
Expand All @@ -34,7 +32,7 @@ public function matches($value): bool
*/
public function coerce($value)
{
if (is_null($value)) {
if (null === $value) {
return null;
}

Expand Down

0 comments on commit 76fbe09

Please sign in to comment.