Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHPCS errors/warnings #7638

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@
<exclude name="Universal.Operators.DisallowShortTernary" />

<!-- @TODO(P0): Fix these once WPCS is merged on develop and remove the exclusions. -->
<exclude name="PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose" />
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound" />
<exclude name="PSR2.Files.EndFileNewline.TooMany" />
<exclude name="Universal.CodeAnalysis.NoEchoSprintf.Found" />
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody" />
<exclude name="Universal.ControlStructures.DisallowLonelyIf.Found" />
<exclude name="Generic.WhiteSpace.IncrementDecrementSpacing.SpaceAfterDecrement" />
Expand Down
2 changes: 1 addition & 1 deletion back-compat/templates-v0-3/style.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
.amp-wp-content, .amp-wp-title-bar div {
<?php $content_max_width = absint( $this->get( 'content_max_width' ) ); ?>
<?php if ( $content_max_width > 0 ) : ?>
max-width: <?php echo sprintf( '%dpx', $content_max_width ); ?>;
max-width: <?php printf( '%dpx', $content_max_width ); ?>;
margin: 0 auto;
<?php endif; ?>
}
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-amp-admin-pointer.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@

add_action(
'admin_print_footer_scripts',
function() {
function () {

Check warning on line 153 in includes/admin/class-amp-admin-pointer.php

View check run for this annotation

Codecov / codecov/patch

includes/admin/class-amp-admin-pointer.php#L153

Added line #L153 was not covered by tests
$this->print_js();
}
);
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-amp-admin-pointers.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
'position' => [
'align' => 'middle',
],
'active_callback' => static function() {
'active_callback' => static function () {

Check warning on line 72 in includes/admin/class-amp-admin-pointers.php

View check run for this annotation

Codecov / codecov/patch

includes/admin/class-amp-admin-pointers.php#L72

Added line #L72 was not covered by tests
return version_compare( strtok( AMP__VERSION, '-' ), '1.1', '<' );
},
]
Expand Down
1 change: 0 additions & 1 deletion includes/class-amp-comment-walker.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function start_el( &$output, $comment, $depth = 0, $args = [], $id = 0 )
}

$output .= $new_tag . substr( ltrim( $new_out ), strlen( $tag ) );

}

/**
Expand Down
6 changes: 3 additions & 3 deletions includes/class-amp-service-worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function add_cdn_script_caching( $service_workers ) {
// Add AMP scripts to runtime cache which will then get stale-while-revalidate strategy.
$service_workers->register(
'amp-cdn-runtime-caching',
static function() {
static function () {
$urls = AMP_Service_Worker::get_precached_script_cdn_urls();
if ( empty( $urls ) ) {
return '';
Expand Down Expand Up @@ -356,8 +356,8 @@ public static function handle_service_worker_iframe_install() {
// Die in a way that can be unit tested.
add_filter(
'wp_die_handler',
static function() {
return static function() {
static function () {
return static function () {
die();
};
},
Expand Down
16 changes: 8 additions & 8 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public static function finish_init() {

add_filter(
'template_include',
static function() {
static function () {
return AMP__DIR__ . '/includes/templates/reader-template-loader.php';
},
PHP_INT_MAX
Expand Down Expand Up @@ -859,21 +859,21 @@ public static function add_hooks() {
// Prevent MediaElement.js scripts/styles from being enqueued.
add_filter(
'wp_video_shortcode_library',
static function() {
static function () {
return 'amp';
}
);
add_filter(
'wp_audio_shortcode_library',
static function() {
static function () {
return 'amp';
}
);

// Don't show loading indicator on custom logo since it makes most sense for larger images.
add_filter(
'get_custom_logo',
static function( $html ) {
static function ( $html ) {
return preg_replace( '/(?<=<img\s)/', ' data-amp-noloading="" ', $html );
},
1
Expand All @@ -900,7 +900,7 @@ static function( $html ) {
add_filter( 'get_header_image_tag', [ __CLASS__, 'amend_header_image_with_video_header' ], PHP_INT_MAX );
add_action(
'wp_print_footer_scripts',
static function() {
static function () {
wp_dequeue_script( 'wp-custom-header' );
},
0
Expand Down Expand Up @@ -1252,14 +1252,14 @@ public static function init_admin_bar() {
// Emulate customize support script in PHP, to assume Customizer.
add_action(
'admin_bar_menu',
static function() {
static function () {
remove_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
},
41
);
add_filter(
'body_class',
static function( $body_classes ) {
static function ( $body_classes ) {
return array_merge(
array_diff(
$body_classes,
Expand Down Expand Up @@ -2141,7 +2141,7 @@ public static function prepare_response( $response, $args = [] ) {

if ( count( $errors ) > 0 ) {
$error_messages = array_map(
static function( Optimizer\Error $error ) {
static function ( Optimizer\Error $error ) {
return ' - ' . $error->getCode() . ': ' . $error->getMessage();
},
iterator_to_array( $errors )
Expand Down
1 change: 0 additions & 1 deletion includes/embeds/class-amp-issuu-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@ public function filter_embed_oembed_html( $return, $url, $attr ) {
return $return;
}
}

1 change: 0 additions & 1 deletion includes/embeds/class-amp-meetup-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ public function filter_embed_oembed_html( $cache, $url ) {
return $cache;
}
}

1 change: 0 additions & 1 deletion includes/embeds/class-amp-reddit-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ public function render( $args ) {
);
}
}

24 changes: 12 additions & 12 deletions includes/sanitizers/class-amp-core-theme-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@
*/
add_filter(
'get_custom_logo',
static function( $html ) {
static function ( $html ) {
$src = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
if ( ! $src ) {
return $html;
Expand Down Expand Up @@ -659,7 +659,7 @@
public static function dequeue_scripts( $handles = [] ) {
add_action(
'wp_enqueue_scripts',
static function() use ( $handles ) {
static function () use ( $handles ) {
foreach ( $handles as $handle ) {
wp_dequeue_script( $handle );
}
Expand Down Expand Up @@ -798,7 +798,7 @@

add_filter(
'body_class',
static function( $body_classes ) use ( $args ) {
static function ( $body_classes ) use ( $args ) {
if ( has_header_video() ) {
$body_classes[] = $args['class_name'];
}
Expand Down Expand Up @@ -832,7 +832,7 @@
// @todo This was introduced in <https://github.com/ampproject/amp-wp/commit/e1c7462> but it doesn't seem to have any effect.
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
ob_start();
?>
<style>
Expand Down Expand Up @@ -868,7 +868,7 @@
$method = __METHOD__;
add_filter(
'get_custom_logo',
static function( $html ) use ( $method ) {
static function ( $html ) use ( $method ) {
// Pattern sourced from AMP_Base_Embed_Handler::match_element_attributes().
$pattern = sprintf(
'/<img%s/',
Expand Down Expand Up @@ -936,7 +936,7 @@
// that any subsequent style rules for images will continue to override.
add_action(
'wp_print_styles',
static function() use ( $method ) {
static function () use ( $method ) {
printf(
'<style data-src="%s">%s</style>',
esc_attr( $method ),
Expand All @@ -957,7 +957,7 @@
public static function add_twentyseventeen_masthead_styles() {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {

Check warning on line 960 in includes/sanitizers/class-amp-core-theme-sanitizer.php

View check run for this annotation

Codecov / codecov/patch

includes/sanitizers/class-amp-core-theme-sanitizer.php#L960

Added line #L960 was not covered by tests
$is_front_page_layout = ( is_front_page() && 'posts' !== get_option( 'show_on_front' ) ) || ( is_home() && is_front_page() );
ob_start();
?>
Expand Down Expand Up @@ -1124,7 +1124,7 @@
public static function add_nav_menu_styles( $args = [] ) {
add_action(
'wp_enqueue_scripts',
static function() use ( $args ) {
static function () use ( $args ) {

Check warning on line 1127 in includes/sanitizers/class-amp-core-theme-sanitizer.php

View check run for this annotation

Codecov / codecov/patch

includes/sanitizers/class-amp-core-theme-sanitizer.php#L1127

Added line #L1127 was not covered by tests
ob_start();
?>
<style>
Expand Down Expand Up @@ -1441,7 +1441,7 @@
// Make sure the featured image gets responsive layout.
add_filter(
'wp_get_attachment_image_attributes',
static function( $attributes ) {
static function ( $attributes ) {

Check warning on line 1444 in includes/sanitizers/class-amp-core-theme-sanitizer.php

View check run for this annotation

Codecov / codecov/patch

includes/sanitizers/class-amp-core-theme-sanitizer.php#L1444

Added line #L1444 was not covered by tests
if ( preg_match( '/(^|\s)(attachment-post-thumbnail)(\s|$)/', $attributes['class'] ) ) {
$attributes['data-amp-layout'] = 'responsive';
}
Expand All @@ -1458,7 +1458,7 @@
public static function add_twentyfourteen_masthead_styles() {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {

Check warning on line 1461 in includes/sanitizers/class-amp-core-theme-sanitizer.php

View check run for this annotation

Codecov / codecov/patch

includes/sanitizers/class-amp-core-theme-sanitizer.php#L1461

Added line #L1461 was not covered by tests
ob_start();
?>
<style>
Expand Down Expand Up @@ -2030,7 +2030,7 @@
public static function amend_twentytwentyone_dark_mode_styles() {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
$theme_style_handle = 'twenty-twenty-one-style';
$dark_mode_style_handle = 'tt1-dark-mode';

Expand Down Expand Up @@ -2070,7 +2070,7 @@
public static function amend_twentytwentyone_styles() {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
$style_handle = 'twenty-twenty-one-style';

// Bail if the stylesheet is not enqueued.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function add_buffering_hooks( $args = [] ) {
*/
add_filter(
'walker_nav_menu_start_el',
static function( $item_output, $item, $depth, $nav_menu_args ) use ( $args ) {
static function ( $item_output, $item, $depth, $nav_menu_args ) use ( $args ) {
// Skip adding buttons to nav menu widgets for now.
if ( empty( $nav_menu_args->theme_location ) ) {
return $item_output;
Expand Down
1 change: 0 additions & 1 deletion includes/sanitizers/class-amp-o2-player-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public function sanitize() {
$this->create_amp_o2_player( $this->dom, $node );
}
}

}

/**
Expand Down
1 change: 0 additions & 1 deletion includes/sanitizers/class-amp-playbuzz-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public function sanitize() {
$this->did_convert_elements = true;

}

}

/**
Expand Down
Loading
Loading