From 9c3f6e973a5ce9f7d87fdceaf810494e26a3b55d Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sat, 12 Feb 2022 12:37:31 +0800 Subject: [PATCH] Deprecate both `Exceptions::cleanPath()` and `BaseCollector::cleanPath()` --- app/Views/errors/html/error_exception.php | 10 +++--- system/Debug/Exceptions.php | 2 ++ .../Toolbar/Collectors/BaseCollector.php | 8 ++--- system/Debug/Toolbar/Collectors/Files.php | 2 +- tests/system/Debug/ExceptionsTest.php | 32 ------------------- user_guide_src/source/changelogs/v4.2.0.rst | 1 + 6 files changed, 12 insertions(+), 43 deletions(-) diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php index 693afed491f5..4ddeac1a2ec4 100644 --- a/app/Views/errors/html/error_exception.php +++ b/app/Views/errors/html/error_exception.php @@ -30,7 +30,7 @@
-

at line

+

at line

@@ -64,12 +64,12 @@ - + {PHP internal code} @@ -350,7 +350,7 @@
    -
  1. +
diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index a65be7a2ad2f..0dbc7e293ae9 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -318,6 +318,8 @@ protected function determineCodes(Throwable $exception): array /** * This makes nicer looking paths for the error output. + * + * @deprecated Use dedicated `clean_path()` function. */ public static function cleanPath(string $file): string { diff --git a/system/Debug/Toolbar/Collectors/BaseCollector.php b/system/Debug/Toolbar/Collectors/BaseCollector.php index 5d8d39ff169f..e8aaad9ba115 100644 --- a/system/Debug/Toolbar/Collectors/BaseCollector.php +++ b/system/Debug/Toolbar/Collectors/BaseCollector.php @@ -11,8 +11,6 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Debug\Exceptions; - /** * Base Toolbar collector */ @@ -174,13 +172,13 @@ public function display() } /** - * Clean Path - * * This makes nicer looking paths for the error output. + * + * @deprecated Use the dedicated `clean_path()` function. */ public function cleanPath(string $file): string { - return Exceptions::cleanPath($file); + return clean_path($file); } /** diff --git a/system/Debug/Toolbar/Collectors/Files.php b/system/Debug/Toolbar/Collectors/Files.php index d6aefd2c3fe9..ea14dcfd1ec3 100644 --- a/system/Debug/Toolbar/Collectors/Files.php +++ b/system/Debug/Toolbar/Collectors/Files.php @@ -58,7 +58,7 @@ public function display(): array $userFiles = []; foreach ($rawFiles as $file) { - $path = $this->cleanPath($file); + $path = clean_path($file); if (strpos($path, 'SYSTEMPATH') !== false) { $coreFiles[] = [ diff --git a/tests/system/Debug/ExceptionsTest.php b/tests/system/Debug/ExceptionsTest.php index 08d521ede2f4..247629933c69 100644 --- a/tests/system/Debug/ExceptionsTest.php +++ b/tests/system/Debug/ExceptionsTest.php @@ -61,36 +61,4 @@ public function testDetermineCodes(): void $this->assertSame([500, 1], $determineCodes(new RuntimeException('That.', 600))); $this->assertSame([404, 1], $determineCodes(new RuntimeException('There.', 404))); } - - /** - * @dataProvider dirtyPathsProvider - */ - public function testCleanPaths(string $file, string $expected): void - { - $this->assertSame($expected, Exceptions::cleanPath($file)); - } - - public function dirtyPathsProvider() - { - $ds = DIRECTORY_SEPARATOR; - - yield from [ - [ - APPPATH . 'Config' . $ds . 'App.php', - 'APPPATH' . $ds . 'Config' . $ds . 'App.php', - ], - [ - SYSTEMPATH . 'CodeIgniter.php', - 'SYSTEMPATH' . $ds . 'CodeIgniter.php', - ], - [ - VENDORPATH . 'autoload.php', - 'VENDORPATH' . $ds . 'autoload.php', - ], - [ - FCPATH . 'index.php', - 'FCPATH' . $ds . 'index.php', - ], - ]; - } } diff --git a/user_guide_src/source/changelogs/v4.2.0.rst b/user_guide_src/source/changelogs/v4.2.0.rst index 3d2a2223350f..395408641e9f 100644 --- a/user_guide_src/source/changelogs/v4.2.0.rst +++ b/user_guide_src/source/changelogs/v4.2.0.rst @@ -40,6 +40,7 @@ Deprecations ************ - ``CodeIgniter\Database\SQLSRV\Connection::getError()`` is deprecated. Use ``CodeIgniter\Database\SQLSRV\Connection::error()`` instead. +- ``CodeIgniter\Debug\Exceptions::cleanPath()`` and ``CodeIgniter\Debug\Toolbar\Collectors\BaseCollector::cleanPath()`` are deprecated. Use the ``clean_path()`` function instead. Bugs Fixed **********