diff --git a/amp.php b/amp.php index b7fac8ea565..b7a14c3d63b 100644 --- a/amp.php +++ b/amp.php @@ -14,7 +14,7 @@ */ define( 'AMP__FILE__', __FILE__ ); -define( 'AMP__DIR__', dirname( __FILE__ ) ); +define( 'AMP__DIR__', __DIR__ ); define( 'AMP__VERSION', '2.4.3-alpha' ); /** diff --git a/back-compat/templates-v0-3/style.php b/back-compat/templates-v0-3/style.php index 4df8a87a9ee..48f716f46ba 100644 --- a/back-compat/templates-v0-3/style.php +++ b/back-compat/templates-v0-3/style.php @@ -75,7 +75,7 @@ .amp-wp-content, .amp-wp-title-bar div { get( 'content_max_width' ) ); ?> 0 ) : ?> - max-width: ; + max-width: ; margin: 0 auto; } diff --git a/bin/add-test-widgets-to-sidebar.php b/bin/add-test-widgets-to-sidebar.php index 68580abc2ca..53c2e4c4ddc 100644 --- a/bin/add-test-widgets-to-sidebar.php +++ b/bin/add-test-widgets-to-sidebar.php @@ -391,7 +391,7 @@ function amp_create_widget( $widget ) { $number = max( array_keys( $widgets ) ); $number = max( 1, $number ); } - $number++; + ++$number; $widgets[ $number ] = $settings; update_option( $option_key, $widgets ); } diff --git a/bin/verify-version-consistency.php b/bin/verify-version-consistency.php index 0b9a0dc0bad..de4c75dd02c 100755 --- a/bin/verify-version-consistency.php +++ b/bin/verify-version-consistency.php @@ -14,14 +14,14 @@ $versions = []; -$readme_md = file_get_contents( dirname( __FILE__ ) . '/../README.md' ); +$readme_md = file_get_contents( __DIR__ . '/../README.md' ); if ( ! preg_match( '/\*\*Stable tag:\*\*\s+(?P\S+)/i', $readme_md, $matches ) ) { echo "Could not find stable tag in readme\n"; exit( 1 ); } $versions['README.md#stable-tag'] = $matches['version']; -$plugin_file = file_get_contents( dirname( __FILE__ ) . '/../amp.php' ); +$plugin_file = file_get_contents( __DIR__ . '/../amp.php' ); if ( ! preg_match( '/\*\s*Version:\s*(?P\d+\.\d+(?:.\d+)?(-\w+)?)/', $plugin_file, $matches ) ) { echo "Could not find version in readme metadata\n"; exit( 1 ); diff --git a/docs/src/Cli/GenerateCommand.php b/docs/src/Cli/GenerateCommand.php index ffcc26c625d..db04d868a29 100644 --- a/docs/src/Cli/GenerateCommand.php +++ b/docs/src/Cli/GenerateCommand.php @@ -98,7 +98,7 @@ public function __invoke( $args, $assoc_args ) { foreach ( $iterator as $file ) { if ( unlink( $file ) ) { WP_CLI::line( "Cleaned: $file" ); - $cleaned_count++; + ++$cleaned_count; } else { WP_CLI::warning( "Failed to clean: $file" ); } diff --git a/includes/admin/class-amp-admin-pointer.php b/includes/admin/class-amp-admin-pointer.php index 6e50bcd1632..d1f29f10380 100644 --- a/includes/admin/class-amp-admin-pointer.php +++ b/includes/admin/class-amp-admin-pointer.php @@ -150,7 +150,7 @@ public function enqueue() { add_action( 'admin_print_footer_scripts', - function() { + function () { $this->print_js(); } ); diff --git a/includes/admin/class-amp-admin-pointers.php b/includes/admin/class-amp-admin-pointers.php index 875421dea16..fb0565dad28 100644 --- a/includes/admin/class-amp-admin-pointers.php +++ b/includes/admin/class-amp-admin-pointers.php @@ -69,7 +69,7 @@ private function get_pointers() { 'position' => [ 'align' => 'middle', ], - 'active_callback' => static function() { + 'active_callback' => static function () { return version_compare( strtok( AMP__VERSION, '-' ), '1.1', '<' ); }, ] diff --git a/includes/amp-helper-functions.php b/includes/amp-helper-functions.php index 1844bb0bf06..738658d572b 100644 --- a/includes/amp-helper-functions.php +++ b/includes/amp-helper-functions.php @@ -180,7 +180,7 @@ static function () use ( $old_version ) { add_action( 'rest_api_init', - static function() { + static function () { $reader_themes = new ReaderThemes(); $reader_theme_controller = new AMP_Reader_Theme_REST_Controller( $reader_themes ); diff --git a/includes/class-amp-comment-walker.php b/includes/class-amp-comment-walker.php index 0d3eb2eee39..89f6243b5e3 100644 --- a/includes/class-amp-comment-walker.php +++ b/includes/class-amp-comment-walker.php @@ -69,7 +69,6 @@ public function start_el( &$output, $comment, $depth = 0, $args = [], $id = 0 ) } $output .= $new_tag . substr( ltrim( $new_out ), strlen( $tag ) ); - } /** diff --git a/includes/class-amp-service-worker.php b/includes/class-amp-service-worker.php index 624e097c1bb..6e8a8bdaa61 100644 --- a/includes/class-amp-service-worker.php +++ b/includes/class-amp-service-worker.php @@ -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 ''; @@ -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(); }; }, diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php index 08fa48d5e71..3f4fe170fa4 100644 --- a/includes/class-amp-theme-support.php +++ b/includes/class-amp-theme-support.php @@ -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 @@ -859,13 +859,13 @@ 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'; } ); @@ -873,7 +873,7 @@ static function() { // 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( '/(?<= 0 ) { $error_messages = array_map( - static function( Optimizer\Error $error ) { + static function ( Optimizer\Error $error ) { return ' - ' . $error->getCode() . ': ' . $error->getMessage(); }, iterator_to_array( $errors ) diff --git a/includes/embeds/class-amp-core-block-handler.php b/includes/embeds/class-amp-core-block-handler.php index 6abfd2c821e..1622cfc12c1 100644 --- a/includes/embeds/class-amp-core-block-handler.php +++ b/includes/embeds/class-amp-core-block-handler.php @@ -149,7 +149,7 @@ public function filter_rendered_block( $block_content, $block ) { */ public function ampify_categories_block( $block_content ) { static $block_id = 0; - $block_id++; + ++$block_id; $form_id = "wp-block-categories-dropdown-{$block_id}-form"; @@ -186,7 +186,7 @@ public function ampify_archives_block( $block_content ) { // Eliminate use of uniqid(). Core should be using wp_unique_id() here. static $block_id = 0; - $block_id++; + ++$block_id; $block_content = preg_replace( '/(?<="wp-block-archives-)\w+(?=")/', $block_id, $block_content ); // Replace onchange with on attribute. @@ -339,7 +339,7 @@ public function ampify_navigation_block( $block_content, $block ) { add_action( 'wp_print_footer_scripts', [ $this, 'dequeue_block_navigation_view_script' ], 0 ); } - $this->navigation_block_count++; + ++$this->navigation_block_count; $modal_state_property = "modal_{$this->navigation_block_count}_expanded"; // Set `aria-expanded` value of submenus whenever AMP state changes. @@ -487,7 +487,7 @@ private function process_categories_widgets( Document $dom ) { continue; // @codeCoverageIgnore } - $this->category_widget_count++; + ++$this->category_widget_count; $id = sprintf( 'amp-wp-widget-categories-%d', $this->category_widget_count ); $form->setAttribute( 'id', $id ); diff --git a/includes/embeds/class-amp-gfycat-embed-handler.php b/includes/embeds/class-amp-gfycat-embed-handler.php index d2982c3b357..01301d5d19d 100644 --- a/includes/embeds/class-amp-gfycat-embed-handler.php +++ b/includes/embeds/class-amp-gfycat-embed-handler.php @@ -80,4 +80,3 @@ public function filter_embed_oembed_html( $return, $url, $attr ) { return $return; } } - diff --git a/includes/embeds/class-amp-issuu-embed-handler.php b/includes/embeds/class-amp-issuu-embed-handler.php index 8feb238bf2a..f17fa7ae86d 100644 --- a/includes/embeds/class-amp-issuu-embed-handler.php +++ b/includes/embeds/class-amp-issuu-embed-handler.php @@ -64,4 +64,3 @@ public function filter_embed_oembed_html( $return, $url, $attr ) { return $return; } } - diff --git a/includes/embeds/class-amp-meetup-embed-handler.php b/includes/embeds/class-amp-meetup-embed-handler.php index 094fb0aff11..00e989bc125 100644 --- a/includes/embeds/class-amp-meetup-embed-handler.php +++ b/includes/embeds/class-amp-meetup-embed-handler.php @@ -44,4 +44,3 @@ public function filter_embed_oembed_html( $cache, $url ) { return $cache; } } - diff --git a/includes/embeds/class-amp-playlist-embed-handler.php b/includes/embeds/class-amp-playlist-embed-handler.php index 3bc9fc14120..4c01be5d20b 100644 --- a/includes/embeds/class-amp-playlist-embed-handler.php +++ b/includes/embeds/class-amp-playlist-embed-handler.php @@ -152,7 +152,7 @@ public function audio_playlist( $data ) { if ( ! isset( $data['tracks'] ) ) { return ''; } - self::$playlist_id++; + ++self::$playlist_id; $container_id = 'wpPlaylist' . self::$playlist_id . 'Carousel'; $state_id = 'wpPlaylist' . self::$playlist_id; $amp_state = [ @@ -207,7 +207,7 @@ public function video_playlist( $data ) { if ( ! isset( $data['tracks'][0]['src'] ) ) { return ''; } - self::$playlist_id++; + ++self::$playlist_id; $state_id = 'wpPlaylist' . self::$playlist_id; $amp_state = [ 'selectedIndex' => 0, diff --git a/includes/embeds/class-amp-reddit-embed-handler.php b/includes/embeds/class-amp-reddit-embed-handler.php index 922dd158c65..35026d72159 100644 --- a/includes/embeds/class-amp-reddit-embed-handler.php +++ b/includes/embeds/class-amp-reddit-embed-handler.php @@ -74,4 +74,3 @@ public function render( $args ) { ); } } - diff --git a/includes/sanitizers/class-amp-bento-sanitizer.php b/includes/sanitizers/class-amp-bento-sanitizer.php index b1fec7a2810..01e020731e5 100644 --- a/includes/sanitizers/class-amp-bento-sanitizer.php +++ b/includes/sanitizers/class-amp-bento-sanitizer.php @@ -176,7 +176,7 @@ public function sanitize() { $script->parentNode->removeChild( $script ); } else { ValidationExemption::mark_node_as_px_verified( $script ); - $non_amp_scripts_retained++; + ++$non_amp_scripts_retained; } } diff --git a/includes/sanitizers/class-amp-block-uniqid-sanitizer.php b/includes/sanitizers/class-amp-block-uniqid-sanitizer.php index 9ce4692fbff..2b14fc2231f 100644 --- a/includes/sanitizers/class-amp-block-uniqid-sanitizer.php +++ b/includes/sanitizers/class-amp-block-uniqid-sanitizer.php @@ -88,7 +88,7 @@ static function ( $class_name_prefix ) { $replaced_count = 0; foreach ( $elements as $element ) { if ( $this->transform_element_with_class_attribute( $element ) ) { - $replaced_count++; + ++$replaced_count; } } diff --git a/includes/sanitizers/class-amp-core-theme-sanitizer.php b/includes/sanitizers/class-amp-core-theme-sanitizer.php index 38164056d5f..8a3341bd142 100644 --- a/includes/sanitizers/class-amp-core-theme-sanitizer.php +++ b/includes/sanitizers/class-amp-core-theme-sanitizer.php @@ -585,7 +585,7 @@ public static function add_twentyseventeen_attachment_image_attributes( $args = */ 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; @@ -659,7 +659,7 @@ public function prevent_sanitize_in_customizer_preview( $xpaths = [] ) { 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 ); } @@ -798,7 +798,7 @@ public static function add_has_header_video_body_class( $args = [] ) { 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']; } @@ -832,7 +832,7 @@ public static function add_twentytwenty_masthead_styles( $args = [] ) { // @todo This was introduced in but it doesn't seem to have any effect. add_action( 'wp_enqueue_scripts', - static function() { + static function () { ob_start(); ?> ', esc_attr( $method ), @@ -957,7 +957,7 @@ static function() use ( $method ) { public static function add_twentyseventeen_masthead_styles() { add_action( 'wp_enqueue_scripts', - static function() { + static function () { $is_front_page_layout = ( is_front_page() && 'posts' !== get_option( 'show_on_front' ) ) || ( is_home() && is_front_page() ); ob_start(); ?> @@ -1124,7 +1124,7 @@ public function add_twentyseventeen_sticky_nav_menu() { public static function add_nav_menu_styles( $args = [] ) { add_action( 'wp_enqueue_scripts', - static function() use ( $args ) { + static function () use ( $args ) { ob_start(); ?>
', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet 1, - static function( $requested_url ) { + static function ( $requested_url ) { if ( false !== strpos( $requested_url, 'import-buttons.php' ) ) { return '@import url( "../css/./foo/../buttons.css" );body{color:#123456}'; } @@ -3220,7 +3220,7 @@ static function ( WP_UnitTestCase $test, $stylesheet ) { includes_url( '/dynamic/import-buttons.php' ), '
', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet 1, - static function( $requested_url ) { + static function ( $requested_url ) { if ( false !== strpos( $requested_url, 'import-buttons.php' ) ) { return sprintf( '@import "%s";body{color:#123456}', plugins_url( 'tests/php/data/css/buttons.css', AMP__FILE__ ) ); } @@ -3238,7 +3238,7 @@ static function ( WP_UnitTestCase $test, $stylesheet ) { includes_url( '/dynamic/import-buttons.php' ), '
', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet 2, - static function( $requested_url ) { + static function ( $requested_url ) { $self_call_url = includes_url( '/dynamic/nested.php' ); if ( false !== strpos( $requested_url, 'import-buttons.php' ) ) { return sprintf( '@import "%s";body{color:#123456}', $self_call_url ); @@ -3293,7 +3293,7 @@ static function ( $stylesheet_url ) { add_filter( 'pre_http_request', - static function( $preempt, $request, $url ) use ( $mock_response, $stylesheet_urls, &$http_request_count ) { + static function ( $preempt, $request, $url ) use ( $mock_response, $stylesheet_urls, &$http_request_count ) { $http_request_count++; if ( $mock_response ) { $body = $mock_response( $url, $stylesheet_urls ); @@ -3494,7 +3494,7 @@ function () use ( $render_template ) { require_once get_template_directory() . '/functions.php'; add_action( 'wp_head', - static function() { + static function () { printf( '', esc_html( str_repeat( 'a', 75000 - 10 ) ) ); }, -1000 @@ -3505,7 +3505,7 @@ static function() { add_action( 'wp_footer', - function() { + function () { ?>
@@ -3518,7 +3518,7 @@ function() { return $render_template(); }, - function( $original_dom, $original_source, $amphtml_dom, $amphtml_source ) { + function ( $original_dom, $original_source, $amphtml_dom, $amphtml_source ) { /** * Vars. * @@ -3596,7 +3596,7 @@ public function test_prioritized_stylesheets( $html_generator, $assert ) { $error_codes = []; $args = [ 'use_document_element' => true, - 'validation_error_callback' => static function( $error ) use ( &$error_codes ) { + 'validation_error_callback' => static function ( $error ) use ( &$error_codes ) { $error_codes[] = $error['code']; }, ]; diff --git a/tests/php/test-amp-wordpress-embed-handler.php b/tests/php/test-amp-wordpress-embed-handler.php index 8d025ff122e..7d4483cb42e 100644 --- a/tests/php/test-amp-wordpress-embed-handler.php +++ b/tests/php/test-amp-wordpress-embed-handler.php @@ -16,7 +16,8 @@ */ class AMP_WordPress_Embed_Handler_Test extends TestCase { - use MarkupComparison, WithoutBlockPreRendering; + use MarkupComparison; + use WithoutBlockPreRendering; /** @var string */ const WP_59_ALPHA_POST_URL = 'https://make.wordpress.org/core/2021/10/12/proposal-for-a-performance-team/'; diff --git a/tests/php/test-class-amp-accessibility-sanitizer.php b/tests/php/test-class-amp-accessibility-sanitizer.php index a686350ccdb..025686f9637 100644 --- a/tests/php/test-class-amp-accessibility-sanitizer.php +++ b/tests/php/test-class-amp-accessibility-sanitizer.php @@ -153,7 +153,6 @@ public function get_skip_link_test_data() { 'expected' => '
Hello World!
', ], ]; - } /** @@ -211,6 +210,5 @@ public function test_add_skip_link_for_none_fse_theme() { $actual = AMP_DOM_Utils::get_content_from_dom( $dom ); $this->assertEqualMarkup( $expected, $actual ); - } } diff --git a/tests/php/test-class-amp-base-sanitizer.php b/tests/php/test-class-amp-base-sanitizer.php index 5ef6072d3c8..8e95645873f 100644 --- a/tests/php/test-class-amp-base-sanitizer.php +++ b/tests/php/test-class-amp-base-sanitizer.php @@ -611,7 +611,7 @@ public function test_remove_invalid_attribute() { $sanitizer = new AMP_Video_Sanitizer( $dom, [ - 'validation_error_callback' => static function( $error, $context ) use ( $that ) { + 'validation_error_callback' => static function ( $error, $context ) use ( $that ) { $that->assertEquals( [ 'node_name' => 'onload', @@ -642,7 +642,7 @@ public function test_remove_invalid_attribute() { $sanitizer = new AMP_Video_Sanitizer( $dom, [ - 'validation_error_callback' => static function( $error, $context ) use ( $that ) { + 'validation_error_callback' => static function ( $error, $context ) use ( $that ) { $that->assertEquals( [ 'node_name' => 'onload', diff --git a/tests/php/test-class-amp-cli-option-command.php b/tests/php/test-class-amp-cli-option-command.php index 35b42ad370d..54703853881 100644 --- a/tests/php/test-class-amp-cli-option-command.php +++ b/tests/php/test-class-amp-cli-option-command.php @@ -21,7 +21,8 @@ */ class Test_AMP_CLI_Option_Command extends DependencyInjectedTestCase { - use PrivateAccess, MockAdminUser; + use PrivateAccess; + use MockAdminUser; /** * OptionCommand instance. diff --git a/tests/php/test-class-amp-cli-validation-command.php b/tests/php/test-class-amp-cli-validation-command.php index 6ae7c09fcc2..c41d495c538 100644 --- a/tests/php/test-class-amp-cli-validation-command.php +++ b/tests/php/test-class-amp-cli-validation-command.php @@ -20,7 +20,8 @@ */ class Test_AMP_CLI_Validation_Command extends DependencyInjectedTestCase { - use PrivateAccess, ValidationRequestMocking; + use PrivateAccess; + use ValidationRequestMocking; /** * Store a reference to the validation command object. diff --git a/tests/php/test-class-amp-customizer-design-settings.php b/tests/php/test-class-amp-customizer-design-settings.php index a2501963372..e80f984e8f4 100644 --- a/tests/php/test-class-amp-customizer-design-settings.php +++ b/tests/php/test-class-amp-customizer-design-settings.php @@ -88,7 +88,6 @@ public function test_is_amp_customizer_enabled_and_init( callable $set_up, $enab $this->assertEquals( $enabled ? 10 : false, has_action( 'amp_customizer_init', [ AMP_Customizer_Design_Settings::class, 'init_customizer' ] ) ); $this->assertEquals( $enabled ? 10 : false, has_filter( 'amp_customizer_get_settings', [ AMP_Customizer_Design_Settings::class, 'append_settings' ] ) ); - } /** @return array */ diff --git a/tests/php/test-class-amp-gallery-block-sanitizer.php b/tests/php/test-class-amp-gallery-block-sanitizer.php index ce8cfc4f40e..089a5c39688 100644 --- a/tests/php/test-class-amp-gallery-block-sanitizer.php +++ b/tests/php/test-class-amp-gallery-block-sanitizer.php @@ -14,7 +14,8 @@ */ class AMP_Gallery_Block_Sanitizer_Test extends TestCase { - use PrivateAccess, MarkupComparison; + use PrivateAccess; + use MarkupComparison; /** * Get data. diff --git a/tests/php/test-class-amp-gfycat-embed-handler.php b/tests/php/test-class-amp-gfycat-embed-handler.php index 8c80d54838d..70dfeec1cbb 100644 --- a/tests/php/test-class-amp-gfycat-embed-handler.php +++ b/tests/php/test-class-amp-gfycat-embed-handler.php @@ -28,7 +28,7 @@ public function set_up() { // Mock the HTTP request. add_filter( 'pre_oembed_result', - static function( $pre, $url ) { + static function ( $pre, $url ) { if ( in_array( 'external-http', $_SERVER['argv'], true ) ) { return $pre; } diff --git a/tests/php/test-class-amp-http.php b/tests/php/test-class-amp-http.php index fe83c0565d8..b42e96e584c 100644 --- a/tests/php/test-class-amp-http.php +++ b/tests/php/test-class-amp-http.php @@ -548,7 +548,7 @@ public function test_handle_wp_die() { add_filter( 'wp_doing_ajax', '__return_true' ); add_filter( 'wp_die_ajax_handler', - static function() { + static function () { return '__return_null'; } ); @@ -572,7 +572,7 @@ public function test_filter_comment_post_redirect() { add_filter( 'wp_doing_ajax', '__return_true' ); add_filter( 'wp_die_ajax_handler', - static function() { + static function () { return '__return_null'; } ); @@ -602,7 +602,7 @@ static function() { ); add_filter( 'amp_comment_posted_message', - static function( $message, WP_Comment $filter_comment ) { + static function ( $message, WP_Comment $filter_comment ) { return sprintf( '(comment=%d,approved=%d)', $filter_comment->comment_ID, $filter_comment->comment_approved ); }, 10, diff --git a/tests/php/test-class-amp-imgur-embed-handler.php b/tests/php/test-class-amp-imgur-embed-handler.php index 810b2cb37aa..6f1ab0b58e2 100644 --- a/tests/php/test-class-amp-imgur-embed-handler.php +++ b/tests/php/test-class-amp-imgur-embed-handler.php @@ -26,7 +26,7 @@ public function set_up() { // Mock the HTTP request. add_filter( 'pre_http_request', - static function( $pre, $r, $url ) { + static function ( $pre, $r, $url ) { if ( in_array( 'external-http', $_SERVER['argv'], true ) ) { return $pre; } diff --git a/tests/php/test-class-amp-link-sanitizer.php b/tests/php/test-class-amp-link-sanitizer.php index c1c00b6ea78..a1cf924ce56 100644 --- a/tests/php/test-class-amp-link-sanitizer.php +++ b/tests/php/test-class-amp-link-sanitizer.php @@ -386,7 +386,7 @@ public function test_is_frontend_url( $url, $expected ) { add_filter( 'home_url', - static function() use ( $new_home_url ) { + static function () use ( $new_home_url ) { return $new_home_url; } ); diff --git a/tests/php/test-class-amp-nav-menu-toggle-sanitizer.php b/tests/php/test-class-amp-nav-menu-toggle-sanitizer.php index 3d800095dfb..fa3d6df277f 100644 --- a/tests/php/test-class-amp-nav-menu-toggle-sanitizer.php +++ b/tests/php/test-class-amp-nav-menu-toggle-sanitizer.php @@ -30,13 +30,13 @@ public function data_converter() { $head = ''; $amp_state = ''; - $amp_get_container_attrs = function( $class = '', $toggle_class = 'toggled-on' ) { + $amp_get_container_attrs = function ( $class = '', $toggle_class = 'toggled-on' ) { if ( empty( $toggle_class ) ) { return ''; } return ' data-amp-bind-class=""' . $class . '" + ( navMenuToggledOn ? " ' . $toggle_class . '" : \'\' )"'; }; - $amp_get_toggle_attrs = function( $class = '', $toggle_class = 'toggled-on' ) { // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning -- Sniff has a bug. + $amp_get_toggle_attrs = function ( $class = '', $toggle_class = 'toggled-on' ) { // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning -- Sniff has a bug. return ' on="tap:AMP.setState({ navMenuToggledOn: ! navMenuToggledOn })" aria-expanded="false" data-amp-bind-aria-expanded="navMenuToggledOn ? \'true\' : \'false\'"' . ( ! empty( $toggle_class ) ? ' data-amp-bind-class=""' . $class . '" + ( navMenuToggledOn ? " ' . $toggle_class . '" : \'\' )"' : '' ); }; diff --git a/tests/php/test-class-amp-post-type-support.php b/tests/php/test-class-amp-post-type-support.php index cc729e06fb3..d90a5fe8ed8 100644 --- a/tests/php/test-class-amp-post-type-support.php +++ b/tests/php/test-class-amp-post-type-support.php @@ -92,7 +92,6 @@ static function ( $post_types ) { ], AMP_Post_Type_Support::get_eligible_post_types() ); - } /** diff --git a/tests/php/test-class-amp-reader-themes-rest-controller.php b/tests/php/test-class-amp-reader-themes-rest-controller.php index aa964d183d8..d74a0e6238b 100644 --- a/tests/php/test-class-amp-reader-themes-rest-controller.php +++ b/tests/php/test-class-amp-reader-themes-rest-controller.php @@ -80,7 +80,7 @@ public function test_get_items() { $this->assertContains( $expected_reader_theme, $actual_reader_themes ); } - $filter = static function() { + $filter = static function () { return [ [ 'name' => 'My theme', @@ -131,7 +131,7 @@ public function test_get_items_header_with_themes_api_failure() { * @covers ::get_items */ public function test_get_items_header_with_themes_api_empty_array() { - $filter_cb = static function() { + $filter_cb = static function () { return (object) [ 'themes' => [] ]; }; add_filter( 'themes_api_result', $filter_cb ); @@ -141,7 +141,6 @@ public function test_get_items_header_with_themes_api_empty_array() { [ 'X-AMP-Theme-API-Error' => 'The default reader themes cannot be displayed because a plugin appears to be overriding the themes response from WordPress.org.' ], $response->get_headers() ); - } /** @@ -150,7 +149,7 @@ public function test_get_items_header_with_themes_api_empty_array() { * @covers ::get_items */ public function test_themes_api_remote_wp_error() { - $filter_cb = static function() { + $filter_cb = static function () { return new WP_Error( 'amp_test_error', 'Test message' diff --git a/tests/php/test-class-amp-service-worker.php b/tests/php/test-class-amp-service-worker.php index a70c57818b7..9681badb004 100644 --- a/tests/php/test-class-amp-service-worker.php +++ b/tests/php/test-class-amp-service-worker.php @@ -227,7 +227,7 @@ public function test_handle_service_worker_iframe_install() { add_filter( 'wp_die_handler', static function () { - return static function() { + return static function () { throw new Exception( 'exited' ); }; } diff --git a/tests/php/test-class-amp-srcset-sanitizer.php b/tests/php/test-class-amp-srcset-sanitizer.php index 3a24259ccc4..b7b7dd81f86 100644 --- a/tests/php/test-class-amp-srcset-sanitizer.php +++ b/tests/php/test-class-amp-srcset-sanitizer.php @@ -140,7 +140,7 @@ public function test_sanitize( $source, $expected = null, $expected_error_codes $args = [ 'use_document_element' => true, - 'validation_error_callback' => static function( $error ) use ( &$error_codes ) { + 'validation_error_callback' => static function ( $error ) use ( &$error_codes ) { $error_codes[] = $error['code']; }, ]; diff --git a/tests/php/test-class-amp-theme-support.php b/tests/php/test-class-amp-theme-support.php index 3870a22be84..52c3a35b7f7 100644 --- a/tests/php/test-class-amp-theme-support.php +++ b/tests/php/test-class-amp-theme-support.php @@ -183,14 +183,14 @@ public function test_supports_reader_mode() { // Add filters so that get_template_directory() the theme in the mock filesystem. add_filter( 'theme_root', - function() use ( $mock_directory ) { + function () use ( $mock_directory ) { return $mock_directory->url(); } ); add_filter( 'template', - function() use ( $mock_theme ) { + function () use ( $mock_theme ) { return $mock_theme; } ); @@ -498,7 +498,7 @@ public function test_get_template_availability() { AMP_Options_Manager::update_option( Option::SUPPORTED_TEMPLATES, [ 'is_special', 'is_custom', 'is_page' ] ); add_filter( 'amp_supportable_templates', - static function( $templates ) { + static function ( $templates ) { $templates['is_single'] = [ 'label' => 'Single post', 'parent' => 'is_singular', @@ -506,7 +506,7 @@ static function( $templates ) { $templates['is_special'] = [ 'label' => 'Special post', 'parent' => 'is_single', - 'callback' => static function( WP_Query $query ) { + 'callback' => static function ( WP_Query $query ) { return $query->is_singular() && 'special' === get_post( $query->get_queried_object_id() )->post_name; }, ]; @@ -516,14 +516,14 @@ static function( $templates ) { ]; $templates['is_custom'] = [ 'label' => 'Custom', - 'callback' => static function( WP_Query $query ) { + 'callback' => static function ( WP_Query $query ) { return false !== $query->get( 'custom', false ); }, ]; $templates['is_custom[thing]'] = [ 'label' => 'Custom Thing', 'parent' => 'is_custom', - 'callback' => static function( WP_Query $query ) { + 'callback' => static function ( WP_Query $query ) { return 'thing' === $query->get( 'custom', false ); }, ]; @@ -532,7 +532,7 @@ static function( $templates ) { ); add_filter( 'query_vars', - static function( $vars ) { + static function ( $vars ) { $vars[] = 'custom'; return $vars; } @@ -637,7 +637,7 @@ static function ( $templates ) { $templates['missing_parent'] = [ 'label' => 'Missing parent', 'parent' => 'is_unknown', - 'callback' => static function( WP_Query $query ) { + 'callback' => static function ( WP_Query $query ) { return false !== $query->get( 'missing_parent', false ); }, ]; @@ -753,10 +753,10 @@ public function test_get_supportable_templates() { // Test inclusion of custom template. add_filter( 'amp_supportable_templates', - static function( $templates ) { + static function ( $templates ) { $templates['is_custom'] = [ 'label' => 'Custom', - 'callback' => static function( WP_Query $query ) { + 'callback' => static function ( WP_Query $query ) { return false !== $query->get( 'custom', false ); }, ]; @@ -1017,13 +1017,13 @@ public function test_init_admin_bar() { add_action( 'admin_bar_init', - function() { + function () { wp_enqueue_style( 'example-admin-bar', 'https://example.com/example-admin-bar.css', [ 'admin-bar' ], '0.1' ); wp_enqueue_script( 'example-admin-bar', 'https://example.com/example-admin-bar.js', [ 'admin-bar' ], '0.1', false ); } ); - $callback = function() { + $callback = function () { ?>