@@ -256,16 +256,15 @@ public function obfuscateArrayProperties(array $array): array
256256
257257 private function _obfuscateWithDefault (mixed $ value , ?Obfuscator $ defaultObfuscator ): mixed
258258 {
259+ $ result = $ value ;
259260 if (is_scalar ($ value ) || is_null ($ value )) {
260- return $ this ->_obfuscateScalar ($ value , $ defaultObfuscator );
261+ $ result = $ this ->_obfuscateScalar ($ value , $ defaultObfuscator );
262+ } else if (is_object ($ value )) {
263+ $ result = $ this ->_obfuscateObject ($ value , $ defaultObfuscator );
264+ } else if (is_array ($ value )) {
265+ $ result = $ this ->_obfuscateArray ($ value , $ defaultObfuscator );
261266 }
262- if (is_object ($ value )) {
263- return $ this ->_obfuscateObject ($ value , $ defaultObfuscator );
264- }
265- if (is_array ($ value )) {
266- return $ this ->_obfuscateArray ($ value , $ defaultObfuscator );
267- }
268- return $ value ;
267+ return $ result ;
269268 }
270269
271270 // phpcs:disable Generic.Files.LineLength.TooLong
@@ -280,29 +279,28 @@ private function _obfuscateValue(mixed $value, ?array $propertyConfig, ?Obfuscat
280279 if (is_null ($ propertyConfig )) {
281280 return $ this ->_obfuscateWithDefault ($ value , $ defaultObfuscator );
282281 }
282+ $ result = $ value ;
283283 $ obfuscator = $ propertyConfig ['obfuscator ' ];
284284 if (is_scalar ($ value ) || is_null ($ value )) {
285- return $ this ->_obfuscateScalar ($ value , $ obfuscator );
286- }
287- if (is_object ($ value )) {
285+ $ result = $ this ->_obfuscateScalar ($ value , $ obfuscator );
286+ } else if (is_object ($ value )) {
288287 $ obfuscationMode = $ propertyConfig ['forObjects ' ];
289- return match ($ obfuscationMode ) {
288+ $ result = match ($ obfuscationMode ) {
290289 PropertyObfuscationMode::SKIP => $ value ,
291290 PropertyObfuscationMode::EXCLUDE => $ this ->_obfuscateWithDefault ($ value , $ defaultObfuscator ),
292291 PropertyObfuscationMode::INHERIT => $ this ->_obfuscateScalars ($ value , $ obfuscator ),
293292 PropertyObfuscationMode::INHERIT_OVERRIDABLE => $ this ->_obfuscateWithDefault ($ value , $ obfuscator ),
294293 };
295- }
296- if (is_array ($ value )) {
294+ } else if (is_array ($ value )) {
297295 $ obfuscationMode = $ propertyConfig ['forArrays ' ];
298- return match ($ obfuscationMode ) {
296+ $ result = match ($ obfuscationMode ) {
299297 PropertyObfuscationMode::SKIP => $ value ,
300298 PropertyObfuscationMode::EXCLUDE => $ this ->_obfuscateWithDefault ($ value , $ defaultObfuscator ),
301299 PropertyObfuscationMode::INHERIT => $ this ->_obfuscateScalars ($ value , $ obfuscator ),
302300 PropertyObfuscationMode::INHERIT_OVERRIDABLE => $ this ->_obfuscateWithDefault ($ value , $ obfuscator ),
303301 };
304302 }
305- return $ value ;
303+ return $ result ;
306304 }
307305
308306 private function _obfuscateObject (object $ object , ?Obfuscator $ defaultObfuscator ): stdClass
@@ -318,9 +316,9 @@ private function _obfuscateObject(object $object, ?Obfuscator $defaultObfuscator
318316 /**
319317 * Obfuscates an array.
320318 *
321- * @param array<mixed> $array
319+ * @param array<int|string, mixed> $array
322320 *
323- * @return array<mixed>
321+ * @return array<int|string, mixed>
324322 */
325323 private function _obfuscateArray (array $ array , ?Obfuscator $ defaultObfuscator ): array
326324 {
@@ -338,24 +336,23 @@ private function _obfuscateArray(array $array, ?Obfuscator $defaultObfuscator):
338336
339337 private function _obfuscateScalars (mixed $ value , Obfuscator $ obfuscator ): mixed
340338 {
339+ $ result = $ value ;
341340 if (is_scalar ($ value ) || is_null ($ value )) {
342- return $ this ->_obfuscateScalar ($ value , $ obfuscator );
343- }
344- if (is_object ($ value )) {
341+ $ result = $ this ->_obfuscateScalar ($ value , $ obfuscator );
342+ } else if (is_object ($ value )) {
345343 $ obfuscated = new stdClass ();
346344 foreach ($ value as $ propertyName => $ propertyValue ) {
347345 $ obfuscated ->$ propertyName = $ this ->_obfuscateScalars ($ propertyValue , $ obfuscator );
348346 }
349- return $ obfuscated ;
350- }
351- if (is_array ($ value )) {
347+ $ result = $ obfuscated ;
348+ } else if (is_array ($ value )) {
352349 $ obfuscated = [];
353350 foreach ($ value as $ propertyName => $ propertyValue ) {
354351 $ obfuscated [$ propertyName ] = $ this ->_obfuscateScalars ($ propertyValue , $ obfuscator );
355352 }
356- return $ obfuscated ;
353+ $ result = $ obfuscated ;
357354 }
358- return $ value ;
355+ return $ result ;
359356 }
360357
361358 /**
0 commit comments