From f251a3c750468e126a996105c544636630a88341 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Oct 2023 08:38:30 +0900 Subject: [PATCH] refactor: replace str_ireplace() with in_array() php > ini_set('display_errors', '1'); php > var_dump(ini_get('display_errors')); string(1) "1" php > ini_set('display_errors', 1); php > var_dump(ini_get('display_errors')); string(1) "1" php > ini_set('display_errors', true); php > var_dump(ini_get('display_errors')); string(1) "1" php > ini_set('display_errors', 'true'); php > var_dump(ini_get('display_errors')); string(4) "true" --- system/Debug/ExceptionHandler.php | 10 +++++----- system/Debug/Exceptions.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/system/Debug/ExceptionHandler.php b/system/Debug/ExceptionHandler.php index 46b855e5eca7..63449888ffb5 100644 --- a/system/Debug/ExceptionHandler.php +++ b/system/Debug/ExceptionHandler.php @@ -130,11 +130,11 @@ protected function determineView(Throwable $exception, string $templatePath): st $view = 'production.php'; if ( - str_ireplace( - ['off', 'none', 'no', 'false', 'null', '0'], - '', - ini_get('display_errors') - ) !== '' + in_array( + strtolower(ini_get('display_errors')), + ['1', 'true', 'on', 'yes'], + true + ) ) { $view = 'error_exception.php'; } diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index b127a58241b0..bbcfcc8e8889 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -254,11 +254,11 @@ protected function determineView(Throwable $exception, string $templatePath): st $templatePath = rtrim($templatePath, '\\/ ') . DIRECTORY_SEPARATOR; if ( - str_ireplace( - ['off', 'none', 'no', 'false', 'null', '0'], - '', - ini_get('display_errors') - ) !== '' + in_array( + strtolower(ini_get('display_errors')), + ['1', 'true', 'on', 'yes'], + true + ) ) { $view = 'error_exception.php'; }