Skip to content

Commit c286fb8

Browse files
committed
Minor Changes
Apply some suggestions from @MarkBaker
1 parent 7fe5ee8 commit c286fb8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ public static function format($value, string $format): string
123123
// general syntax: [$<Currency string>-<language info>]
124124
// language info is in hexadecimal
125125
// strip off chinese part like [DBNum1][$-804]
126-
$format = preg_replace('/^(\[DBNum\d\])*(\[\$[^\]]*\])/i', '', $format) ?? '';
126+
$format = (string) preg_replace('/^(\[DBNum\d\])*(\[\$[^\]]*\])/i', '', $format);
127127

128128
// OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case;
129129
// but we don't want to change any quoted strings
130130
/** @var callable */
131-
$callable = ['self', 'setLowercaseCallback'];
131+
$callable = [self::class, 'setLowercaseCallback'];
132132
$format = preg_replace_callback('/(?:^|")([^"]*)(?:$|")/', $callable, $format);
133133

134134
// Only process the non-quoted blocks for date format characters
@@ -159,14 +159,14 @@ public static function format($value, string $format): string
159159

160160
// escape any quoted characters so that DateTime format() will render them correctly
161161
/** @var callable */
162-
$callback = ['self', 'escapeQuotesCallback'];
163-
$format = preg_replace_callback('/"(.*)"/U', $callback, $format) ?? '';
162+
$callback = [self::class, 'escapeQuotesCallback'];
163+
$format = (string) preg_replace_callback('/"(.*)"/U', $callback, $format);
164164

165165
$dateObj = Date::excelToDateTimeObject($value);
166166
// If the colon preceding minute had been quoted, as happens in
167167
// Excel 2003 XML formats, m will not have been changed to i above.
168168
// Change it now.
169-
$format = \preg_replace('/\\\\:m/', ':i', $format) ?? '';
169+
$format = (string) \preg_replace('/\\\\:m/', ':i', $format);
170170

171171
return $dateObj->format($format);
172172
}

0 commit comments

Comments
 (0)