diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php
index 87cc4a6cc5f18..5a23573dd1dfa 100644
--- a/lib/block-supports/layout.php
+++ b/lib/block-supports/layout.php
@@ -590,7 +590,7 @@ function gutenberg_restore_group_inner_container( $block_content, $block ) {
);
$updated_content = preg_replace_callback(
$replace_regex,
- function( $matches ) {
+ static function( $matches ) {
return $matches[1] . '
' . $matches[2] . '
' . $matches[3];
},
$block_content
diff --git a/lib/blocks.php b/lib/blocks.php
index bbee108b71c5f..5c1d81f120c4a 100644
--- a/lib/blocks.php
+++ b/lib/blocks.php
@@ -239,7 +239,7 @@ function gutenberg_register_core_block_assets( $block_name ) {
if ( ! $stylesheet_removed ) {
add_action(
'wp_enqueue_scripts',
- function() {
+ static function() {
wp_dequeue_style( 'wp-block-library-theme' );
}
);
diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php
index c27572e735ee1..8fbd3ea6e70df 100644
--- a/lib/class-wp-theme-json-gutenberg.php
+++ b/lib/class-wp-theme-json-gutenberg.php
@@ -2365,7 +2365,7 @@ static function( $split_selector ) use ( $clean_style_variation_selector ) {
$pseudo_matches = array_values(
array_filter(
$element_pseudo_allowed,
- function( $pseudo_selector ) use ( $selector ) {
+ static function( $pseudo_selector ) use ( $selector ) {
return str_contains( $selector, $pseudo_selector );
}
)
diff --git a/lib/compat/wordpress-6.2/script-loader.php b/lib/compat/wordpress-6.2/script-loader.php
index 55a890f54f301..37c1ced3c8cfc 100644
--- a/lib/compat/wordpress-6.2/script-loader.php
+++ b/lib/compat/wordpress-6.2/script-loader.php
@@ -66,7 +66,7 @@ static function () use ( $style ) {
add_filter(
'block_editor_settings_all',
- function( $settings ) {
+ static function( $settings ) {
// We must override what core is passing now.
$settings['__unstableIsBlockBasedTheme'] = wp_is_block_theme();
return $settings;
diff --git a/lib/compat/wordpress-6.3/script-loader.php b/lib/compat/wordpress-6.3/script-loader.php
index b1445d102df4e..c3035bb0da37d 100644
--- a/lib/compat/wordpress-6.3/script-loader.php
+++ b/lib/compat/wordpress-6.3/script-loader.php
@@ -76,7 +76,7 @@ function _gutenberg_get_iframed_editor_assets() {
add_filter(
'block_editor_settings_all',
- function( $settings ) {
+ static function( $settings ) {
// We must override what core is passing now.
$settings['__unstableResolvedAssets'] = _gutenberg_get_iframed_editor_assets();
return $settings;
diff --git a/lib/experimental/fonts-api/fonts-api.php b/lib/experimental/fonts-api/fonts-api.php
index 348ae2dc875e2..841efeda47a95 100644
--- a/lib/experimental/fonts-api/fonts-api.php
+++ b/lib/experimental/fonts-api/fonts-api.php
@@ -230,7 +230,7 @@ function wp_print_fonts( $handles = false ) {
*/
add_filter(
'mime_types',
- function( $mime_types ) {
+ static function( $mime_types ) {
// Webfonts formats.
$mime_types['woff2'] = 'font/woff2';
$mime_types['woff'] = 'font/woff';
diff --git a/lib/experimental/navigation-theme-opt-in.php b/lib/experimental/navigation-theme-opt-in.php
index 7efed9794d0cc..efd1a6eec5cb8 100644
--- a/lib/experimental/navigation-theme-opt-in.php
+++ b/lib/experimental/navigation-theme-opt-in.php
@@ -161,7 +161,7 @@ function gutenberg_remove_block_nav_menu_items( $menu_items ) {
return array_filter(
$menu_items,
- function( $menu_item ) {
+ static function( $menu_item ) {
return 'block' !== $menu_item->type;
}
);
diff --git a/lib/global-styles-and-settings.php b/lib/global-styles-and-settings.php
index bed5ab1e4408b..309f01ca2bdd3 100644
--- a/lib/global-styles-and-settings.php
+++ b/lib/global-styles-and-settings.php
@@ -197,7 +197,7 @@ function gutenberg_add_global_styles_for_blocks() {
$result = array_values(
array_filter(
$metadata['path'],
- function ( $item ) {
+ static function ( $item ) {
if ( strpos( $item, 'core/' ) !== false ) {
return true;
}
diff --git a/packages/block-library/src/comments-pagination-next/index.php b/packages/block-library/src/comments-pagination-next/index.php
index a535b7c40d6c4..5a8df691ff092 100644
--- a/packages/block-library/src/comments-pagination-next/index.php
+++ b/packages/block-library/src/comments-pagination-next/index.php
@@ -26,7 +26,7 @@ function render_block_core_comments_pagination_next( $attributes, $content, $blo
$label = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
$pagination_arrow = get_comments_pagination_arrow( $block, 'next' );
- $filter_link_attributes = function() {
+ $filter_link_attributes = static function() {
return get_block_wrapper_attributes();
};
add_filter( 'next_comments_link_attributes', $filter_link_attributes );
diff --git a/packages/block-library/src/comments-pagination-previous/index.php b/packages/block-library/src/comments-pagination-previous/index.php
index 951dc8dd78a06..ed3fa653abda9 100644
--- a/packages/block-library/src/comments-pagination-previous/index.php
+++ b/packages/block-library/src/comments-pagination-previous/index.php
@@ -22,7 +22,7 @@ function render_block_core_comments_pagination_previous( $attributes, $content,
$label = $pagination_arrow . $label;
}
- $filter_link_attributes = function() {
+ $filter_link_attributes = static function() {
return get_block_wrapper_attributes();
};
add_filter( 'previous_comments_link_attributes', $filter_link_attributes );
diff --git a/packages/block-library/src/file/index.php b/packages/block-library/src/file/index.php
index 9081b63a5e76b..b68ee8eacc591 100644
--- a/packages/block-library/src/file/index.php
+++ b/packages/block-library/src/file/index.php
@@ -25,7 +25,7 @@ function render_block_core_file( $attributes, $content ) {
$pattern = '@aria-label="(?[^"]+)?")@i';
$content = preg_replace_callback(
$pattern,
- function ( $matches ) {
+ static function ( $matches ) {
$filename = ! empty( $matches['filename'] ) ? $matches['filename'] : '';
$has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
$label = $has_filename ?
diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php
index 84ff235344cfc..8667511d00f2a 100644
--- a/packages/block-library/src/navigation/index.php
+++ b/packages/block-library/src/navigation/index.php
@@ -214,7 +214,7 @@ function block_core_navigation_render_submenu_icon() {
function block_core_navigation_filter_out_empty_blocks( $parsed_blocks ) {
$filtered = array_filter(
$parsed_blocks,
- function( $block ) {
+ static function( $block ) {
return isset( $block['blockName'] );
}
);
@@ -783,7 +783,7 @@ function block_core_navigation_get_classic_menu_fallback() {
// Otherwise return the most recently created classic menu.
usort(
$classic_nav_menus,
- function( $a, $b ) {
+ static function( $a, $b ) {
return $b->term_id - $a->term_id;
}
);
diff --git a/packages/block-library/src/post-excerpt/index.php b/packages/block-library/src/post-excerpt/index.php
index 24f6777b4121d..4ed4edab95078 100644
--- a/packages/block-library/src/post-excerpt/index.php
+++ b/packages/block-library/src/post-excerpt/index.php
@@ -31,7 +31,7 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
}
$more_text = ! empty( $attributes['moreText'] ) ? '' . wp_kses_post( $attributes['moreText'] ) . '' : '';
- $filter_excerpt_more = function( $more ) use ( $more_text ) {
+ $filter_excerpt_more = static function( $more ) use ( $more_text ) {
return empty( $more_text ) ? $more : '';
};
/**
@@ -87,7 +87,7 @@ function register_block_core_post_excerpt() {
defined( 'REST_REQUEST' ) && REST_REQUEST ) {
add_filter(
'excerpt_length',
- function() {
+ static function() {
return 100;
},
PHP_INT_MAX
diff --git a/packages/block-library/src/query-pagination-next/index.php b/packages/block-library/src/query-pagination-next/index.php
index bd8d86eef04af..f0ded727ee8a9 100644
--- a/packages/block-library/src/query-pagination-next/index.php
+++ b/packages/block-library/src/query-pagination-next/index.php
@@ -36,7 +36,7 @@ function render_block_core_query_pagination_next( $attributes, $content, $block
// Check if the pagination is for Query that inherits the global context.
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
- $filter_link_attributes = function() use ( $wrapper_attributes ) {
+ $filter_link_attributes = static function() use ( $wrapper_attributes ) {
return $wrapper_attributes;
};
add_filter( 'next_posts_link_attributes', $filter_link_attributes );
diff --git a/packages/block-library/src/query-pagination-previous/index.php b/packages/block-library/src/query-pagination-previous/index.php
index 15bae30a04149..5665506598f81 100644
--- a/packages/block-library/src/query-pagination-previous/index.php
+++ b/packages/block-library/src/query-pagination-previous/index.php
@@ -34,7 +34,7 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl
// Check if the pagination is for Query that inherits the global context
// and handle appropriately.
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
- $filter_link_attributes = function() use ( $wrapper_attributes ) {
+ $filter_link_attributes = static function() use ( $wrapper_attributes ) {
return $wrapper_attributes;
};
diff --git a/packages/block-library/src/site-logo/index.php b/packages/block-library/src/site-logo/index.php
index f7dde9d7b0513..f1819fcaac8d0 100644
--- a/packages/block-library/src/site-logo/index.php
+++ b/packages/block-library/src/site-logo/index.php
@@ -13,7 +13,7 @@
* @return string The render.
*/
function render_block_core_site_logo( $attributes ) {
- $adjust_width_height_filter = function ( $image ) use ( $attributes ) {
+ $adjust_width_height_filter = static function ( $image ) use ( $attributes ) {
if ( empty( $attributes['width'] ) || empty( $image ) || ! $image[1] || ! $image[2] ) {
return $image;
}
diff --git a/packages/e2e-tests/plugins/block-context.php b/packages/e2e-tests/plugins/block-context.php
index d1cc347640718..dc92132152e1f 100644
--- a/packages/e2e-tests/plugins/block-context.php
+++ b/packages/e2e-tests/plugins/block-context.php
@@ -52,7 +52,7 @@ function gutenberg_test_register_context_blocks() {
'postId',
'postType',
),
- 'render_callback' => function( $attributes, $content, $block ) {
+ 'render_callback' => static function( $attributes, $content, $block ) {
$ordered_context = array(
$block->context['gutenberg/recordId'],
$block->context['postId'],
diff --git a/packages/e2e-tests/plugins/iframed-block.php b/packages/e2e-tests/plugins/iframed-block.php
index 29e71fa75a2ec..574a48400ea2f 100644
--- a/packages/e2e-tests/plugins/iframed-block.php
+++ b/packages/e2e-tests/plugins/iframed-block.php
@@ -9,14 +9,14 @@
add_action(
'setup_theme',
- function() {
+ static function() {
add_theme_support( 'block-templates' );
}
);
add_action(
'init',
- function() {
+ static function() {
wp_register_script(
'iframed-block-jquery-test',
plugin_dir_url( __FILE__ ) . 'iframed-block/jquery.test.js',
diff --git a/packages/e2e-tests/plugins/iframed-enqueue-block-assets.php b/packages/e2e-tests/plugins/iframed-enqueue-block-assets.php
index c85c77fe11d0e..ad98354dd45dc 100644
--- a/packages/e2e-tests/plugins/iframed-enqueue-block-assets.php
+++ b/packages/e2e-tests/plugins/iframed-enqueue-block-assets.php
@@ -9,7 +9,7 @@
add_action(
'enqueue_block_assets',
- function() {
+ static function() {
wp_enqueue_style(
'iframed-enqueue-block-assets',
plugin_dir_url( __FILE__ ) . 'iframed-enqueue-block-assets/style.css',
diff --git a/packages/e2e-tests/plugins/iframed-inline-styles.php b/packages/e2e-tests/plugins/iframed-inline-styles.php
index f54c8eb83e623..ec44e371af6f0 100644
--- a/packages/e2e-tests/plugins/iframed-inline-styles.php
+++ b/packages/e2e-tests/plugins/iframed-inline-styles.php
@@ -9,14 +9,14 @@
add_action(
'setup_theme',
- function() {
+ static function() {
add_theme_support( 'block-templates' );
}
);
add_action(
'init',
- function() {
+ static function() {
wp_register_script(
'iframed-inline-styles-editor-script',
plugin_dir_url( __FILE__ ) . 'iframed-inline-styles/editor.js',
@@ -40,7 +40,7 @@ function() {
add_action(
'enqueue_block_editor_assets',
- function() {
+ static function() {
wp_enqueue_style(
'iframed-inline-styles-compat-style',
plugin_dir_url( __FILE__ ) . 'iframed-inline-styles/compat-style.css',
diff --git a/packages/e2e-tests/plugins/iframed-masonry-block.php b/packages/e2e-tests/plugins/iframed-masonry-block.php
index d8d6ea14120f8..3e7948ae2fa12 100644
--- a/packages/e2e-tests/plugins/iframed-masonry-block.php
+++ b/packages/e2e-tests/plugins/iframed-masonry-block.php
@@ -9,14 +9,14 @@
add_action(
'setup_theme',
- function() {
+ static function() {
add_theme_support( 'block-templates' );
}
);
add_action(
'init',
- function() {
+ static function() {
wp_register_script(
'iframed-masonry-block-editor',
plugin_dir_url( __FILE__ ) . 'iframed-masonry-block/editor.js',
diff --git a/packages/e2e-tests/plugins/iframed-multiple-stylesheets.php b/packages/e2e-tests/plugins/iframed-multiple-stylesheets.php
index 40d7d5040083c..e70ba31938d14 100644
--- a/packages/e2e-tests/plugins/iframed-multiple-stylesheets.php
+++ b/packages/e2e-tests/plugins/iframed-multiple-stylesheets.php
@@ -9,14 +9,14 @@
add_action(
'setup_theme',
- function() {
+ static function() {
add_theme_support( 'block-templates' );
}
);
add_action(
'init',
- function() {
+ static function() {
wp_register_script(
'iframed-multiple-stylesheets-editor-script',
plugin_dir_url( __FILE__ ) . 'iframed-multiple-stylesheets/editor.js',
diff --git a/packages/e2e-tests/plugins/marquee-function-widget.php b/packages/e2e-tests/plugins/marquee-function-widget.php
index dda0c3f9a6e27..85881bab14c49 100644
--- a/packages/e2e-tests/plugins/marquee-function-widget.php
+++ b/packages/e2e-tests/plugins/marquee-function-widget.php
@@ -14,7 +14,7 @@ function marquee_greeting_init() {
wp_register_sidebar_widget(
'marquee_greeting',
'Marquee Greeting',
- function() {
+ static function() {
$greeting = get_option( 'marquee_greeting', 'Hello!' );
printf( '', esc_html( $greeting ) );
}
@@ -23,7 +23,7 @@ function() {
wp_register_widget_control(
'marquee_greeting',
'Marquee Greeting',
- function() {
+ static function() {
if ( isset( $_POST['marquee-greeting'] ) ) {
update_option(
'marquee_greeting',
diff --git a/phpunit/class-block-context-test.php b/phpunit/class-block-context-test.php
index 4cf30478aa568..6c06cfd099bd4 100644
--- a/phpunit/class-block-context-test.php
+++ b/phpunit/class-block-context-test.php
@@ -104,7 +104,7 @@ public function test_provides_block_context() {
'gutenberg/contextWithAssigned',
'gutenberg/contextWithoutDefault',
),
- 'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
+ 'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
$provided_context[] = $block->context;
return '';
@@ -142,7 +142,7 @@ public function test_provides_default_context() {
'gutenberg/test-context-consumer',
array(
'uses_context' => array( 'postId', 'postType' ),
- 'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
+ 'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
$provided_context[] = $block->context;
return '';
@@ -173,7 +173,7 @@ public function test_default_context_is_filterable() {
'gutenberg/test-context-consumer',
array(
'uses_context' => array( 'example' ),
- 'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
+ 'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
$provided_context[] = $block->context;
return '';
@@ -181,7 +181,7 @@ public function test_default_context_is_filterable() {
)
);
- $filter_block_context = function( $context ) {
+ $filter_block_context = static function( $context ) {
$context['example'] = 'ok';
return $context;
};
diff --git a/phpunit/class-wp-rest-pattern-directory-controller-test.php b/phpunit/class-wp-rest-pattern-directory-controller-test.php
index 5f9561a1d5f27..fb42db35ac9c4 100644
--- a/phpunit/class-wp-rest-pattern-directory-controller-test.php
+++ b/phpunit/class-wp-rest-pattern-directory-controller-test.php
@@ -185,7 +185,7 @@ public function data_get_items_query_args() {
private static function capture_http_urls() {
add_filter(
'pre_http_request',
- function ( $preempt, $args, $url ) {
+ static function ( $preempt, $args, $url ) {
if ( 'api.wordpress.org' !== wp_parse_url( $url, PHP_URL_HOST ) ) {
return $preempt;
}
diff --git a/phpunit/fonts-api/wp-fonts-testcase.php b/phpunit/fonts-api/wp-fonts-testcase.php
index f7f7fb04b5062..b7bff9234b9ed 100644
--- a/phpunit/fonts-api/wp-fonts-testcase.php
+++ b/phpunit/fonts-api/wp-fonts-testcase.php
@@ -248,7 +248,7 @@ protected function get_reflection_method( $method_name ) {
protected function setup_registration_mocks( array $inputs, WP_Fonts $wp_fonts ) {
$mocks = array();
- $build_mock = function ( $font_family, $is_font_family = false ) use ( &$mocks, $wp_fonts ) {
+ $build_mock = static function ( $font_family, $is_font_family = false ) use ( &$mocks, $wp_fonts ) {
$mock = new stdClass();
$mock->deps = array();
$mock->extra = array( 'is_font_family' => $is_font_family );