diff --git a/composer.json b/composer.json index 1aa68ca12a3..05e7ad3cc92 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require-dev": { "phpunit/phpunit": "9.6.13", "phpunit/php-code-coverage": "9.2.29", - "woocommerce/woocommerce-sniffs": "0.1.3", + "woocommerce/woocommerce-sniffs": "1.0.0", "phpdocumentor/reflection": "3.0.1", "yoast/phpunit-polyfills": "2.0.0", "nikic/php-parser": "4.16.0 as 1.0.0", diff --git a/composer.lock b/composer.lock index 57aa9fb3766..4fb7127cca8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6866bccfee9df864f774a3ad47d1fdf6", + "content-hash": "f85215f4c89677dfe6802cd46116606f", "packages": [ { "name": "automattic/jetpack-a8c-mc-stats", @@ -55,20 +55,20 @@ }, { "name": "automattic/jetpack-admin-ui", - "version": "v0.2.23", + "version": "v0.2.24", "source": { "type": "git", "url": "https://github.com/Automattic/jetpack-admin-ui.git", - "reference": "2684f3ee3b458074d95e727e70ae994802501688" + "reference": "334858057237be51aa916352c7573fc4c06bbd6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/jetpack-admin-ui/zipball/2684f3ee3b458074d95e727e70ae994802501688", - "reference": "2684f3ee3b458074d95e727e70ae994802501688", + "url": "https://api.github.com/repos/Automattic/jetpack-admin-ui/zipball/334858057237be51aa916352c7573fc4c06bbd6c", + "reference": "334858057237be51aa916352c7573fc4c06bbd6c", "shasum": "" }, "require-dev": { - "automattic/jetpack-changelogger": "^3.3.9", + "automattic/jetpack-changelogger": "^3.3.11", "automattic/jetpack-logo": "^1.6.3", "automattic/wordbless": "dev-master", "yoast/phpunit-polyfills": "1.1.0" @@ -102,9 +102,9 @@ ], "description": "Generic Jetpack wp-admin UI elements", "support": { - "source": "https://github.com/Automattic/jetpack-admin-ui/tree/v0.2.23" + "source": "https://github.com/Automattic/jetpack-admin-ui/tree/v0.2.24" }, - "time": "2023-09-19T18:19:10+00:00" + "time": "2023-10-30T08:37:02+00:00" }, { "name": "automattic/jetpack-autoloader", @@ -632,35 +632,38 @@ "packages-dev": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", "shasum": "" }, "require": { "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", + "php": ">=5.4", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -676,7 +679,7 @@ }, { "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", @@ -700,10 +703,10 @@ "tests" ], "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2022-02-04T12:51:07+00:00" + "time": "2023-01-05T11:28:13+00:00" }, { "name": "doctrine/instantiator", @@ -1416,6 +1419,142 @@ }, "time": "2022-10-24T09:00:36+00:00" }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "746c3190ba8eb2f212087c947ba75f4f5b9a58d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/746c3190ba8eb2f212087c947ba75f4f5b9a58d5", + "reference": "746c3190ba8eb2f212087c947ba75f4f5b9a58d5", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.0.8", + "squizlabs/php_codesniffer": "^3.7.1" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "time": "2023-09-20T22:06:18+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "69465cab9d12454e5e7767b9041af0cd8cd13be7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/69465cab9d12454e5e7767b9041af0cd8cd13be7", + "reference": "69465cab9d12454e5e7767b9041af0cd8cd13be7", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.7.1 || 4.0.x-dev@dev" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "yoast/phpunit-polyfills": "^1.0.5 || ^2.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "time": "2023-07-16T21:39:41+00:00" + }, { "name": "phpdocumentor/reflection", "version": "3.0.1", @@ -3072,74 +3211,77 @@ }, { "name": "woocommerce/woocommerce-sniffs", - "version": "0.1.3", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-sniffs.git", - "reference": "4576d54595614d689bc4436acff8baaece3c5bb0" + "reference": "3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/4576d54595614d689bc4436acff8baaece3c5bb0", - "reference": "4576d54595614d689bc4436acff8baaece3c5bb0", + "url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8", + "reference": "3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "php": ">=7.0", "phpcompatibility/phpcompatibility-wp": "^2.1.0", - "wp-coding-standards/wpcs": "^2.3.0" + "wp-coding-standards/wpcs": "^3.0.0" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Claudio Sanches", - "email": "claudio@automattic.com" - } - ], "description": "WooCommerce sniffs", "keywords": [ "phpcs", "standards", + "static analysis", "woocommerce", "wordpress" ], "support": { "issues": "https://github.com/woocommerce/woocommerce-sniffs/issues", - "source": "https://github.com/woocommerce/woocommerce-sniffs/tree/0.1.3" + "source": "https://github.com/woocommerce/woocommerce-sniffs/tree/1.0.0" }, - "time": "2022-02-17T15:34:51+00:00" + "time": "2023-09-29T13:52:33+00:00" }, { "name": "wp-coding-standards/wpcs", - "version": "2.3.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "7da1894633f168fe244afc6de00d141f27517b62" + "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", - "reference": "7da1894633f168fe244afc6de00d141f27517b62", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b4caf9689f1a0e4a4c632679a44e638c1c67aff1", + "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1", "shasum": "" }, "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.3.1" + "phpcsstandards/phpcsextra": "^1.1.0", + "phpcsstandards/phpcsutils": "^1.0.8", + "squizlabs/php_codesniffer": "^3.7.2" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcompatibility/php-compatibility": "^9.0", - "phpcsstandards/phpcsdevtools": "^1.0", + "phpcsstandards/phpcsdevtools": "^1.2.0", "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -3156,6 +3298,7 @@ "keywords": [ "phpcs", "standards", + "static analysis", "wordpress" ], "support": { @@ -3163,7 +3306,13 @@ "source": "https://github.com/WordPress/WordPress-Coding-Standards", "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, - "time": "2020-05-13T23:57:56+00:00" + "funding": [ + { + "url": "https://opencollective.com/thewpcc/contribute/wp-php-63406", + "type": "custom" + } + ], + "time": "2023-09-14T07:06:09+00:00" }, { "name": "wp-hooks/generator", @@ -3299,5 +3448,5 @@ "platform-overrides": { "php": "7.4.33" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/phpcs.xml b/phpcs.xml index 2184d7a6e83..83c49eebcb7 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -34,7 +34,7 @@ src/* - + src/* tests/* @@ -67,7 +67,7 @@ - + src/* diff --git a/src/Assets/Api.php b/src/Assets/Api.php index da8374c523a..f3386b67ede 100644 --- a/src/Assets/Api.php +++ b/src/Assets/Api.php @@ -240,7 +240,7 @@ public function register_script( $handle, $relative_src, $dependencies = [], $ha $dependencies = array_diff( $script_data['dependencies'], [ $handle ] ); add_action( 'admin_notices', - function() use ( $handle ) { + function () use ( $handle ) { echo '

'; /* translators: %s file handle name. */ printf( esc_html__( 'Script with handle %s had a dependency on itself which has been removed. This is an indicator that your JS code has a circular dependency that can cause bugs.', 'woo-gutenberg-products-block' ), esc_html( $handle ) ); diff --git a/src/Assets/AssetDataRegistry.php b/src/Assets/AssetDataRegistry.php index f8fed09cc26..44950d581f3 100644 --- a/src/Assets/AssetDataRegistry.php +++ b/src/Assets/AssetDataRegistry.php @@ -341,7 +341,7 @@ public function hydrate_api_request( $path ) { public function hydrate_data_from_api_request( $key, $path, $check_key_exists = false ) { $this->add( $key, - function() use ( $path ) { + function () use ( $path ) { if ( isset( $this->preloaded_api_requests[ $path ], $this->preloaded_api_requests[ $path ]['body'] ) ) { return $this->preloaded_api_requests[ $path ]['body']; } diff --git a/src/AssetsController.php b/src/AssetsController.php index 3fbd7b961ac..814027ae673 100644 --- a/src/AssetsController.php +++ b/src/AssetsController.php @@ -200,7 +200,7 @@ private function get_block_asset_resource_hints( $filename = '' ) { $this->get_script_dependency_src_array( $script_data['dependencies'] ) ); return array_map( - function( $src ) { + function ( $src ) { return array( 'href' => $src, 'as' => 'script', @@ -220,7 +220,7 @@ private function get_script_dependency_src_array( array $dependencies ) { $wp_scripts = wp_scripts(); return array_reduce( $dependencies, - function( $src, $handle ) use ( $wp_scripts ) { + function ( $src, $handle ) use ( $wp_scripts ) { if ( isset( $wp_scripts->registered[ $handle ] ) ) { $src[] = esc_url( add_query_arg( 'ver', $wp_scripts->registered[ $handle ]->ver, $this->get_absolute_url( $wp_scripts->registered[ $handle ]->src ) ) ); $src = array_merge( $src, $this->get_script_dependency_src_array( $wp_scripts->registered[ $handle ]->deps ) ); diff --git a/src/BlockTemplatesController.php b/src/BlockTemplatesController.php index 7538cea4e1f..6e47f797c21 100644 --- a/src/BlockTemplatesController.php +++ b/src/BlockTemplatesController.php @@ -72,7 +72,7 @@ protected function init() { // This render_callback wrapper allows us to add support for plugin-housed template parts. add_filter( 'block_type_metadata_settings', - function( $settings, $metadata ) { + function ( $settings, $metadata ) { if ( isset( $metadata['name'], $settings['render_callback'] ) && 'core/template-part' === $metadata['name'] && @@ -90,13 +90,13 @@ function( $settings, $metadata ) { // @see https://core.trac.wordpress.org/ticket/58366 for more info. add_filter( 'block_type_metadata_settings', - function( $settings, $metadata ) { + function ( $settings, $metadata ) { if ( isset( $metadata['name'], $settings['render_callback'] ) && 'core/shortcode' === $metadata['name'] ) { $settings['original_render_callback'] = $settings['render_callback']; - $settings['render_callback'] = function( $attributes, $content ) use ( $settings ) { + $settings['render_callback'] = function ( $attributes, $content ) use ( $settings ) { // The shortcode has already been rendered, so look for the cart/checkout HTML. if ( strstr( $content, 'woocommerce-cart-form' ) || strstr( $content, 'wc-empty-cart-message' ) || strstr( $content, 'woocommerce-checkout-form' ) ) { // Return early before wpautop runs again. @@ -410,7 +410,7 @@ public function add_block_templates( $query_result, $query, $template_type ) { * templates that aren't listed in theme.json. */ $query_result = array_map( - function( $template ) { + function ( $template ) { if ( str_contains( $template->slug, 'single-product' ) ) { // We don't want to add the compatibility layer on the Editor Side. // The second condition is necessary to not apply the compatibility layer on the REST API. Gutenberg uses the REST API to clone the template. @@ -419,7 +419,7 @@ function( $template ) { // Add the product class to the body. We should move this to a more appropriate place. add_filter( 'body_class', - function( $classes ) { + function ( $classes ) { return array_merge( $classes, wc_get_product_class() ); } ); @@ -510,7 +510,7 @@ public function get_block_templates_from_woocommerce( $slugs, $already_found_tem array_filter( $already_found_templates, function ( $template ) use ( $template_slug ) { - $template_obj = (object) $template; //phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.Found + $template_obj = (object) $template; //phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.Found return $template_obj->slug === $template_slug; } ) diff --git a/src/BlockTypes/AbstractBlock.php b/src/BlockTypes/AbstractBlock.php index c4ef90ddfb2..bf2e4aeb5fa 100644 --- a/src/BlockTypes/AbstractBlock.php +++ b/src/BlockTypes/AbstractBlock.php @@ -230,7 +230,7 @@ protected function register_block_type() { $block_settings['style'] = null; add_filter( 'render_block', - function( $html, $block ) use ( $style_handles ) { + function ( $html, $block ) use ( $style_handles ) { if ( $block['blockName'] === $this->get_block_type() ) { array_map( 'wp_enqueue_style', $style_handles ); } diff --git a/src/BlockTypes/AbstractProductGrid.php b/src/BlockTypes/AbstractProductGrid.php index a7460767493..1cac2dc69d7 100644 --- a/src/BlockTypes/AbstractProductGrid.php +++ b/src/BlockTypes/AbstractProductGrid.php @@ -430,7 +430,7 @@ protected function prime_product_variations( $product_ids ) { // Prepare the data to cache by indexing by the parent product. $primed_data = array_reduce( $all_variation_meta_data, - function( $values, $data ) use ( $variation_ids_by_parent ) { + function ( $values, $data ) use ( $variation_ids_by_parent ) { $values[ $variation_ids_by_parent[ $data->variation_id ] ?? 0 ][] = $data; return $values; }, diff --git a/src/BlockTypes/Checkout.php b/src/BlockTypes/Checkout.php index 38133e31b14..614a4669d0d 100644 --- a/src/BlockTypes/Checkout.php +++ b/src/BlockTypes/Checkout.php @@ -36,7 +36,7 @@ protected function initialize() { // This prevents the page redirecting when the cart is empty. This is so the editor still loads the page preview. add_filter( 'woocommerce_checkout_redirect_empty_cart', - function( $return ) { + function ( $return ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return isset( $_GET['_wp-find-template'] ) ? false : $return; } @@ -283,7 +283,7 @@ protected function enqueue_data( array $attributes = [] ) { $shipping_methods = WC()->shipping()->get_shipping_methods(); $formatted_shipping_methods = array_reduce( $shipping_methods, - function( $acc, $method ) { + function ( $acc, $method ) { if ( in_array( $method->id, LocalPickupUtils::get_local_pickup_method_ids(), true ) ) { return $acc; } @@ -305,7 +305,7 @@ function( $acc, $method ) { $shipping_zones = \WC_Shipping_Zones::get_zones(); $formatted_shipping_zones = array_reduce( $shipping_zones, - function( $acc, $zone ) { + function ( $acc, $zone ) { $acc[] = [ 'id' => $zone['id'], 'title' => $zone['zone_name'], @@ -329,7 +329,7 @@ function( $acc, $zone ) { $payment_methods = $this->get_enabled_payment_gateways(); $formatted_payment_methods = array_reduce( $payment_methods, - function( $acc, $method ) { + function ( $acc, $method ) { $acc[] = [ 'id' => $method->id, 'title' => $method->method_title, @@ -354,7 +354,7 @@ function( $acc, $method ) { $declared_extensions = \Automattic\WooCommerce\Utilities\FeaturesUtil::get_compatible_plugins_for_feature( 'cart_checkout_blocks' ); $incompatible_extensions = array_reduce( $declared_extensions['incompatible'], - function( $acc, $item ) { + function ( $acc, $item ) { $plugin = get_plugin_data( WP_PLUGIN_DIR . '/' . $item ); $acc[] = [ 'id' => $plugin['TextDomain'], @@ -390,7 +390,7 @@ protected function get_enabled_payment_gateways() { $payment_gateways = WC()->payment_gateways->payment_gateways(); return array_filter( $payment_gateways, - function( $payment_gateway ) { + function ( $payment_gateway ) { return 'yes' === $payment_gateway->enabled; } ); @@ -424,7 +424,7 @@ protected function hydrate_customer_payment_methods() { foreach ( $payment_methods as $payment_method_group => $saved_payment_methods ) { $payment_methods[ $payment_method_group ] = array_filter( $saved_payment_methods, - function( $saved_payment_method ) use ( $payment_gateways ) { + function ( $saved_payment_method ) use ( $payment_gateways ) { return in_array( $saved_payment_method['method']['gateway'], array_keys( $payment_gateways ), true ); } ); diff --git a/src/BlockTypes/ClassicTemplate.php b/src/BlockTypes/ClassicTemplate.php index 9b292f8bd02..f53b80328f4 100644 --- a/src/BlockTypes/ClassicTemplate.php +++ b/src/BlockTypes/ClassicTemplate.php @@ -138,7 +138,7 @@ protected function render_order_received() { echo '

'; - echo sprintf( + printf( '<%1$s %2$s>%3$s', 'h1', get_block_wrapper_attributes(), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped @@ -382,7 +382,7 @@ public function filter_products_by_stock( $meta_query ) { $filtered_values = array_filter( $values_to_array, - function( $value ) use ( $stock_status ) { + function ( $value ) use ( $stock_status ) { return in_array( $value, $stock_status, true ); } ); diff --git a/src/BlockTypes/CollectionFilters.php b/src/BlockTypes/CollectionFilters.php index e00d4ef4fa2..c037d242a29 100644 --- a/src/BlockTypes/CollectionFilters.php +++ b/src/BlockTypes/CollectionFilters.php @@ -151,7 +151,7 @@ private function get_aggregated_collection_data( $block ) { $inner_blocks = $this->get_inner_blocks_recursive( $block->inner_blocks ); $collection_data_params = array_map( - function( $block_name ) use ( $inner_blocks ) { + function ( $block_name ) use ( $inner_blocks ) { return in_array( $block_name, $inner_blocks, true ); }, $this->collection_data_params_mapping @@ -222,7 +222,7 @@ private function get_formatted_products_params( $query ) { $shared_params = array( 'exclude', 'offset', 'order', 'serach' ); array_walk( $shared_params, - function( $key ) use ( $query, &$params ) { + function ( $key ) use ( $query, &$params ) { $params[ $key ] = $query[ $key ] ?? ''; } ); @@ -241,7 +241,7 @@ function( $key ) use ( $query, &$params ) { ); array_walk( $mapped_params, - function( $mapped_key, $original_key ) use ( $query, &$params ) { + function ( $mapped_key, $original_key ) use ( $query, &$params ) { $params[ $mapped_key ] = $query[ $original_key ] ?? ''; } ); @@ -250,7 +250,7 @@ function( $mapped_key, $original_key ) use ( $query, &$params ) { * The value of taxQuery and woocommerceAttributes need additional * transformation to the shape that Store API accepts. */ - $taxonomy_mapper = function( $key ) { + $taxonomy_mapper = function ( $key ) { $mapping = array( 'product_tag' => 'tag', 'product_cat' => 'category', @@ -262,7 +262,7 @@ function( $mapped_key, $original_key ) use ( $query, &$params ) { if ( is_array( $query['taxQuery'] ) ) { array_walk( $query['taxQuery'], - function( $terms, $taxonomy ) use ( $taxonomy_mapper, &$params ) { + function ( $terms, $taxonomy ) use ( $taxonomy_mapper, &$params ) { $params[ $taxonomy_mapper( $taxonomy ) ] = implode( ',', $terms ); } ); @@ -271,7 +271,7 @@ function( $terms, $taxonomy ) use ( $taxonomy_mapper, &$params ) { if ( is_array( $query['woocommerceAttributes'] ) ) { array_walk( $query['woocommerceAttributes'], - function( $attribute ) use ( &$params ) { + function ( $attribute ) use ( &$params ) { $params['attributes'][] = array( 'attribute' => $attribute['taxonomy'], 'term_id' => $attribute['termId'], diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 731a53e0cc2..fecce31ea20 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -532,7 +532,7 @@ protected function get_tax_label() { 'tax_label' => $tax_label, 'display_cart_prices_including_tax' => false, ); - }; + } return array( 'tax_label' => '', diff --git a/src/BlockTypes/MiniCartContents.php b/src/BlockTypes/MiniCartContents.php index 0b3e618aef5..fe25c54b77b 100644 --- a/src/BlockTypes/MiniCartContents.php +++ b/src/BlockTypes/MiniCartContents.php @@ -122,7 +122,7 @@ protected function enqueue_assets( array $attributes, $content, $block ) { $properties = array_filter( $style['properties'], - function( $property ) { + function ( $property ) { return $property['value']; } ); @@ -165,5 +165,4 @@ public static function get_mini_cart_block_types() { return $block_types; } - } diff --git a/src/BlockTypes/OrderConfirmation/Totals.php b/src/BlockTypes/OrderConfirmation/Totals.php index e539b5f445c..eeeba83180e 100644 --- a/src/BlockTypes/OrderConfirmation/Totals.php +++ b/src/BlockTypes/OrderConfirmation/Totals.php @@ -101,7 +101,7 @@ protected function render_order_details_table_items( $order ) { $order_items = array_filter( // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) ), - function( $item ) { + function ( $item ) { // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment return apply_filters( 'woocommerce_order_item_visible', true, $item ); } diff --git a/src/BlockTypes/ProductAverageRating.php b/src/BlockTypes/ProductAverageRating.php index 6f98fb9757d..176fceb1e56 100644 --- a/src/BlockTypes/ProductAverageRating.php +++ b/src/BlockTypes/ProductAverageRating.php @@ -100,4 +100,3 @@ protected function render( $attributes, $content, $block ) { ); } } - diff --git a/src/BlockTypes/ProductCategories.php b/src/BlockTypes/ProductCategories.php index 083f9a8d8cc..eb7d23acfd0 100644 --- a/src/BlockTypes/ProductCategories.php +++ b/src/BlockTypes/ProductCategories.php @@ -169,7 +169,7 @@ protected function get_categories( $attributes ) { if ( ! $attributes['hasEmpty'] ) { $categories = array_filter( $categories, - function( $category ) { + function ( $category ) { return 0 !== $category->count; } ); diff --git a/src/BlockTypes/ProductCollection.php b/src/BlockTypes/ProductCollection.php index 675608d28d2..0ad77cc9423 100644 --- a/src/BlockTypes/ProductCollection.php +++ b/src/BlockTypes/ProductCollection.php @@ -372,7 +372,7 @@ public function extend_rest_query_allowed_params( $params ) { private function merge_queries( ...$queries ) { $merged_query = array_reduce( $queries, - function( $acc, $query ) { + function ( $acc, $query ) { if ( ! is_array( $query ) ) { return $acc; } @@ -537,15 +537,13 @@ private function array_merge_recursive_replace_non_array_properties( $base, $new foreach ( $new as $key => $value ) { if ( is_numeric( $key ) ) { $base[] = $value; - } else { - if ( is_array( $value ) ) { - if ( ! isset( $base[ $key ] ) ) { - $base[ $key ] = array(); - } - $base[ $key ] = $this->array_merge_recursive_replace_non_array_properties( $base[ $key ], $value ); - } else { - $base[ $key ] = $value; + } elseif ( is_array( $value ) ) { + if ( ! isset( $base[ $key ] ) ) { + $base[ $key ] = array(); } + $base[ $key ] = $this->array_merge_recursive_replace_non_array_properties( $base[ $key ], $value ); + } else { + $base[ $key ] = $value; } } @@ -718,7 +716,7 @@ private function get_filter_by_taxonomies_query( $tax_query ): array { $product_taxonomies = get_taxonomies( [ 'object_type' => [ 'product' ] ], 'names' ); $result = array_filter( $tax_query, - function( $item ) use ( $product_taxonomies ) { + function ( $item ) use ( $product_taxonomies ) { return isset( $item['taxonomy'] ) && in_array( $item['taxonomy'], $product_taxonomies, true ); } ); @@ -807,7 +805,7 @@ private function get_filter_by_attributes_query() { $queries = array_reduce( $attributes_filter_query_args, - function( $acc, $query_args ) { + function ( $acc, $query_args ) { $attribute_name = $query_args['filter']; $attribute_query_type = $query_args['query_type']; @@ -872,7 +870,7 @@ private function get_filter_by_attributes_query_vars() { $this->attributes_filter_query_args = array_reduce( wc_get_attribute_taxonomies(), - function( $acc, $attribute ) { + function ( $acc, $attribute ) { $acc[ $attribute->attribute_name ] = array( 'filter' => AttributeFilter::FILTER_QUERY_VAR_PREFIX . $attribute->attribute_name, 'query_type' => AttributeFilter::QUERY_TYPE_QUERY_VAR_PREFIX . $attribute->attribute_name, @@ -899,7 +897,7 @@ private function get_filter_by_stock_status_query() { $filtered_stock_status_values = array_filter( explode( ',', $filter_stock_status_values ), - function( $stock_status ) { + function ( $stock_status ) { return in_array( $stock_status, StockFilter::get_stock_status_query_var_values(), true ); } ); @@ -940,7 +938,7 @@ private function get_filter_by_rating_query() { } $rating_terms = array_map( - function( $rating ) use ( $product_visibility_terms ) { + function ( $rating ) use ( $product_visibility_terms ) { return $product_visibility_terms[ 'rated-' . $rating ]; }, $parsed_filter_rating_values diff --git a/src/BlockTypes/ProductGallery.php b/src/BlockTypes/ProductGallery.php index 2c82642c36b..30afb424f29 100644 --- a/src/BlockTypes/ProductGallery.php +++ b/src/BlockTypes/ProductGallery.php @@ -59,7 +59,7 @@ protected function render_dialog() { $html = array_reduce( $parsed_template, - function( $carry, $item ) { + function ( $carry, $item ) { return $carry . render_block( $item ); }, '' diff --git a/src/BlockTypes/ProductGalleryLargeImage.php b/src/BlockTypes/ProductGalleryLargeImage.php index 8b126b83e1e..ef27dca6beb 100644 --- a/src/BlockTypes/ProductGalleryLargeImage.php +++ b/src/BlockTypes/ProductGalleryLargeImage.php @@ -98,7 +98,7 @@ protected function render( $attributes, $content, $block ) { '{content}' => $content, '{directives}' => array_reduce( array_keys( $directives ), - function( $carry, $key ) use ( $directives ) { + function ( $carry, $key ) use ( $directives ) { return $carry . ' ' . $key . '="' . esc_attr( $directives[ $key ] ) . '"'; }, '' @@ -140,7 +140,7 @@ private function get_main_images_html( $context, $product_id ) { ); $main_image_with_wrapper = array_map( - function( $main_image_element ) { + function ( $main_image_element ) { return "'; }, $main_images @@ -148,7 +148,6 @@ function( $main_image_element ) { $visible_main_image = array_shift( $main_images ); return array( $visible_main_image, $main_image_with_wrapper ); - } /** diff --git a/src/BlockTypes/ProductGalleryLargeImageNextPrevious.php b/src/BlockTypes/ProductGalleryLargeImageNextPrevious.php index 60fd86f9410..9b7a362d69a 100644 --- a/src/BlockTypes/ProductGalleryLargeImageNextPrevious.php +++ b/src/BlockTypes/ProductGalleryLargeImageNextPrevious.php @@ -176,7 +176,6 @@ protected function get_inside_button( $button_type, $context ) { $this->get_class_suffix( $context ), $icon_path ); - } /** @@ -216,6 +215,5 @@ protected function get_outside_button( $button_type, $context ) { $this->get_class_suffix( $context ), $icon_path ); - } } diff --git a/src/BlockTypes/ProductGalleryThumbnails.php b/src/BlockTypes/ProductGalleryThumbnails.php index be083c13290..3222acdbd1e 100644 --- a/src/BlockTypes/ProductGalleryThumbnails.php +++ b/src/BlockTypes/ProductGalleryThumbnails.php @@ -85,7 +85,7 @@ protected function render( $attributes, $content, $block ) { $html .= $processor->get_updated_html(); } - $thumbnails_count++; + ++$thumbnails_count; } return sprintf( diff --git a/src/BlockTypes/ProductQuery.php b/src/BlockTypes/ProductQuery.php index be61ea4d509..52e356fedce 100644 --- a/src/BlockTypes/ProductQuery.php +++ b/src/BlockTypes/ProductQuery.php @@ -278,7 +278,7 @@ public function build_query( $query ) { private function merge_queries( ...$queries ) { $merged_query = array_reduce( $queries, - function( $acc, $query ) { + function ( $acc, $query ) { if ( ! is_array( $query ) ) { return $acc; } @@ -495,7 +495,7 @@ private function get_product_visibility_query( $stock_query ) { private function get_query_vars_from_filter_blocks() { $attributes_filter_query_args = array_reduce( array_values( $this->get_filter_by_attributes_query_vars() ), - function( $acc, $array ) { + function ( $acc, $array ) { return array_merge( array_values( $array ), $acc ); }, array() @@ -507,7 +507,6 @@ function( $acc, $array ) { 'attributes_filter_query_args' => $attributes_filter_query_args, 'rating_filter_query_args' => array( RatingFilter::RATING_QUERY_VAR ), ); - } /** @@ -521,7 +520,7 @@ public function set_query_vars( $public_query_vars ) { return array_reduce( array_values( $query_vars ), - function( $acc, $query_vars_filter_block ) { + function ( $acc, $query_vars_filter_block ) { return array_merge( $query_vars_filter_block, $acc ); }, $public_query_vars @@ -552,7 +551,7 @@ private function get_filter_by_attributes_query_vars() { $this->attributes_filter_query_args = array_reduce( wc_get_attribute_taxonomies(), - function( $acc, $attribute ) { + function ( $acc, $attribute ) { $acc[ $attribute->attribute_name ] = array( 'filter' => AttributeFilter::FILTER_QUERY_VAR_PREFIX . $attribute->attribute_name, 'query_type' => AttributeFilter::QUERY_TYPE_QUERY_VAR_PREFIX . $attribute->attribute_name, @@ -648,7 +647,7 @@ private function get_filter_by_attributes_query() { $queries = array_reduce( $attributes_filter_query_args, - function( $acc, $query_args ) { + function ( $acc, $query_args ) { $attribute_name = $query_args['filter']; $attribute_query_type = $query_args['query_type']; @@ -702,7 +701,7 @@ private function get_filter_by_stock_status_query() { $filtered_stock_status_values = array_filter( explode( ',', $filter_stock_status_values ), - function( $stock_status ) { + function ( $stock_status ) { return in_array( $stock_status, StockFilter::get_stock_status_query_var_values(), true ); } ); @@ -815,15 +814,13 @@ private function array_merge_recursive_replace_non_array_properties( $base, $new foreach ( $new as $key => $value ) { if ( is_numeric( $key ) ) { $base[] = $value; - } else { - if ( is_array( $value ) ) { - if ( ! isset( $base[ $key ] ) ) { - $base[ $key ] = array(); - } - $base[ $key ] = $this->array_merge_recursive_replace_non_array_properties( $base[ $key ], $value ); - } else { - $base[ $key ] = $value; + } elseif ( is_array( $value ) ) { + if ( ! isset( $base[ $key ] ) ) { + $base[ $key ] = array(); } + $base[ $key ] = $this->array_merge_recursive_replace_non_array_properties( $base[ $key ], $value ); + } else { + $base[ $key ] = $value; } } @@ -888,7 +885,7 @@ private function get_filter_by_rating_query() { } $rating_terms = array_map( - function( $rating ) use ( $product_visibility_terms ) { + function ( $rating ) use ( $product_visibility_terms ) { return $product_visibility_terms[ 'rated-' . $rating ]; }, $parsed_filter_rating_values @@ -943,7 +940,7 @@ private function get_filter_by_taxonomies_query( $query ): array { $product_taxonomies = get_taxonomies( array( 'object_type' => array( 'product' ) ), 'names' ); $result = array_filter( $tax_query, - function( $item ) use ( $product_taxonomies ) { + function ( $item ) use ( $product_taxonomies ) { return isset( $item['taxonomy'] ) && in_array( $item['taxonomy'], $product_taxonomies, true ); } ); diff --git a/src/BlockTypes/ProductRating.php b/src/BlockTypes/ProductRating.php index d9dfec13379..fe3865d823e 100644 --- a/src/BlockTypes/ProductRating.php +++ b/src/BlockTypes/ProductRating.php @@ -132,7 +132,7 @@ protected function render( $attributes, $content, $block ) { * @param int $count Total number of ratings. * @return string */ - $filter_rating_html = function( $html, $rating, $count ) use ( $post_id, $product_rating, $product_reviews_count, $is_descendent_of_single_product_block, $is_descendent_of_single_product_template ) { + $filter_rating_html = function ( $html, $rating, $count ) use ( $post_id, $product_rating, $product_reviews_count, $is_descendent_of_single_product_block, $is_descendent_of_single_product_template ) { $product_permalink = get_permalink( $post_id ); $reviews_count = $count; $average_rating = $rating; diff --git a/src/BlockTypes/ProductRatingCounter.php b/src/BlockTypes/ProductRatingCounter.php index be85c94d2fd..4e3fa74954e 100644 --- a/src/BlockTypes/ProductRatingCounter.php +++ b/src/BlockTypes/ProductRatingCounter.php @@ -132,7 +132,7 @@ protected function render( $attributes, $content, $block ) { * @param int $count Total number of ratings. * @return string */ - $filter_rating_html = function( $html, $rating, $count ) use ( $post_id, $product_rating, $product_reviews_count, $is_descendent_of_single_product_block, $is_descendent_of_single_product_template ) { + $filter_rating_html = function ( $html, $rating, $count ) use ( $post_id, $product_rating, $product_reviews_count, $is_descendent_of_single_product_block, $is_descendent_of_single_product_template ) { $product_permalink = get_permalink( $post_id ); $reviews_count = $count; $average_rating = $rating; @@ -206,4 +206,3 @@ protected function render( $attributes, $content, $block ) { return ''; } } - diff --git a/src/BlockTypes/ProductRatingStars.php b/src/BlockTypes/ProductRatingStars.php index 4cb0402e672..e4f29dfaa26 100644 --- a/src/BlockTypes/ProductRatingStars.php +++ b/src/BlockTypes/ProductRatingStars.php @@ -101,7 +101,7 @@ protected function render( $attributes, $content, $block ) { * @param int $count Total number of ratings. * @return string */ - $filter_rating_html = function( $html, $rating, $count ) use ( $product_rating, $product_reviews_count ) { + $filter_rating_html = function ( $html, $rating, $count ) use ( $product_rating, $product_reviews_count ) { $product_permalink = get_permalink(); $reviews_count = $count; $average_rating = $rating; diff --git a/src/BlockTypes/ProductStockIndicator.php b/src/BlockTypes/ProductStockIndicator.php index f95ad94951e..f7877b09bf2 100644 --- a/src/BlockTypes/ProductStockIndicator.php +++ b/src/BlockTypes/ProductStockIndicator.php @@ -110,6 +110,5 @@ protected function render( $attributes, $content, $block ) { $output .= '
'; return $output; - } } diff --git a/src/BlockTypes/RelatedProducts.php b/src/BlockTypes/RelatedProducts.php index 0516c3f88e9..d5f3f4cb856 100644 --- a/src/BlockTypes/RelatedProducts.php +++ b/src/BlockTypes/RelatedProducts.php @@ -41,7 +41,6 @@ protected function initialize() { 10, 2 ); - } /** @@ -164,7 +163,7 @@ private function get_related_products_ids( $product_per_page = 5 ) { $related_products = wc_products_array_orderby( $related_products, 'rand', 'desc' ); $related_product_ids = array_map( - function( $product ) { + function ( $product ) { return $product->get_id(); }, $related_products @@ -172,5 +171,4 @@ function( $product ) { return $related_product_ids; } - } diff --git a/src/BlockTypes/StockFilter.php b/src/BlockTypes/StockFilter.php index 82fe9b696ee..7abe008f871 100644 --- a/src/BlockTypes/StockFilter.php +++ b/src/BlockTypes/StockFilter.php @@ -24,7 +24,6 @@ protected function enqueue_data( array $stock_statuses = [] ) { parent::enqueue_data( $stock_statuses ); $this->asset_data_registry->add( 'stockStatusOptions', wc_get_product_stock_status_options(), true ); $this->asset_data_registry->add( 'hideOutOfStockItems', 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ), true ); - } /** diff --git a/src/BlockTypesController.php b/src/BlockTypesController.php index 2c9e175fbe5..aa3a66c5b31 100644 --- a/src/BlockTypesController.php +++ b/src/BlockTypesController.php @@ -303,5 +303,4 @@ protected function get_block_types() { return $block_types; } - } diff --git a/src/Domain/Bootstrap.php b/src/Domain/Bootstrap.php index 58b1f13ac0e..1e1e629b6d0 100644 --- a/src/Domain/Bootstrap.php +++ b/src/Domain/Bootstrap.php @@ -112,7 +112,7 @@ protected function init() { add_action( 'admin_init', - function() { + function () { // Delete this notification because the blocks are included in WC Core now. This will handle any sites // with lingering notices. InboxNotifications::delete_surface_cart_checkout_blocks_notification(); @@ -181,7 +181,7 @@ protected function has_core_dependencies() { $has_needed_dependencies = false; add_action( 'admin_notices', - function() { + function () { if ( should_display_compatibility_notices() ) { ?>
@@ -216,7 +216,7 @@ protected function add_build_notice() { } add_action( 'admin_notices', - function() { + function () { echo '

'; printf( /* translators: %1$s is the install command, %2$s is the build command, %3$s is the watch command. */ @@ -255,19 +255,19 @@ function ( Container $container ) { ); $this->container->register( AssetDataRegistry::class, - function( Container $container ) { + function ( Container $container ) { return new AssetDataRegistry( $container->get( AssetApi::class ) ); } ); $this->container->register( AssetsController::class, - function( Container $container ) { + function ( Container $container ) { return new AssetsController( $container->get( AssetApi::class ) ); } ); $this->container->register( PaymentMethodRegistry::class, - function() { + function () { return new PaymentMethodRegistry(); } ); @@ -349,26 +349,26 @@ function () { ); $this->container->register( DraftOrders::class, - function( Container $container ) { + function ( Container $container ) { return new DraftOrders( $container->get( Package::class ) ); } ); $this->container->register( CreateAccount::class, - function( Container $container ) { + function ( Container $container ) { return new CreateAccount( $container->get( Package::class ) ); } ); $this->container->register( GoogleAnalytics::class, - function( Container $container ) { + function ( Container $container ) { $asset_api = $container->get( AssetApi::class ); return new GoogleAnalytics( $asset_api ); } ); $this->container->register( JetpackWooCommerceAnalytics::class, - function( Container $container ) { + function ( Container $container ) { $asset_api = $container->get( AssetApi::class ); $asset_data_registry = $container->get( AssetDataRegistry::class ); $block_templates_controller = $container->get( BlockTemplatesController::class ); @@ -377,13 +377,13 @@ function( Container $container ) { ); $this->container->register( Notices::class, - function( Container $container ) { + function ( Container $container ) { return new Notices( $container->get( Package::class ) ); } ); $this->container->register( Hydration::class, - function( Container $container ) { + function ( Container $container ) { return new Hydration( $container->get( AssetDataRegistry::class ) ); } ); @@ -404,28 +404,28 @@ function () { // Maintains backwards compatibility with previous Store API namespace. $this->container->register( 'Automattic\WooCommerce\Blocks\StoreApi\Formatters', - function( Container $container ) { + function ( Container $container ) { $this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\Formatters', '7.2.0', 'Automattic\WooCommerce\StoreApi\Formatters', '7.4.0' ); return $container->get( StoreApi::class )->container()->get( \Automattic\WooCommerce\StoreApi\Formatters::class ); } ); $this->container->register( 'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', - function( Container $container ) { + function ( Container $container ) { $this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', '7.2.0', 'Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema', '7.4.0' ); return $container->get( StoreApi::class )->container()->get( \Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::class ); } ); $this->container->register( 'Automattic\WooCommerce\Blocks\StoreApi\SchemaController', - function( Container $container ) { + function ( Container $container ) { $this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\SchemaController', '7.2.0', 'Automattic\WooCommerce\StoreApi\SchemaController', '7.4.0' ); return $container->get( StoreApi::class )->container()->get( SchemaController::class ); } ); $this->container->register( 'Automattic\WooCommerce\Blocks\StoreApi\RoutesController', - function( Container $container ) { + function ( Container $container ) { $this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\RoutesController', '7.2.0', 'Automattic\WooCommerce\StoreApi\RoutesController', '7.4.0' ); return $container->get( StoreApi::class )->container()->get( RoutesController::class ); } @@ -446,7 +446,7 @@ function ( $container ) { ); $this->container->register( TasksController::class, - function() { + function () { return new TasksController(); } ); @@ -455,12 +455,12 @@ function() { /** * Throws a deprecation notice for a dependency without breaking requests. * - * @param string $function Class or function being deprecated. + * @param string $function_name Class or function being deprecated. * @param string $version Version in which it was deprecated. * @param string $replacement Replacement class or function, if applicable. * @param string $trigger_error_version Optional version to start surfacing this as a PHP error rather than a log. Defaults to $version. */ - protected function deprecated_dependency( $function, $version, $replacement = '', $trigger_error_version = '' ) { + protected function deprecated_dependency( $function_name, $version, $replacement = '', $trigger_error_version = '' ) { if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { return; } @@ -468,12 +468,12 @@ protected function deprecated_dependency( $function, $version, $replacement = '' $trigger_error_version = $trigger_error_version ? $trigger_error_version : $version; $error_message = $replacement ? sprintf( '%1$s is deprecated since version %2$s! Use %3$s instead.', - $function, + $function_name, $version, $replacement ) : sprintf( '%1$s is deprecated since version %2$s with no alternative available.', - $function, + $function_name, $version ); /** @@ -481,7 +481,7 @@ protected function deprecated_dependency( $function, $version, $replacement = '' * * @since 7.3.0 */ - do_action( 'deprecated_function_run', $function, $replacement, $version ); + do_action( 'deprecated_function_run', $function_name, $replacement, $version ); $log_error = false; @@ -521,28 +521,28 @@ protected function deprecated_dependency( $function, $version, $replacement = '' protected function register_payment_methods() { $this->container->register( Cheque::class, - function( Container $container ) { + function ( Container $container ) { $asset_api = $container->get( AssetApi::class ); return new Cheque( $asset_api ); } ); $this->container->register( PayPal::class, - function( Container $container ) { + function ( Container $container ) { $asset_api = $container->get( AssetApi::class ); return new PayPal( $asset_api ); } ); $this->container->register( BankTransfer::class, - function( Container $container ) { + function ( Container $container ) { $asset_api = $container->get( AssetApi::class ); return new BankTransfer( $asset_api ); } ); $this->container->register( CashOnDelivery::class, - function( Container $container ) { + function ( Container $container ) { $asset_api = $container->get( AssetApi::class ); return new CashOnDelivery( $asset_api ); } diff --git a/src/Domain/Package.php b/src/Domain/Package.php index 6958a6bec8d..19d13a8201b 100644 --- a/src/Domain/Package.php +++ b/src/Domain/Package.php @@ -79,7 +79,6 @@ public function get_version_stored_on_db() { */ public function set_version_stored_on_db() { update_option( Options::WC_BLOCK_VERSION, $this->get_version() ); - } /** diff --git a/src/Domain/Services/CreateAccount.php b/src/Domain/Services/CreateAccount.php index 6954dd3c784..b338d87cd76 100644 --- a/src/Domain/Services/CreateAccount.php +++ b/src/Domain/Services/CreateAccount.php @@ -38,7 +38,7 @@ function ( $wc_emails_instance ) { // Add custom "new account" handler. add_action( 'woocommerce_created_customer_notification', - function( $customer_id, $new_customer_data = array(), $password_generated = false ) use ( $wc_emails_instance ) { + function ( $customer_id, $new_customer_data = array(), $password_generated = false ) use ( $wc_emails_instance ) { // If this is a block-based signup, send a new email with password reset link (no password in email). if ( isset( $new_customer_data['source'] ) && 'store-api' === $new_customer_data['source'] ) { $this->customer_new_account( $customer_id, $new_customer_data ); diff --git a/src/Domain/Services/DraftOrders.php b/src/Domain/Services/DraftOrders.php index 1f0fc2d3b75..6df732100cc 100644 --- a/src/Domain/Services/DraftOrders.php +++ b/src/Domain/Services/DraftOrders.php @@ -168,13 +168,13 @@ public function delete_expired_draft_orders() { ] ); - // do we bail because the query results are unexpected? + // Do we bail because the query results are unexpected? try { - $this->assert_order_results( $orders, $batch_size ); + $this->assert_order_results( $orders ); if ( $orders ) { foreach ( $orders as $order ) { $order->delete( true ); - $count ++; + ++$count; } } if ( $batch_size === $count && function_exists( 'as_enqueue_async_action' ) ) { @@ -206,11 +206,10 @@ private function ensure_draft_status_registered() { * this service class executes. * * @param WC_Order[] $order_results The order results being asserted. - * @param int $expected_batch_size The expected batch size for the results. * @throws Exception If any assertions fail, an exception is thrown. */ - private function assert_order_results( $order_results, $expected_batch_size ) { - // if not an array, then just return because it won't get handled + private function assert_order_results( $order_results ) { + // If not an array, then just return because it won't get handled // anyways. if ( ! is_array( $order_results ) ) { return; @@ -218,17 +217,21 @@ private function assert_order_results( $order_results, $expected_batch_size ) { $suffix = ' This is an indicator that something is filtering WooCommerce or WordPress queries and modifying the query parameters.'; - // if count is greater than our expected batch size, then that's a problem. + // If count is greater than our expected batch size, then that's a problem. + // phpcs ignores are because the output is hardcoded and doesn't need to be escaped. if ( count( $order_results ) > 20 ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new Exception( 'There are an unexpected number of results returned from the query.' . $suffix ); } - // if any of the returned orders are not draft (or not a WC_Order), then that's a problem. + // If any of the returned orders are not draft (or not a WC_Order), then that's a problem. foreach ( $order_results as $order ) { if ( ! ( $order instanceof WC_Order ) ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new Exception( 'The returned results contain a value that is not a WC_Order.' . $suffix ); } if ( ! $order->has_status( self::STATUS ) ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new Exception( 'The results contain an order that is not a `wc-checkout-draft` status in the results.' . $suffix ); } } diff --git a/src/Domain/Services/FeatureGating.php b/src/Domain/Services/FeatureGating.php index 581e6aecd32..f2d2f9466b8 100644 --- a/src/Domain/Services/FeatureGating.php +++ b/src/Domain/Services/FeatureGating.php @@ -177,5 +177,4 @@ public function is_block_templates_controller_refactor_enabled() { } return false; } - } diff --git a/src/Domain/Services/GoogleAnalytics.php b/src/Domain/Services/GoogleAnalytics.php index 1123cd52016..55d2b19e4fb 100644 --- a/src/Domain/Services/GoogleAnalytics.php +++ b/src/Domain/Services/GoogleAnalytics.php @@ -106,7 +106,7 @@ private function get_google_analytics_settings() { * @param string $src Src of script. * @return string */ - public function async_script_loader_tags( $tag, $handle, $src ) { + public function async_script_loader_tags( $tag, $handle, $src ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed if ( ! in_array( $handle, array( 'google-tag-manager' ), true ) ) { return $tag; } diff --git a/src/Domain/Services/JetpackWooCommerceAnalytics.php b/src/Domain/Services/JetpackWooCommerceAnalytics.php index 0908813b64e..6211251acb3 100644 --- a/src/Domain/Services/JetpackWooCommerceAnalytics.php +++ b/src/Domain/Services/JetpackWooCommerceAnalytics.php @@ -121,7 +121,7 @@ public function output_order_received_page_view_properties( $order_id ) { $order = wc_get_order( $order_id ); $product_data = wp_json_encode( array_map( - function( $item ) { + function ( $item ) { $product = wc_get_product( $item->get_product_id() ); $product_details = $this->get_product_details( $product ); return array( @@ -377,7 +377,7 @@ public function track_local_pickup( $served, $result, $request ) { 'pickup_locations_enabled' => count( array_filter( $locations, - function( $location ) { + function ( $location ) { return $location['enabled']; } ) ), diff --git a/src/Domain/Services/Notices.php b/src/Domain/Services/Notices.php index 12090af3cf1..6a17c0fb375 100644 --- a/src/Domain/Services/Notices.php +++ b/src/Domain/Services/Notices.php @@ -47,7 +47,7 @@ public function init() { add_filter( 'wc_get_template', [ $this, 'get_notices_template' ], 10, 5 ); add_action( 'wp_head', - function() { + function () { // These pages may return notices in ajax responses, so we need the styles to be ready. if ( is_cart() || is_checkout() ) { wp_enqueue_style( 'wc-blocks-style' ); @@ -94,7 +94,7 @@ public function add_kses_notice_allowed_tags( $allowed_tags ) { * @param string $default_path Default path. * @return string */ - public function get_notices_template( $template, $template_name, $args, $template_path, $default_path ) { + public function get_notices_template( $template, $template_name, $args, $template_path, $default_path ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- Ignoring because those parameters passed by the filter. if ( in_array( $template_name, $this->notice_templates, true ) ) { $template = $this->package->get_path( 'templates/' . $template_name ); wp_enqueue_style( 'wc-blocks-style' ); diff --git a/src/Installer.php b/src/Installer.php index 60cc71b7a00..69687977dcf 100644 --- a/src/Installer.php +++ b/src/Installer.php @@ -116,7 +116,7 @@ protected function maybe_create_table( $table_name, $create_sql ) { protected function add_create_table_notice( $table_name ) { add_action( 'admin_notices', - function() use ( $table_name ) { + function () use ( $table_name ) { echo '

'; printf( /* translators: %1$s table name, %2$s database user, %3$s database name. */ diff --git a/src/Payments/PaymentMethodRegistry.php b/src/Payments/PaymentMethodRegistry.php index e0ea1ea0712..536752cf707 100644 --- a/src/Payments/PaymentMethodRegistry.php +++ b/src/Payments/PaymentMethodRegistry.php @@ -24,7 +24,7 @@ final class PaymentMethodRegistry extends IntegrationRegistry { public function get_all_active_registered() { return array_filter( $this->get_all_registered(), - function( $payment_method ) { + function ( $payment_method ) { return $payment_method->is_active(); } ); diff --git a/src/Shipping/ShippingController.php b/src/Shipping/ShippingController.php index d233d193926..dcac54e1f3d 100644 --- a/src/Shipping/ShippingController.php +++ b/src/Shipping/ShippingController.php @@ -54,7 +54,7 @@ public function init() { if ( is_admin() ) { $this->asset_data_registry->add( 'countryStates', - function() { + function () { return WC()->countries->get_states(); }, true @@ -438,7 +438,7 @@ public function filter_shipping_packages( $packages ) { // Check all packages for an instance of a collectable shipping method. $valid_packages = array_filter( $packages, - function( $package ) { + function ( $package ) { $shipping_method_ids = ArrayUtil::select( $package['rates'] ?? [], 'get_method_id', ArrayUtil::SELECT_BY_OBJECT_METHOD ); return ! empty( array_intersect( LocalPickupUtils::get_local_pickup_method_ids(), $shipping_method_ids ) ); } @@ -447,14 +447,14 @@ function( $package ) { // Remove pickup location from rates arrays. if ( count( $valid_packages ) !== count( $packages ) ) { $packages = array_map( - function( $package ) { + function ( $package ) { if ( ! is_array( $package['rates'] ) ) { $package['rates'] = []; return $package; } $package['rates'] = array_filter( $package['rates'], - function( $rate ) { + function ( $rate ) { return ! in_array( $rate->get_method_id(), LocalPickupUtils::get_local_pickup_method_ids(), true ); } ); diff --git a/src/StoreApi/Exceptions/InvalidCartException.php b/src/StoreApi/Exceptions/InvalidCartException.php index 490b658099a..9c23fbc57b5 100644 --- a/src/StoreApi/Exceptions/InvalidCartException.php +++ b/src/StoreApi/Exceptions/InvalidCartException.php @@ -70,5 +70,4 @@ public function getError() { public function getAdditionalData() { return $this->additional_data; } - } diff --git a/src/StoreApi/Exceptions/StockAvailabilityException.php b/src/StoreApi/Exceptions/StockAvailabilityException.php index 5069f260e8f..2998896b18f 100644 --- a/src/StoreApi/Exceptions/StockAvailabilityException.php +++ b/src/StoreApi/Exceptions/StockAvailabilityException.php @@ -68,5 +68,4 @@ public function getAdditionalData() { public function getProductName() { return $this->product_name; } - } diff --git a/src/StoreApi/Formatters.php b/src/StoreApi/Formatters.php index 2a03b78e3cd..457a40207d2 100644 --- a/src/StoreApi/Formatters.php +++ b/src/StoreApi/Formatters.php @@ -1,7 +1,7 @@ remove_arg_options( $property['properties'] ); } elseif ( isset( $property['items']['properties'] ) ) { @@ -294,7 +294,7 @@ public function get_endpoint_args_for_item_schema( $method = \WP_REST_Server::CR */ protected function force_schema_readonly( $properties ) { return array_map( - function( $property ) { + function ( $property ) { $property['readonly'] = true; if ( isset( $property['items']['properties'] ) ) { $property['items']['properties'] = $this->force_schema_readonly( $property['items']['properties'] ); diff --git a/src/StoreApi/Schemas/V1/CartShippingRateSchema.php b/src/StoreApi/Schemas/V1/CartShippingRateSchema.php index cc5a39211df..6b27a973010 100644 --- a/src/StoreApi/Schemas/V1/CartShippingRateSchema.php +++ b/src/StoreApi/Schemas/V1/CartShippingRateSchema.php @@ -341,7 +341,7 @@ protected function get_rate_meta_data( $rate ) { return array_reduce( array_keys( $meta_data ), - function( $return, $key ) use ( $meta_data ) { + function ( $return, $key ) use ( $meta_data ) { $return[] = [ 'key' => $key, 'value' => $meta_data[ $key ], diff --git a/src/StoreApi/Schemas/V1/CheckoutSchema.php b/src/StoreApi/Schemas/V1/CheckoutSchema.php index 3a84f9c0759..b1d67793bd3 100644 --- a/src/StoreApi/Schemas/V1/CheckoutSchema.php +++ b/src/StoreApi/Schemas/V1/CheckoutSchema.php @@ -220,7 +220,7 @@ protected function get_checkout_response( \WC_Order $order, PaymentResult $payme */ protected function prepare_payment_details_for_response( array $payment_details ) { return array_map( - function( $key, $value ) { + function ( $key, $value ) { return (object) [ 'key' => $key, 'value' => $value, diff --git a/src/StoreApi/Schemas/V1/ErrorSchema.php b/src/StoreApi/Schemas/V1/ErrorSchema.php index 564e9e3a308..4f534ad91fa 100644 --- a/src/StoreApi/Schemas/V1/ErrorSchema.php +++ b/src/StoreApi/Schemas/V1/ErrorSchema.php @@ -53,5 +53,4 @@ public function get_item_response( $error ) { 'message' => $this->prepare_html_response( $error->get_error_message() ), ]; } - } diff --git a/src/StoreApi/Schemas/V1/ImageAttachmentSchema.php b/src/StoreApi/Schemas/V1/ImageAttachmentSchema.php index 036c3823369..d8199b3be75 100644 --- a/src/StoreApi/Schemas/V1/ImageAttachmentSchema.php +++ b/src/StoreApi/Schemas/V1/ImageAttachmentSchema.php @@ -95,5 +95,4 @@ public function get_item_response( $attachment_id ) { 'alt' => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ), ]; } - } diff --git a/src/StoreApi/Schemas/V1/OrderSchema.php b/src/StoreApi/Schemas/V1/OrderSchema.php index f017488c77c..1fc98f5f9c6 100644 --- a/src/StoreApi/Schemas/V1/OrderSchema.php +++ b/src/StoreApi/Schemas/V1/OrderSchema.php @@ -347,7 +347,7 @@ protected function get_totals( $order ) { 'total_items' => $this->prepare_money_response( array_sum( array_map( - function( $item ) { + function ( $item ) { return $item->get_total(); }, array_values( $order->get_items( 'line_item' ) ) @@ -357,7 +357,7 @@ function( $item ) { 'total_items_tax' => $this->prepare_money_response( array_sum( array_map( - function( $item ) { + function ( $item ) { return $item->get_tax_total(); }, array_values( $order->get_items( 'tax' ) ) @@ -367,7 +367,7 @@ function( $item ) { 'total_fees_tax' => $this->prepare_money_response( array_sum( array_map( - function( $item ) { + function ( $item ) { return $item->get_total_tax(); }, array_values( $order->get_items( 'fee' ) ) @@ -377,7 +377,7 @@ function( $item ) { 'total_discount_tax' => $this->prepare_money_response( $order->get_discount_tax() ), 'total_shipping_tax' => $this->prepare_money_response( $order->get_shipping_tax() ), 'tax_lines' => array_map( - function( $item ) { + function ( $item ) { return [ 'name' => $item->get_name(), 'price' => $item->get_tax_total(), diff --git a/src/StoreApi/Schemas/V1/ProductSchema.php b/src/StoreApi/Schemas/V1/ProductSchema.php index 9d7935b9d7b..f4e41d5e3c2 100644 --- a/src/StoreApi/Schemas/V1/ProductSchema.php +++ b/src/StoreApi/Schemas/V1/ProductSchema.php @@ -578,7 +578,7 @@ protected function get_variations( \WC_Product $product ) { $attributes = array_filter( $product->get_attributes(), [ $this, 'filter_variation_attribute' ] ); $default_variation_meta_data = array_reduce( $attributes, - function( $defaults, $attribute ) use ( $product ) { + function ( $defaults, $attribute ) use ( $product ) { $meta_key = wc_variation_attribute_name( $attribute->get_name() ); $defaults[ $meta_key ] = [ 'name' => wc_attribute_label( $attribute->get_name(), $product ), @@ -627,7 +627,7 @@ function( $defaults, $attribute ) use ( $product ) { */ $attributes_by_variation = array_reduce( $variation_meta_data, - function( $values, $data ) use ( $default_variation_meta_keys ) { + function ( $values, $data ) use ( $default_variation_meta_keys ) { // The query above only includes the keys of $default_variation_meta_data so we know all of the attributes // being processed here apply to this product. However, we need an additional check here because the // cache may have been primed elsewhere and include keys from other products. diff --git a/src/StoreApi/StoreApi.php b/src/StoreApi/StoreApi.php index 7b740e37a2e..ed33e921247 100644 --- a/src/StoreApi/StoreApi.php +++ b/src/StoreApi/StoreApi.php @@ -22,7 +22,7 @@ final class StoreApi { public function init() { add_action( 'rest_api_init', - function() { + function () { self::container()->get( Legacy::class )->init(); self::container()->get( RoutesController::class )->register_all_routes(); } @@ -30,7 +30,7 @@ function() { // Runs on priority 11 after rest_api_default_filters() which is hooked at 10. add_action( 'rest_api_init', - function() { + function () { self::container()->get( Authentication::class )->init(); }, 11 diff --git a/src/StoreApi/Utilities/ArrayUtils.php b/src/StoreApi/Utilities/ArrayUtils.php index e1cc9e404fe..eb36e31d4b1 100644 --- a/src/StoreApi/Utilities/ArrayUtils.php +++ b/src/StoreApi/Utilities/ArrayUtils.php @@ -16,7 +16,7 @@ class ArrayUtils { public static function natural_language_join( $array, $enclose_items_with_quotes = false ) { if ( true === $enclose_items_with_quotes ) { $array = array_map( - function( $item ) { + function ( $item ) { return '"' . $item . '"'; }, $array diff --git a/src/StoreApi/Utilities/CartController.php b/src/StoreApi/Utilities/CartController.php index ec0cccde5a5..32004a57a9e 100644 --- a/src/StoreApi/Utilities/CartController.php +++ b/src/StoreApi/Utilities/CartController.php @@ -820,7 +820,7 @@ public function get_shipping_packages( $calculate_rates = true ) { // Add extra package data to array. if ( count( $packages ) ) { $packages = array_map( - function( $key, $package, $index ) { + function ( $key, $package, $index ) { $package['package_id'] = isset( $package['package_id'] ) ? $package['package_id'] : $key; $package['package_name'] = isset( $package['package_name'] ) ? $package['package_name'] : $this->get_package_name( $package, $index ); return $package; @@ -934,7 +934,7 @@ public function apply_coupon( $coupon_code ) { // Prevents new coupons being added if individual use coupons are already in the cart. $individual_use_coupons = $this->get_cart_coupons( - function( $code ) { + function ( $code ) { $coupon = new \WC_Coupon( $code ); return $coupon->get_individual_use(); } diff --git a/src/StoreApi/Utilities/LocalPickupUtils.php b/src/StoreApi/Utilities/LocalPickupUtils.php index 29cff3b2142..bbc7b293b63 100644 --- a/src/StoreApi/Utilities/LocalPickupUtils.php +++ b/src/StoreApi/Utilities/LocalPickupUtils.php @@ -24,7 +24,7 @@ public static function is_local_pickup_enabled() { public static function get_local_pickup_method_ids() { $all_methods_supporting_local_pickup = array_reduce( WC()->shipping()->get_shipping_methods(), - function( $methods, $method ) { + function ( $methods, $method ) { if ( $method->supports( 'local-pickup' ) ) { $methods[] = $method->id; } diff --git a/src/StoreApi/Utilities/OrderAuthorizationTrait.php b/src/StoreApi/Utilities/OrderAuthorizationTrait.php index 0c5c3d0c632..a9b8442c6ed 100644 --- a/src/StoreApi/Utilities/OrderAuthorizationTrait.php +++ b/src/StoreApi/Utilities/OrderAuthorizationTrait.php @@ -58,5 +58,4 @@ public function validate_billing_email_matches_order( $order_id, $billing_email throw new RouteException( 'woocommerce_rest_invalid_billing_email', __( 'Invalid billing email provided.', 'woo-gutenberg-products-block' ), 401 ); } } - } diff --git a/src/StoreApi/Utilities/OrderController.php b/src/StoreApi/Utilities/OrderController.php index 223f7bdd7eb..dc3a38c0f85 100644 --- a/src/StoreApi/Utilities/OrderController.php +++ b/src/StoreApi/Utilities/OrderController.php @@ -1,7 +1,7 @@ customer ) ) { @@ -134,7 +134,7 @@ public function sync_customer_data_with_order( \WC_Order $order ) { ); $customer->save(); - }; + } } /** @@ -181,7 +181,7 @@ protected function validate_coupons( \WC_Order $order ) { try { array_walk( $validators, - function( $validator, $index, $params ) { + function ( $validator, $index, $params ) { call_user_func_array( [ $this, $validator ], $params ); }, [ $coupon, $order ] diff --git a/src/Templates/AbstractTemplateCompatibility.php b/src/Templates/AbstractTemplateCompatibility.php index ee5c4f45384..4be6da10d7a 100644 --- a/src/Templates/AbstractTemplateCompatibility.php +++ b/src/Templates/AbstractTemplateCompatibility.php @@ -29,7 +29,7 @@ public function init() { add_filter( 'render_block_data', - function( $parsed_block, $source_block, $parent_block ) { + function ( $parsed_block, $source_block, $parent_block ) { /** * Filter to disable the compatibility layer for the blockified templates. * @@ -45,7 +45,6 @@ function( $parsed_block, $source_block, $parent_block ) { } return $this->update_render_block_data( $parsed_block, $source_block, $parent_block ); - }, 10, 3 diff --git a/src/Templates/ArchiveProductTemplatesCompatibility.php b/src/Templates/ArchiveProductTemplatesCompatibility.php index cfbd2c447a1..412bdfbdfa2 100644 --- a/src/Templates/ArchiveProductTemplatesCompatibility.php +++ b/src/Templates/ArchiveProductTemplatesCompatibility.php @@ -78,7 +78,7 @@ public function inject_hooks( $block_content, $block ) { $block_hooks = array_filter( $this->hook_data, - function( $hook ) use ( $block_name ) { + function ( $hook ) use ( $block_name ) { return in_array( $block_name, $hook['block_names'], true ); } ); @@ -100,7 +100,7 @@ function( $hook ) use ( $block_name ) { $supported_blocks = array_merge( [], ...array_map( - function( $hook ) { + function ( $hook ) { return $hook['block_names']; }, array_values( $this->hook_data ) diff --git a/src/Templates/CheckoutHeaderTemplate.php b/src/Templates/CheckoutHeaderTemplate.php index daefdac72d5..4bfc35516c9 100644 --- a/src/Templates/CheckoutHeaderTemplate.php +++ b/src/Templates/CheckoutHeaderTemplate.php @@ -9,5 +9,4 @@ class CheckoutHeaderTemplate { const SLUG = 'checkout-header'; - } diff --git a/src/Templates/MiniCartTemplate.php b/src/Templates/MiniCartTemplate.php index 8f49b7643c7..5dc3ecce6b2 100644 --- a/src/Templates/MiniCartTemplate.php +++ b/src/Templates/MiniCartTemplate.php @@ -9,5 +9,4 @@ class MiniCartTemplate { const SLUG = 'mini-cart'; - } diff --git a/src/Templates/SingleProductTemplate.php b/src/Templates/SingleProductTemplate.php index a03d0d29783..422e58e6995 100644 --- a/src/Templates/SingleProductTemplate.php +++ b/src/Templates/SingleProductTemplate.php @@ -21,7 +21,7 @@ private static function replace_first_single_product_template_block_with_passwor $single_product_template_blocks = array( 'woocommerce/product-image-gallery', 'woocommerce/product-details', 'woocommerce/add-to-cart-form', 'woocommerce/product-meta', 'woocommerce/product-rating', 'woocommerce/product-price', 'woocommerce/related-products' ); return array_reduce( $parsed_blocks, - function( $carry, $block ) use ( $single_product_template_blocks ) { + function ( $carry, $block ) use ( $single_product_template_blocks ) { if ( in_array( $block['blockName'], $single_product_template_blocks, true ) ) { if ( $carry['is_already_replaced'] ) { return array( diff --git a/src/Templates/SingleProductTemplateCompatibility.php b/src/Templates/SingleProductTemplateCompatibility.php index 56e92808cd7..c0ea67f2a57 100644 --- a/src/Templates/SingleProductTemplateCompatibility.php +++ b/src/Templates/SingleProductTemplateCompatibility.php @@ -31,7 +31,7 @@ public function inject_hooks( $block_content, $block ) { $block_hooks = array_filter( $this->hook_data, - function( $hook ) use ( $block_name ) { + function ( $hook ) use ( $block_name ) { return in_array( $block_name, $hook['block_names'], true ); } ); @@ -283,7 +283,7 @@ private static function wrap_single_product_template( $template_content ) { $grouped_blocks = self::group_blocks( $parsed_blocks ); $wrapped_blocks = array_map( - function( $blocks ) { + function ( $blocks ) { if ( 'core/template-part' === $blocks[0]['blockName'] ) { return $blocks; } @@ -310,7 +310,7 @@ function( $blocks ) { private static function inject_custom_attributes_to_first_and_last_block_single_product_template( $wrapped_blocks ) { $template_with_custom_attributes = array_reduce( $wrapped_blocks, - function( $carry, $item ) { + function ( $carry, $item ) { $index = $carry['index']; $carry['index'] = $carry['index'] + 1; @@ -383,7 +383,6 @@ private static function create_wrap_block_group( $blocks ) { $new_block['innerBlocks'] = $blocks; return $new_block; - } /** @@ -425,7 +424,7 @@ private static function has_single_product_template_blocks( $parsed_blocks ) { private static function group_blocks( $parsed_blocks ) { return array_reduce( $parsed_blocks, - function( $carry, $block ) { + function ( $carry, $block ) { if ( 'core/template-part' === $block['blockName'] ) { $carry[] = array( $block ); return $carry; @@ -484,7 +483,7 @@ private static function is_custom_html( $block ) { private static function serialize_blocks( $parsed_blocks ) { return array_reduce( $parsed_blocks, - function( $carry, $item ) { + function ( $carry, $item ) { if ( is_array( $item ) ) { return $carry . serialize_blocks( $item ); } diff --git a/src/Utils/BlockTemplateUtils.php b/src/Utils/BlockTemplateUtils.php index af08452c935..1db40457c8f 100644 --- a/src/Utils/BlockTemplateUtils.php +++ b/src/Utils/BlockTemplateUtils.php @@ -426,7 +426,7 @@ public static function get_theme_template_path( $template_slug, $template_type = // or the stylesheet directory for child themes. $possible_paths = array_reduce( $possible_templates_dir, - function( $carry, $item ) use ( $template_filename ) { + function ( $carry, $item ) use ( $template_filename ) { $filepath = DIRECTORY_SEPARATOR . $item . DIRECTORY_SEPARATOR . $template_filename; $carry[] = get_stylesheet_directory() . $filepath; @@ -502,7 +502,6 @@ public static function get_block_template( $id, $template_type ) { } return null; - } /** @@ -632,7 +631,7 @@ public static function filter_block_templates_by_feature_flag( $block_templates return array_filter( $block_templates, - function( $block_template ) use ( $flag, $block_templates_with_feature_gate ) { + function ( $block_template ) use ( $flag, $block_templates_with_feature_gate ) { if ( isset( $block_templates_with_feature_gate[ $block_template->slug ] ) ) { return $block_templates_with_feature_gate[ $block_template->slug ] <= $flag; } @@ -652,13 +651,13 @@ public static function remove_theme_templates_with_custom_alternative( $template // Get the slugs of all templates that have been customised and saved in the database. $customised_template_slugs = array_map( - function( $template ) { + function ( $template ) { return $template->slug; }, array_values( array_filter( $templates, - function( $template ) { + function ( $template ) { // This template has been customised and saved as a post. return 'custom' === $template->source; } @@ -673,7 +672,7 @@ function( $template ) { return array_values( array_filter( $templates, - function( $template ) use ( $customised_template_slugs ) { + function ( $template ) use ( $customised_template_slugs ) { // This template has been customised and saved as a post, so return it. return ! ( 'theme' === $template->source && in_array( $template->slug, $customised_template_slugs, true ) ); } @@ -754,7 +753,7 @@ public static function get_block_templates_from_db( $slugs = array(), $template_ $saved_woo_templates = $check_query->posts; return array_map( - function( $saved_woo_template ) { + function ( $saved_woo_template ) { return self::build_template_result_from_post( $saved_woo_template ); }, $saved_woo_templates diff --git a/src/Utils/CartCheckoutUtils.php b/src/Utils/CartCheckoutUtils.php index e1d74d2c65e..0e4220a8756 100644 --- a/src/Utils/CartCheckoutUtils.php +++ b/src/Utils/CartCheckoutUtils.php @@ -94,7 +94,7 @@ protected static function deep_sort_with_accents( $array ) { } $array_without_accents = array_map( - function( $value ) { + function ( $value ) { return is_array( $value ) ? self::deep_sort_with_accents( $value ) : remove_accents( wc_strtolower( html_entity_decode( $value ) ) ); diff --git a/src/Utils/StyleAttributesUtils.php b/src/Utils/StyleAttributesUtils.php index 5205dcc3691..119bb06442d 100644 --- a/src/Utils/StyleAttributesUtils.php +++ b/src/Utils/StyleAttributesUtils.php @@ -738,14 +738,14 @@ public static function get_classes_and_styles_by_attributes( $attributes, $prope $classes_and_styles = array_filter( $classes_and_styles ); $classes = array_map( - function( $item ) { + function ( $item ) { return $item['class']; }, $classes_and_styles ); $styles = array_map( - function( $item ) { + function ( $item ) { return $item['style']; }, // Exclude link color styles from parent to avoid conflict with text color.