Skip to content

Commit

Permalink
Use short array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Oct 7, 2024
1 parent 3c5ce82 commit c748c6f
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/Admin/AssetsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function enqueue_assets( string $page_slug, string $script_handle, str
}

if ( \file_exists( $path . 'assets/admin/' . $script_handle . '.css' ) ) {
\wp_enqueue_style( 'gtmkit-' . $script_handle . '-style', $url . 'assets/admin/' . $script_handle . '.css', array( 'wp-components' ), $version );
\wp_enqueue_style( 'gtmkit-' . $script_handle . '-style', $url . 'assets/admin/' . $script_handle . '.css', [ 'wp-components' ], $version );
}

\wp_enqueue_script( 'gtmkit-' . $script_handle . '-script', $url . 'assets/admin/' . $script_handle . '.js', $dependency, $version, true );
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function enqueue_assets( string $hook ): void {
$version = $deps_file['version'];
}

wp_enqueue_style( 'gtmkit-wizard-style', GTMKIT_URL . 'assets/admin/wizard.css', array( 'wp-components' ), $version );
wp_enqueue_style( 'gtmkit-wizard-style', GTMKIT_URL . 'assets/admin/wizard.css', [ 'wp-components' ], $version );

wp_enqueue_script( 'gtmkit-wizard-script', GTMKIT_URL . 'assets/admin/wizard.js', $dependency, $version, true );

Expand Down
12 changes: 6 additions & 6 deletions src/Frontend/Stape.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public function add_cookie_keeper() {
}

$this->set_cookie(
array(
[
'name' => self::COOKIE_KEEPER_NAME,
'value' => md5( wp_rand( PHP_INT_MIN, PHP_INT_MAX ) . '|' . filter_input( INPUT_SERVER, 'HTTP_USER_AGENT', FILTER_SANITIZE_SPECIAL_CHARS ) . '|' . time() ),
'expires' => time() + ( YEAR_IN_SECONDS * 2 ),
)
]
);
}

Expand All @@ -82,11 +82,11 @@ public function add_cookie_keeper() {
*/
private function delete_cookie(): void {
$this->set_cookie(
array(
[
'name' => self::COOKIE_KEEPER_NAME,
'value' => '',
'expires' => -1,
)
]
);
unset( $_COOKIE[ self::COOKIE_KEEPER_NAME ] );
}
Expand All @@ -100,7 +100,7 @@ private function delete_cookie(): void {
private function set_cookie( array $args ): void {
$args = wp_parse_args(
$args,
array(
[
'name' => '',
'value' => '',
'expires' => 0,
Expand All @@ -109,7 +109,7 @@ private function set_cookie( array $args ): void {
'secure' => true,
'httponly' => false,
'samesite' => 'lax',
)
]
);

setcookie(
Expand Down
2 changes: 1 addition & 1 deletion src/Installation/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function v2_upgrade(): void {
* Upgrade routine for v2.2
*/
protected function v22_upgrade(): void {
$auto_update_plugins = (array) get_site_option( 'auto_update_plugins', array() );
$auto_update_plugins = (array) get_site_option( 'auto_update_plugins', [] );

$automatic_updates = in_array( 'gtm-kit/gtm-kit.php', $auto_update_plugins, true );

Expand Down
4 changes: 2 additions & 2 deletions src/Integration/AbstractEcommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ public function get_primary_product_category( int $product_id, string $taxonomy
$product_categories = wp_get_post_terms(
$product_id,
$taxonomy,
array(
[
'orderby' => 'parent',
'order' => 'ASC',
)
]
);

if ( count( $product_categories ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/Integration/EasyDigitalDownloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function get_global_data( array $global_data ): array {
*/
public function get_datalayer_content( array $data_layer ): array {

if ( is_singular( array( 'download' ) ) ) {
if ( is_singular( [ 'download' ] ) ) {
$data_layer = $this->get_datalayer_content_product_page( $data_layer );
} elseif ( is_tax( 'download_category' ) ) {
$data_layer = $this->get_datalayer_content_product_category( $data_layer );
Expand Down
38 changes: 19 additions & 19 deletions src/Integration/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public function get_purchase_event( WC_Order $order, array $data_layer = [] ): a

if ( $this->options->get( 'general', 'debug_log' ) ) {
$logger = wc_get_logger();
$logger->info( wc_print_r( $data_layer, true ), array( 'source' => 'gtmkit-purchase' ) );
$logger->info( wc_print_r( $data_layer, true ), [ 'source' => 'gtmkit-purchase' ] );
}

return $data_layer;
Expand Down Expand Up @@ -1069,23 +1069,23 @@ public function extend_store(): void {

// Register into `cart/items`.
$this->extend->register_endpoint_data(
array(
[
'endpoint' => ProductSchema::IDENTIFIER,
'namespace' => 'gtmkit',
'data_callback' => array( self::$instance, 'extend_product_data' ),
'schema_callback' => array( self::$instance, 'extend_product_schema' ),
'data_callback' => [ self::$instance, 'extend_product_data' ],
'schema_callback' => [ self::$instance, 'extend_product_schema' ],
'schema_type' => ARRAY_A,
)
]
);

$this->extend->register_endpoint_data(
array(
[
'endpoint' => CartItemSchema::IDENTIFIER,
'namespace' => 'gtmkit',
'data_callback' => array( self::$instance, 'extend_cart_data' ),
'schema_callback' => array( self::$instance, 'extend_product_schema' ),
'data_callback' => [ self::$instance, 'extend_cart_data' ],
'schema_callback' => [ self::$instance, 'extend_product_schema' ],
'schema_type' => ARRAY_A,
)
]
);
}

Expand All @@ -1097,9 +1097,9 @@ public function extend_store(): void {
* @return array<string, mixed> $product Registered data or empty array if condition is not satisfied.
*/
public function extend_product_data( $product ): array {
return array(
return [
'item' => $this->get_item_data( $product ),
);
];
}

/**
Expand All @@ -1110,9 +1110,9 @@ public function extend_product_data( $product ): array {
* @return array<string, mixed> $product Registered data or empty array if condition is not satisfied.
*/
public function extend_cart_data( array $cart_item ): array {
return array(
return [
'item' => wp_json_encode( $this->get_item_data( $cart_item['data'] ) ),
);
];
}

/**
Expand All @@ -1122,13 +1122,13 @@ public function extend_cart_data( array $cart_item ): array {
*/
public function extend_product_schema(): array {

return array(
'gtmkit_data' => array(
return [
'gtmkit_data' => [
'description' => __( 'GTM Kit data.', 'gtm-kit' ),
'type' => array( 'string', 'null' ),
'type' => [ 'string', 'null' ],
'readonly' => true,
),
);
],
];
}

/**
Expand All @@ -1141,7 +1141,7 @@ public function extend_product_schema(): array {
public function has_woocommerce_blocks( int $post_id ): array {
$post_content = get_the_content( null, false, $post_id );

$woocommerce_blocks = array();
$woocommerce_blocks = [];

// This will return an array of blocks.
$blocks = parse_blocks( $post_content );
Expand Down
8 changes: 4 additions & 4 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ final class Options {
],
'misc' => [
'auto_update' => [
'default' => false,
'default' => true,
'type' => 'boolean',
],
],
Expand Down Expand Up @@ -364,16 +364,16 @@ public static function array_merge_recursive(): array {
$arrays = func_get_args();

if ( count( $arrays ) < 2 ) {
return $arrays[0] ?? array();
return $arrays[0] ?? [];
}

$merged = array();
$merged = [];

while ( $arrays ) {
$array = array_shift( $arrays );

if ( ! is_array( $array ) ) {
return array();
return [];
}

if ( empty( $array ) ) {
Expand Down

0 comments on commit c748c6f

Please sign in to comment.