@@ -124,33 +124,20 @@ protected function apply_rule(array &$data, string $key, string $rule): void {
124124
125125 $ keys = explode ( '. ' , $ key );
126126 $ last_key = array_pop ( $ keys );
127- $ current = $ this ->navigate_to_parent ( $ data , $ keys );
128127
129- if ( null === $ current || ! array_key_exists ( $ last_key , $ current ) ) {
130- return ;
131- }
132-
133- $ this ->apply_sanitization_rule ( $ current , $ last_key , $ rule );
134- }
135-
136- /**
137- * Navigate to the parent array of the target key.
138- *
139- * @param array<string, mixed> $data The data array to navigate.
140- * @param array<string> $keys The keys to navigate through.
141- *
142- * @return array<string, mixed>|null The parent array or null if not found.
143- */
144- protected function &navigate_to_parent (array &$ data , array $ keys ): ?array {
145128 $ current = &$ data ;
146129 foreach ( $ keys as $ segment ) {
147130 if ( ! is_array ( $ current ) || ! isset ( $ current [ $ segment ] ) ) {
148- $ null = null ;
149- return $ null ;
131+ return ;
150132 }
151133 $ current = &$ current [ $ segment ];
152134 }
153- return $ current ;
135+
136+ if ( ! is_array ( $ current ) || ! array_key_exists ( $ last_key , $ current ) ) {
137+ return ;
138+ }
139+
140+ $ this ->apply_sanitization_rule ( $ current , $ last_key , $ rule );
154141 }
155142
156143 /**
@@ -199,8 +186,8 @@ public function __invoke( LogRecord $record ): LogRecord {
199186 return $ record ;
200187 }
201188
202- $ context = $ record[ ' context ' ] ?? [] ;
203- $ extra = $ record[ ' extra ' ] ?? [] ;
189+ $ context = $ record-> context ;
190+ $ extra = $ record-> extra ;
204191 foreach ( $ rules as $ key => $ rule ) {
205192 $ this ->apply_rule ( $ context , $ key , $ rule );
206193 $ this ->apply_rule ( $ extra , $ key , $ rule );
0 commit comments