Skip to content

Commit

Permalink
Fix psalm 5.20 issues (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Jan 19, 2024
1 parent 8dc444b commit 881b821
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Psl/Filesystem/canonicalize.php
Expand Up @@ -14,5 +14,7 @@
*/
function canonicalize(string $path): ?string
{
return realpath($path) ?: null;
$path = realpath($path);

return false !== $path && '' !== $path ? $path : null;
}
7 changes: 5 additions & 2 deletions src/Psl/Str/detect_encoding.php
Expand Up @@ -25,7 +25,10 @@ function detect_encoding(string $string, ?array $encoding_list = null): ?Encodin
);
}

$encoding = mb_detect_encoding($string, $encoding_list, true) ?: null;
$encoding = mb_detect_encoding($string, $encoding_list, true);
if ($encoding === false) {
return null;
}

return null === $encoding ? $encoding : Encoding::from($encoding);
return Encoding::from($encoding);
}

0 comments on commit 881b821

Please sign in to comment.