Skip to content

Commit

Permalink
Fix PHP lint issues (#32039)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw authored May 20, 2021
1 parent 2727490 commit 4ff70e6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 28 deletions.
1 change: 0 additions & 1 deletion lib/block-supports/colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function gutenberg_apply_colors_support( $block_type, $block_attributes ) {

$has_text_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'text' ), true ) );
$has_background_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'background' ), true ) );
$has_link_colors_support = _wp_array_get( $color_support, array( 'link' ), false );
$has_gradients_support = _wp_array_get( $color_support, array( 'gradients' ), false );
$classes = array();
$styles = array();
Expand Down
3 changes: 1 addition & 2 deletions lib/block-supports/elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* @return string Filtered block content.
*/
function gutenberg_render_elements_support( $block_content, $block ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
$link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );

/*
Expand All @@ -40,7 +39,7 @@ function gutenberg_render_elements_support( $block_content, $block ) {

// Like the layout hook this assumes the hook only applies to blocks with a single wrapper.
// Retrieve the opening tag of the first HTML element.
$html_element_matches;
$html_element_matches = array();
preg_match( '/<[^>]+>/', $block_content, $html_element_matches, PREG_OFFSET_CAPTURE );
$first_element = $html_element_matches[0][0];
// If the first HTML element has a class attribute just add the new class
Expand Down
39 changes: 19 additions & 20 deletions lib/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,54 +205,54 @@ class WP_Theme_JSON {
* - 'value': path to the value in theme.json and block attributes.
*/
const PROPERTIES_METADATA = array(
'background' => array(
'background' => array(
'value' => array( 'color', 'gradient' ),
),
'background-color' => array(
'background-color' => array(
'value' => array( 'color', 'background' ),
),
'border-radius' => array(
'border-radius' => array(
'value' => array( 'border', 'radius' ),
),
'border-color' => array(
'border-color' => array(
'value' => array( 'border', 'color' ),
),
'border-width' => array(
'border-width' => array(
'value' => array( 'border', 'width' ),
),
'border-style' => array(
'border-style' => array(
'value' => array( 'border', 'style' ),
),
'color' => array(
'color' => array(
'value' => array( 'color', 'text' ),
),
'font-family' => array(
'font-family' => array(
'value' => array( 'typography', 'fontFamily' ),
),
'font-size' => array(
'font-size' => array(
'value' => array( 'typography', 'fontSize' ),
),
'font-style' => array(
'font-style' => array(
'value' => array( 'typography', 'fontStyle' ),
),
'font-weight' => array(
'font-weight' => array(
'value' => array( 'typography', 'fontWeight' ),
),
'line-height' => array(
'line-height' => array(
'value' => array( 'typography', 'lineHeight' ),
),
'margin' => array(
'margin' => array(
'value' => array( 'spacing', 'margin' ),
'properties' => array( 'top', 'right', 'bottom', 'left' ),
),
'padding' => array(
'padding' => array(
'value' => array( 'spacing', 'padding' ),
'properties' => array( 'top', 'right', 'bottom', 'left' ),
),
'text-decoration' => array(
'text-decoration' => array(
'value' => array( 'typography', 'textDecoration' ),
),
'text-transform' => array(
'text-transform' => array(
'value' => array( 'typography', 'textTransform' ),
),
);
Expand Down Expand Up @@ -1214,12 +1214,11 @@ private static function remove_insecure_settings( $input ) {
* Processes a style node and returns the same node
* without the insecure styles.
*
* @param array $input Node to process.
* @param string $selector Selector for the node.
* @param array $input Node to process.
*
* @return array
*/
private static function remove_insecure_styles( $input, $selector ) {
private static function remove_insecure_styles( $input ) {
$output = array();
$declarations = self::compute_style_properties( $input );

Expand Down Expand Up @@ -1264,7 +1263,7 @@ public function remove_insecure_properties() {
continue;
}

$output = self::remove_insecure_styles( $input, $metadata['selector'] );
$output = self::remove_insecure_styles( $input );
if ( ! empty( $output ) ) {
gutenberg_experimental_set( $sanitized, $metadata['path'], $output );
}
Expand Down
2 changes: 1 addition & 1 deletion phpunit/class-elements-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function test_class_paragraph_link_color() {
array(
'blockName' => 'core/paragraph',
'attrs' => array(
'style' => array(
'style' => array(
'elements' => array(
'link' => array(
'color' => array(
Expand Down
4 changes: 2 additions & 2 deletions phpunit/class-rest-nav-menus-controller-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ public function test_get_item() {
$this->register_nav_menu_locations( array( 'primary' ) );
set_theme_mod( 'nav_menu_locations', array( 'primary' => $nav_menu_id ) );

$request = new WP_REST_Request( 'GET', '/__experimental/menus/' . $nav_menu_id );
$response = rest_get_server()->dispatch( $request );
$request = new WP_REST_Request( 'GET', '/__experimental/menus/' . $nav_menu_id );
$response = rest_get_server()->dispatch( $request );
$this->check_get_taxonomy_term_response( $response, $nav_menu_id );
}

Expand Down
4 changes: 2 additions & 2 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function test_get_settings() {
'elements' => array(
'link' => array(
'color' => array(
'text' => '#111',
'text' => '#111',
),
),
),
Expand Down Expand Up @@ -554,7 +554,7 @@ function test_remove_insecure_properties_removes_unsafe_styles() {
),
'blocks' => array(
'core/group' => array(
'color' => array(
'color' => array(
'text' => 'var:preset|color|dark-gray',
),
'elements' => array(
Expand Down

0 comments on commit 4ff70e6

Please sign in to comment.