@@ -293,7 +293,7 @@ protected function collectVars(Throwable $exception, int $statusCode): array
293293 $ trace = $ exception ->getTrace ();
294294
295295 if ($ this ->config ->sensitiveDataInTrace !== []) {
296- $ this ->maskSensitiveData ($ trace , $ this ->config ->sensitiveDataInTrace );
296+ $ trace = $ this ->maskSensitiveData ($ trace , $ this ->config ->sensitiveDataInTrace );
297297 }
298298
299299 return [
@@ -311,8 +311,10 @@ protected function collectVars(Throwable $exception, int $statusCode): array
311311 * Mask sensitive data in the trace.
312312 *
313313 * @param array|object $trace
314+ *
315+ * @return array|object
314316 */
315- protected function maskSensitiveData (& $ trace , array $ keysToMask , string $ path = '' )
317+ protected function maskSensitiveData ($ trace , array $ keysToMask , string $ path = '' )
316318 {
317319 foreach ($ keysToMask as $ keyToMask ) {
318320 $ explode = explode ('/ ' , $ keyToMask );
@@ -327,15 +329,17 @@ protected function maskSensitiveData(&$trace, array $keysToMask, string $path =
327329 }
328330 }
329331
330- if (is_object ($ trace )) {
331- $ trace = get_object_vars ($ trace );
332- }
333-
334332 if (is_array ($ trace )) {
335333 foreach ($ trace as $ pathKey => $ subarray ) {
336- $ this ->maskSensitiveData ($ subarray , $ keysToMask , $ path . '/ ' . $ pathKey );
334+ $ trace [$ pathKey ] = $ this ->maskSensitiveData ($ subarray , $ keysToMask , $ path . '/ ' . $ pathKey );
335+ }
336+ } elseif (is_object ($ trace )) {
337+ foreach ($ trace as $ pathKey => $ subarray ) {
338+ $ trace ->{$ pathKey } = $ this ->maskSensitiveData ($ subarray , $ keysToMask , $ path . '/ ' . $ pathKey );
337339 }
338340 }
341+
342+ return $ trace ;
339343 }
340344
341345 /**
0 commit comments