Skip to content

Commit

Permalink
fix psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mattallan committed Apr 11, 2024
1 parent 249df0a commit 512f612
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 3 additions & 5 deletions includes/class-wc-payments-payment-request-button-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public function get_shipping_options( $shipping_address, $itemized_display_items
$data = [];

// Remember current shipping method before resetting.
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', [] );
$this->calculate_shipping( apply_filters( 'wcpay_payment_request_shipping_posted_values', $shipping_address ) );

$packages = WC()->shipping->get_packages();
Expand Down Expand Up @@ -1523,16 +1523,14 @@ private function get_taxes_like_cart( $product, $price ) {
*
* This function needs to be called after `WC()->cart->calculate_totals()` is run, otherwise `WC()->cart->recurring_carts` won't exist yet.
*
* @since 8.3.0
*
* @param array $previous_chosen_methods The previously chosen shipping methods.
*/
private function maybe_restore_recurring_chosen_shipping_methods( $previous_chosen_methods ) {
private function maybe_restore_recurring_chosen_shipping_methods( $previous_chosen_methods = [] ) {
if ( empty( WC()->cart->recurring_carts ) || ! method_exists( 'WC_Subscriptions_Cart', 'get_recurring_shipping_package_key' ) ) {
return;
}

$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', [] );

foreach ( WC()->cart->recurring_carts as $recurring_cart_key => $recurring_cart ) {
foreach ( $recurring_cart->get_shipping_packages() as $recurring_cart_package_index => $recurring_cart_package ) {
Expand Down
4 changes: 1 addition & 3 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
</UndefinedClass>
</file>
<file src="includes/class-wc-payments-payment-request-button-handler.php">
<UndefinedClass occurrences="4">
<UndefinedClass occurrences="5">
<code>WC_Pre_Orders_Product</code>
<code>WC_Subscriptions_Product</code>
<code>WC_Subscriptions_Product</code>
<code>WC_Subscriptions_Cart</code>
<code>WC_Subscriptions_Cart</code>
</UndefinedClass>
</file>
Expand Down

0 comments on commit 512f612

Please sign in to comment.