1313
1414namespace CodeIgniter \Debug ;
1515
16- use CodeIgniter \HTTP \CLIRequest ;
17- use CodeIgniter \HTTP \IncomingRequest ;
18- use CodeIgniter \HTTP \RequestInterface ;
19- use CodeIgniter \HTTP \ResponseInterface ;
2016use Config \Exceptions as ExceptionsConfig ;
2117use Throwable ;
2218
@@ -53,21 +49,6 @@ public function __construct(ExceptionsConfig $config)
5349 }
5450 }
5551
56- /**
57- * The main entry point into the handler.
58- *
59- * @param CLIRequest|IncomingRequest $request
60- *
61- * @return void
62- */
63- abstract public function handle (
64- Throwable $ exception ,
65- RequestInterface $ request ,
66- ResponseInterface $ response ,
67- int $ statusCode ,
68- int $ exitCode ,
69- );
70-
7152 /**
7253 * Gathers the variables that will be made available to the view.
7354 */
@@ -76,7 +57,7 @@ protected function collectVars(Throwable $exception, int $statusCode): array
7657 // Get the first exception.
7758 $ firstException = $ exception ;
7859
79- while ($ prevException = $ firstException ->getPrevious ()) {
60+ while (( $ prevException = $ firstException ->getPrevious ()) instanceof Throwable ) {
8061 $ firstException = $ prevException ;
8162 }
8263
@@ -103,24 +84,22 @@ protected function collectVars(Throwable $exception, int $statusCode): array
10384 protected function maskSensitiveData (array $ trace , array $ keysToMask , string $ path = '' ): array
10485 {
10586 foreach ($ trace as $ i => $ line ) {
106- $ trace [$ i ]['args ' ] = $ this ->maskData ($ line ['args ' ], $ keysToMask );
87+ $ trace [$ i ]['args ' ] = $ this ->maskData ($ line ['args ' ], $ keysToMask, $ path );
10788 }
10889
10990 return $ trace ;
11091 }
11192
11293 /**
113- * @param array|object $args
114- *
115- * @return array|object
94+ * @param array<int, string> $keysToMask
11695 */
117- private function maskData ($ args , array $ keysToMask , string $ path = '' )
96+ private function maskData (mixed $ args , array $ keysToMask , string $ path = '' ): mixed
11897 {
119- foreach ($ keysToMask as $ keyToMask ) {
120- $ explode = explode ('/ ' , $ keyToMask );
98+ foreach ($ keysToMask as $ key ) {
99+ $ explode = explode ('/ ' , $ key );
121100 $ index = end ($ explode );
122101
123- if (str_starts_with (strrev ($ path . '/ ' . $ index ), strrev ($ keyToMask ))) {
102+ if (str_starts_with (strrev ($ path . '/ ' . $ index ), strrev ($ key ))) {
124103 if (is_array ($ args ) && array_key_exists ($ index , $ args )) {
125104 $ args [$ index ] = '****************** ' ;
126105 } elseif (
0 commit comments