Skip to content

Commit

Permalink
Cast preg_replace calls to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyWyvern committed Mar 8, 2024
1 parent ff99010 commit 19136c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Smalot/PdfParser/Element/ElementHexa.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public static function decode(string $value): string
$text = '';

// Filter $value of non-hexadecimal characters
$value = preg_replace('/[^0-9a-f]/i', '', $value);
$value = (string) preg_replace('/[^0-9a-f]/i', '', $value);

// Check for leading zeros (4-byte hexadecimal indicator), or
// the BE BOM
if ('00' === substr($value, 0, 2) || 'feff' === strtolower(substr($value, 0, 4))) {
$value = preg_replace('/^feff/i', '', $value);
$value = (string) preg_replace('/^feff/i', '', $value);
for ($i = 0, $length = \strlen($value); $i < $length; $i += 4) {
$hex = substr($value, $i, 4);
$text .= '&#'.str_pad(hexdec($hex), 4, '0', \STR_PAD_LEFT).';';
Expand Down

0 comments on commit 19136c7

Please sign in to comment.