FormatMetadata::formatFraction: Don't risk passing null to preg_match

We do this above for formatNum(), so this approach seems to be
idiomatic to this code.

Bug: T394989
Change-Id: I804cc180e5de8ddf22b70e9f532f0f2416713eb7
(cherry picked from commit a6a777ae853f0f989b1438bd5c1c3af5dbed135a)
This commit is contained in:
James D. Forrester 2025-05-22 09:58:43 -04:00 committed by Reedy
parent 4c2a44d9e0
commit 700a639140

View file

@ -1378,6 +1378,7 @@ class FormatMetadata extends ContextSource {
*/
private function formatFraction( $num ) {
$m = [];
$num ??= '';
if ( preg_match( '/^(-?\d+)\/(\d+)$/', $num, $m ) ) {
$numerator = (int)$m[1];
$denominator = (int)$m[2];