From 31cad9151aa2a7070e73bc53dc2d104fdce7e0c6 Mon Sep 17 00:00:00 2001 From: LinkingYou Date: Thu, 19 Dec 2019 16:40:08 +0100 Subject: [PATCH 1/4] Fixes a problem with php 7.4 This would fix the issue #75 --- src/FontLib/AdobeFontMetrics.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FontLib/AdobeFontMetrics.php b/src/FontLib/AdobeFontMetrics.php index a62daaa..a0e973b 100644 --- a/src/FontLib/AdobeFontMetrics.php +++ b/src/FontLib/AdobeFontMetrics.php @@ -139,7 +139,7 @@ function write($file, $encoding = null) { $this->endSection("CharMetrics"); $kern = $font->getData("kern", "subtable"); - $tree = $kern["tree"]; + $tree = is_array($kern) ? $kern["tree"] : null; if (!$encoding && is_array($tree)) { $this->startSection("KernData"); From d8dbf5a0b66c6f16d9c678c23c94b28414bd96f4 Mon Sep 17 00:00:00 2001 From: Jan Piskvor Martinec Date: Thu, 16 Jan 2020 16:51:33 +0100 Subject: [PATCH 2/4] Do not emit E_NOTICEs on r/w errors --- src/FontLib/BinaryStream.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/FontLib/BinaryStream.php b/src/FontLib/BinaryStream.php index ab10454..65dd3a4 100644 --- a/src/FontLib/BinaryStream.php +++ b/src/FontLib/BinaryStream.php @@ -38,16 +38,18 @@ class BinaryStream { const modeReadWrite = "rb+"; static function backtrace() { - var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)); - } - - /** - * Open a font file in read mode - * - * @param string $filename The file name of the font to open - * - * @return bool - */ + /** @noinspection ForgottenDebugOutputInspection */ + var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)); + } + + /** + * Open a font file in read mode + * + * @param string $filename The file name of the font to open + * + * @return bool + * @throws \Exception + */ public function load($filename) { return $this->open($filename, self::modeRead); } @@ -142,7 +144,8 @@ public function read($n) { return ""; } - return fread($this->f, $n); + /** @noinspection PhpUsageOfSilenceOperatorInspection - handle the return data, DO NOT spew E_NOTICEs */ + return @fread($this->f, $n); } public function write($data, $length = null) { @@ -150,7 +153,8 @@ public function write($data, $length = null) { return 0; } - return fwrite($this->f, $data, $length); + /** @noinspection PhpUsageOfSilenceOperatorInspection - handle the return data, DO NOT spew E_NOTICEs */ + return @fwrite($this->f, $data, $length); } public function readUInt8() { From d89107bcfe4494f5619884694e23d52b17b6fe60 Mon Sep 17 00:00:00 2001 From: Jan Piskvor Martinec Date: Wed, 29 Apr 2020 10:34:27 +0200 Subject: [PATCH 3/4] indentation fix --- src/FontLib/BinaryStream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FontLib/BinaryStream.php b/src/FontLib/BinaryStream.php index 65dd3a4..5a75678 100644 --- a/src/FontLib/BinaryStream.php +++ b/src/FontLib/BinaryStream.php @@ -145,7 +145,7 @@ public function read($n) { } /** @noinspection PhpUsageOfSilenceOperatorInspection - handle the return data, DO NOT spew E_NOTICEs */ - return @fread($this->f, $n); + return @fread($this->f, $n); } public function write($data, $length = null) { From 1e9dd5c00c06cef0fd2e748d9a20f62768929ae4 Mon Sep 17 00:00:00 2001 From: Jan Piskvor Martinec Date: Wed, 29 Apr 2020 10:35:06 +0200 Subject: [PATCH 4/4] remove PHPStorm's @noinspection --- src/FontLib/BinaryStream.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/FontLib/BinaryStream.php b/src/FontLib/BinaryStream.php index 5a75678..414ef03 100644 --- a/src/FontLib/BinaryStream.php +++ b/src/FontLib/BinaryStream.php @@ -38,7 +38,6 @@ class BinaryStream { const modeReadWrite = "rb+"; static function backtrace() { - /** @noinspection ForgottenDebugOutputInspection */ var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)); } @@ -144,7 +143,7 @@ public function read($n) { return ""; } - /** @noinspection PhpUsageOfSilenceOperatorInspection - handle the return data, DO NOT spew E_NOTICEs */ + // handle the return data, DO NOT spew E_NOTICEs return @fread($this->f, $n); } @@ -153,7 +152,7 @@ public function write($data, $length = null) { return 0; } - /** @noinspection PhpUsageOfSilenceOperatorInspection - handle the return data, DO NOT spew E_NOTICEs */ + // handle the return data, DO NOT spew E_NOTICEs return @fwrite($this->f, $data, $length); }