Skip to content

Commit

Permalink
Move lowecasing functionality at the beginning of the helper
Browse files Browse the repository at this point in the history
There are some early returns that would make lowecasing not happen even if we passed the last parameter as true.
  • Loading branch information
dingo-d committed Sep 18, 2023
1 parent 4556d69 commit 0cdebde
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions WordPress/Helpers/RulesetPropertyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ final class RulesetPropertyHelper {
* @return array
*/
public static function merge_custom_array( $custom, array $base = array(), $flip = true, $lowercaseKeyValues = false ) {
if ( $lowercaseKeyValues ) {
$base = array_map( 'strtolower', $base );

Check warning on line 58 in WordPress/Helpers/RulesetPropertyHelper.php

View workflow job for this annotation

GitHub Actions / Run code sniffs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

Check warning on line 58 in WordPress/Helpers/RulesetPropertyHelper.php

View workflow job for this annotation

GitHub Actions / Run code sniffs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
$custom = array_map( 'strtolower', $custom );
$base = array_change_key_case( $base );

Check warning on line 60 in WordPress/Helpers/RulesetPropertyHelper.php

View workflow job for this annotation

GitHub Actions / Run code sniffs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

Check warning on line 60 in WordPress/Helpers/RulesetPropertyHelper.php

View workflow job for this annotation

GitHub Actions / Run code sniffs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
$custom = array_change_key_case( $custom );
}

if ( true === $flip ) {
$base = array_filter( $base );
}
Expand All @@ -70,13 +77,6 @@ public static function merge_custom_array( $custom, array $base = array(), $flip
return $custom;
}

if ( $lowercaseKeyValues ) {
$base = array_map( 'strtolower', $base );
$custom = array_map( 'strtolower', $custom );
$base = array_change_key_case( $base );
$custom = array_change_key_case( $custom );
}

return array_merge( $base, $custom );
}
}

0 comments on commit 0cdebde

Please sign in to comment.