From e7165a33b282ab4d20b3863825caadb46313d62b Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Fri, 7 Jan 2022 21:35:06 -0500 Subject: [PATCH] Only check for mbstring.func_overload in < PHP 8.x Fixes #385 --- src/Mustache/Tokenizer.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index 1846675f..2a172c34 100644 --- a/src/Mustache/Tokenizer.php +++ b/src/Mustache/Tokenizer.php @@ -97,11 +97,16 @@ public function scan($text, $delimiters = '') // Setting mbstring.func_overload makes things *really* slow. // Let's do everyone a favor and scan this string as ASCII instead. // + // The INI directive was removed in PHP 8.0 so we don't need to check there (and can drop it + // when we remove support for older versions of PHP). + // // @codeCoverageIgnoreStart $encoding = null; - if (function_exists('mb_internal_encoding') && ini_get('mbstring.func_overload') & 2) { - $encoding = mb_internal_encoding(); - mb_internal_encoding('ASCII'); + if (version_compare(PHP_VERSION, '8.0.0', '<')) { + if (function_exists('mb_internal_encoding') && ini_get('mbstring.func_overload') & 2) { + $encoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } } // @codeCoverageIgnoreEnd