Skip to content

Commit

Permalink
Fixes PHP error "A non well formed numeric value encountered" if Gedc…
Browse files Browse the repository at this point in the history
…om 7 export is used with PHP 7.4
  • Loading branch information
Jefferson49 committed Jan 4, 2024
1 parent 7509a20 commit 42c726a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions GedcomSevenExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ public function convertToGedcom7(string $gedcom, bool $gedcom_l= false): string
$level = (int) $match[1];
$role = str_replace("_", "", $pattern);

$search = $level . " " . $pattern . " " . $match[2];
$replace = $level . " " . "ASSO @VOID@\n" . $level + 1 . " PHRASE " . $match[2] . "\n" . $level + 1 . " ROLE " . $role;
$search = (string) $level . " " . $pattern . " " . $match[2];
$replace = (string) $level . " " . "ASSO @VOID@\n" . (string) ($level + 1) . " PHRASE " . $match[2] . "\n" . (string) ($level + 1) . " ROLE " . $role;
$gedcom = str_replace($search, $replace, $gedcom);
}
}
Expand Down Expand Up @@ -430,18 +430,18 @@ public function convertToGedcom7(string $gedcom, bool $gedcom_l= false): string

//If allowed value
if (in_array(strtoupper($match[2]), $values)) {
$search = $level . " " . $enumset . " " . $match[2];
$replace = $level . " " . $enumset . " " . strtoupper($match[2]);
$search = (string) $level . " " . $enumset . " " . $match[2];
$replace = (string) $level . " " . $enumset . " " . strtoupper($match[2]);
$gedcom = str_replace($search, $replace, $gedcom);
}
//Use phrase instead
else {
$search = $level . " " . $enumset . " " . $match[2];
$search = (string) $level . " " . $enumset . " " . $match[2];
//For specific role descriptions
if ($enumset == "ROLE") {
$match[2] = str_replace(['(', ')'], ['', ''], $match[2]); // (<ROLE_DESCRIPTOR>)
}
$replace = $level . " " . $enumset . " OTHER\n" . $level + 1 . " PHRASE " . $match[2];
$replace = (string) $level . " " . $enumset . " OTHER\n" . (string) ($level + 1) . " PHRASE " . $match[2];
$gedcom = str_replace($search, $replace, $gedcom);
}
}
Expand Down Expand Up @@ -471,14 +471,14 @@ public function convertToGedcom7(string $gedcom, bool $gedcom_l= false): string

//If allowed type
if (in_array(strtoupper($found_type), $enum_values)) {
$search = $level . " " . $level2_tag . " " . $found_type;
$replace = $level . " " . $level2_tag . " " . strtoupper($found_type);
$search = (string) $level . " " . $level2_tag . " " . $found_type;
$replace = (string) $level . " " . $level2_tag . " " . strtoupper($found_type);
$gedcom = str_replace($search, $replace, $gedcom);
}
//Use OTHER/PHRASE instead
else {
$search = $level . " " . $level2_tag . " " . $found_type;
$replace = $level . " " . $level2_tag . " OTHER\n" . $level + 1 . " PHRASE " . $found_type;
$search = (string) $level . " " . $level2_tag . " " . $found_type;
$replace = (string) $level . " " . $level2_tag . " OTHER\n" . (string) ($level + 1) . " PHRASE " . $found_type;
$gedcom = str_replace($search, $replace, $gedcom);
}
}
Expand Down

0 comments on commit 42c726a

Please sign in to comment.