Skip to content

Commit f6d1257

Browse files
committed
Merge pull request #46 from BrunoDeBarros/patch-3
Fixes "strftime() expects parameter 2 to be integer, string given" PHP Warning, and PHP <7 compatibility issue.
2 parents 1e9e053 + e8a3335 commit f6d1257

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/FontLib/BinaryStream.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,12 @@ public function writeFixed($data) {
274274
public function readLongDateTime() {
275275
$this->readUInt32(); // ignored
276276
$date = $this->readUInt32() - 2082844800;
277+
278+
# PHP_INT_MIN isn't defined in PHP < 7.0
279+
$php_int_min = defined("PHP_INT_MIN") ? PHP_INT_MIN : ~PHP_INT_MAX;
277280

278-
if ($date > PHP_INT_MAX) {
279-
$date = PHP_INT_MAX;
280-
} elseif ($date < PHP_INT_MIN) {
281-
$date = PHP_INT_MIN;
281+
if (is_string($date) || $date > PHP_INT_MAX || $date < $php_int_min) {
282+
$date = 0;
282283
}
283284

284285
return strftime("%Y-%m-%d %H:%M:%S", $date);

0 commit comments

Comments
 (0)