Skip to content

Commit

Permalink
Revert PHP types for module hooks (#1314)
Browse files Browse the repository at this point in the history
Enabling too strict type checks can create regressions with hooks
that are not well documented.

Revert the type checks for hook callbacks that could be risky.
  • Loading branch information
herrvigg committed Apr 15, 2023
1 parent ec32863 commit 9f81d5b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/modules/google-site-kit/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Built-in module for Google Site Kit
*/

add_filter( 'googlesitekit_canonical_home_url', function ( string $url ): string {
add_filter( 'googlesitekit_canonical_home_url', function ( $url ) {
// bypass qtranxf_home_url and provide a fixed home URL to avoid disconnections
return get_option( 'home' );
} );
12 changes: 6 additions & 6 deletions src/modules/gravity-forms/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct() {
add_filter( "gform_pre_send_email", array( $this, "gform_pre_send_email" ) );
}

public function gform_pre_render( array $form ): array {
public function gform_pre_render( $form ) {
if ( ! $this->isEnabled() ) {
return $form;
}
Expand Down Expand Up @@ -92,34 +92,34 @@ public function gform_pre_render( array $form ): array {
return $form;
}

public function gform_form_action_attribute( array $matches ): string {
public function gform_form_action_attribute( $matches ) {
global $q_config;

return 'action="' . $this->convertURL( $matches[1], $q_config['language'] ) . '"';
}

public function gform_form_tag( string $tag ): string {
public function gform_form_tag( $tag ): string {
if ( ! $this->isEnabled() ) {
return $tag;
}
return preg_replace_callback( "|action='([^']+)'|", array( &$this, 'gform_form_action_attribute' ), $tag );
}

public function gform_savecontinue_link( string $save_button, array $form ) {
public function gform_savecontinue_link( $save_button, $form ) {
if ( ! $this->isEnabled() ) {
return $save_button;
}
return $this->translate( $save_button );
}

public function gform_confirmation( $confirmation, $form, $lead, bool $ajax ) {
public function gform_confirmation( $confirmation, $form, $lead, $ajax ) {
if ( ! $this->isEnabled() ) {
return $confirmation;
}
return $this->translate( $confirmation );
}

public function gform_pre_send_email( array $email ): array {
public function gform_pre_send_email( $email ) {
if ( ! $this->isEnabled() ) {
return $email;
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/woo-commerce/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function qtranxf_wc_add_admin_page_config( array $page_configs ): array {
return $page_configs;
}

function qtranxf_wc_email_get_option( $value_translated, WC_Email $wce, $value = null, $key = null, $empty_value = null ) {
function qtranxf_wc_email_get_option( $value_translated, $wc_email, $value = null, $key = null, $empty_value = null ) {
if ( ! $value ) {
return $value_translated; // so that older WC versions do not get nasty output
}
Expand All @@ -261,7 +261,7 @@ function qtranxf_wc_email_get_option( $value_translated, WC_Email $wce, $value =
*
* @return string
*/
function qtranxf_wc_admin_url_append_language( string $url ): string {
function qtranxf_wc_admin_url_append_language( $url ) {
if ( strpos( $url, 'action=woocommerce_mark_order_status' ) ) {
$components = parse_url( $url );
$params = array();
Expand Down Expand Up @@ -289,7 +289,7 @@ function qtranxf_wc_admin_url_append_language( string $url ): string {
*
* @return string
*/
function qtranxf_wc_admin_url_append_language_edit_page( string $url ): string {
function qtranxf_wc_admin_url_append_language_edit_page( $url ) {
if ( strpos( $url, 'admin-ajax.php' ) === false || ! isset( $_GET['action'] ) || ! isset( $_GET['post'] ) || $_GET['action'] != 'edit' ) {
return $url;
}
Expand Down
14 changes: 7 additions & 7 deletions src/modules/woo-commerce/front.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function qtranxf_wc_filter_postmeta( $original_value, int $object_id, string $me
* @see wc_dropdown_variation_attribute_options (single-product/add-to-cart/variable.php)
*
*/
function qtranxf_wc_dropdown_variation_attribute_options_args( array $args ): array {
function qtranxf_wc_dropdown_variation_attribute_options_args( $args ) {
if ( isset( $args['options'] ) ) {
$args['options'] = qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage( $args['options'] );
}
Expand All @@ -86,7 +86,7 @@ function qtranxf_wc_save_post_meta( $order_id ) {
add_post_meta( $order_id, '_user_language', $q_config['language'], true );
}

function qtranxf_wc_paypal_args( array $args ): array {
function qtranxf_wc_paypal_args( $args ) {
$args['lc'] = get_locale();

return $args;
Expand All @@ -104,7 +104,7 @@ function qtranxf_wc_paypal_args( array $args ): array {
*
* @return string cart hash with language information
*/
function qtranxf_wc_get_cart_hash( array $cart ): string {
function qtranxf_wc_get_cart_hash( $cart ): string {
$lang = qtranxf_getLanguage();

return md5( json_encode( $cart ) . $lang );
Expand All @@ -116,7 +116,7 @@ function qtranxf_wc_get_cart_hash( array $cart ): string {
*
* @param array $cart wc variable holding contents of the cart without language information.
*/
function qtranxf_wc_set_cookies_cart_hash( array $cart ): void {
function qtranxf_wc_set_cookies_cart_hash( $cart ): void {
$hash = qtranxf_wc_get_cart_hash( $cart );
wc_setcookie( 'woocommerce_cart_hash', $hash );
}
Expand All @@ -127,7 +127,7 @@ function qtranxf_wc_set_cookies_cart_hash( array $cart ): void {
*
* @param WC_Cart $wc_cart wc object without language information.
*/
function qtranxf_wc_cart_loaded_from_session( WC_Cart $wc_cart ): void {
function qtranxf_wc_cart_loaded_from_session( $wc_cart ): void {
if ( headers_sent() ) {
return;
}
Expand All @@ -143,7 +143,7 @@ function qtranxf_wc_cart_loaded_from_session( WC_Cart $wc_cart ): void {
*
* @param bool $set is true if cookies need to be set, otherwse they are unset in calling function.
*/
function qtranxf_wc_set_cart_cookies( bool $set ): void {
function qtranxf_wc_set_cart_cookies( $set ): void {
if ( $set ) {
$wc = WC();
$wc_cart = $wc->cart;
Expand All @@ -163,7 +163,7 @@ function qtranxf_wc_set_cart_cookies( bool $set ): void {
*
* @return string cart hash with language information
*/
function qtranxf_wc_cart_hash( string $hash, array $cart ): string {
function qtranxf_wc_cart_hash( $hash, $cart ) {
$new_hash = qtranxf_wc_get_cart_hash( $cart );
if ( ! headers_sent() ) {
wc_setcookie( 'woocommerce_cart_hash', $new_hash );
Expand Down

0 comments on commit 9f81d5b

Please sign in to comment.