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 ()) !== null ) {
8061 $ firstException = $ prevException ;
8162 }
8263
@@ -110,17 +91,18 @@ protected function maskSensitiveData(array $trace, array $keysToMask, string $pa
11091 }
11192
11293 /**
113- * @param array|object $args
94+ * @param array<string, mixed>|object $args
95+ * @param array<int, string> $keysToMask
11496 *
115- * @return array|object
97+ * @return array<string, mixed> |object
11698 */
117- private function maskData ($ args , array $ keysToMask , string $ path = '' )
99+ private function maskData (array | object $ args , array $ keysToMask , string $ path = '' ): array | object
118100 {
119- foreach ($ keysToMask as $ keyToMask ) {
120- $ explode = explode ('/ ' , $ keyToMask );
101+ foreach ($ keysToMask as $ key ) {
102+ $ explode = explode ('/ ' , $ key );
121103 $ index = end ($ explode );
122104
123- if (str_starts_with (strrev ($ path . '/ ' . $ index ), strrev ($ keyToMask ))) {
105+ if (str_starts_with (strrev ($ path . '/ ' . $ index ), strrev ($ key ))) {
124106 if (is_array ($ args ) && array_key_exists ($ index , $ args )) {
125107 $ args [$ index ] = '****************** ' ;
126108 } elseif (
@@ -136,7 +118,7 @@ private function maskData($args, array $keysToMask, string $path = '')
136118 foreach ($ args as $ pathKey => $ subarray ) {
137119 $ args [$ pathKey ] = $ this ->maskData ($ subarray , $ keysToMask , $ path . '/ ' . $ pathKey );
138120 }
139- } elseif ( is_object ( $ args )) {
121+ } else {
140122 foreach ($ args as $ pathKey => $ subarray ) {
141123 $ args ->{$ pathKey } = $ this ->maskData ($ subarray , $ keysToMask , $ path . '/ ' . $ pathKey );
142124 }
0 commit comments