From 3f2166f8ec6ee9213eb056ac130f5d0af50906cb Mon Sep 17 00:00:00 2001 From: Bruno Moreira De Barros Date: Thu, 11 Feb 2016 08:09:59 +0000 Subject: [PATCH 1/2] Fixes a "strftime() expects parameter 2 to be integer, string given" PHP Warning. --- src/FontLib/BinaryStream.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/FontLib/BinaryStream.php b/src/FontLib/BinaryStream.php index f83039e..89b14a4 100644 --- a/src/FontLib/BinaryStream.php +++ b/src/FontLib/BinaryStream.php @@ -275,10 +275,8 @@ public function readLongDateTime() { $this->readUInt32(); // ignored $date = $this->readUInt32() - 2082844800; - if ($date > PHP_INT_MAX) { - $date = PHP_INT_MAX; - } elseif ($date < PHP_INT_MIN) { - $date = PHP_INT_MIN; + if (is_string($date) || $date > PHP_INT_MAX || $date < PHP_INT_MIN) { + $date = 0; } return strftime("%Y-%m-%d %H:%M:%S", $date); From e8a3335ab7cbc8c362e73f2902a40ac8a4d25eb6 Mon Sep 17 00:00:00 2001 From: Bruno Moreira De Barros Date: Fri, 12 Feb 2016 09:13:39 +0000 Subject: [PATCH 2/2] Don't rely on PHP_INT_MIN if it isn't defined (PHP < 7). --- src/FontLib/BinaryStream.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/FontLib/BinaryStream.php b/src/FontLib/BinaryStream.php index 89b14a4..4e0735b 100644 --- a/src/FontLib/BinaryStream.php +++ b/src/FontLib/BinaryStream.php @@ -274,8 +274,11 @@ public function writeFixed($data) { public function readLongDateTime() { $this->readUInt32(); // ignored $date = $this->readUInt32() - 2082844800; + + # PHP_INT_MIN isn't defined in PHP < 7.0 + $php_int_min = defined("PHP_INT_MIN") ? PHP_INT_MIN : ~PHP_INT_MAX; - if (is_string($date) || $date > PHP_INT_MAX || $date < PHP_INT_MIN) { + if (is_string($date) || $date > PHP_INT_MAX || $date < $php_int_min) { $date = 0; }