Skip to content

Commit

Permalink
Fix PHPStan issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Sep 27, 2024
1 parent 3cb6d8e commit 83d425c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/Admin/AdminSubscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ private function get_subscriptions_map( $table ) {
continue;
}

$memberpress_subscription_id = (string) \get_post_meta( $subscription_post->ID, '_pronamic_subscription_source_id', true );
$memberpress_subscription_id = \get_post_meta( $subscription_post->ID, '_pronamic_subscription_source_id', true );

if ( ! is_string( $memberpress_subscription_id ) ) {
continue;
}

$this->subscriptions_map[ $memberpress_subscription_id ] = $subscription_post;
}
Expand Down
6 changes: 5 additions & 1 deletion src/Admin/AdminTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ function ( $post ) {
);

foreach ( $payment_posts as $payment_post ) {
$memberpress_transaction_id = (string) \get_post_meta( $payment_post->ID, '_pronamic_payment_source_id', true );
$memberpress_transaction_id = \get_post_meta( $payment_post->ID, '_pronamic_payment_source_id', true );

if ( ! is_string( $memberpress_transaction_id ) ) {
continue;
}

$this->payments_map[ $memberpress_transaction_id ] = $payment_post;
}
Expand Down
8 changes: 7 additions & 1 deletion src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,19 @@ public function subscription_email_params( $params, MeprSubscription $memberpres
// Add parameters.
$next_payment_date = $subscription->get_next_payment_date();

$date_format = \get_option( 'date_format' );

if ( ! is_string( $date_format ) ) {
$date_format = 'D j M Y';
}

return \array_merge(
$params,
[
'pronamic_subscription_id' => (string) $subscription->get_id(),
'pronamic_subscription_cancel_url' => $subscription->get_cancel_url(),
'pronamic_subscription_renewal_url' => $subscription->get_renewal_url(),
'pronamic_subscription_renewal_date' => null === $next_payment_date ? '' : \date_i18n( \get_option( 'date_format' ), $next_payment_date->getTimestamp() ),
'pronamic_subscription_renewal_date' => null === $next_payment_date ? '' : \date_i18n( $date_format, $next_payment_date->getTimestamp() ),
]
);
}
Expand Down
13 changes: 9 additions & 4 deletions src/Upgrade310.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,14 @@ private function upgrade_subscriptions( $args = [] ) {
\update_post_meta( $subscription_post_id, '_pronamic_subscription_memberpress_update_source_id', $subscription_source_id );

/**
* MemberPress transaction.
* MemberPress subscription.
*/
if ( ! is_string( $subscription_source_id ) ) {
continue;
}

$memberpress_subscription_id = $subscription_source_id;

/**
* MemberPress subscription.
*/
$memberpress_subscription = MemberPress::get_subscription_by_id( $memberpress_subscription_id );

if ( ! $memberpress_subscription ) {
Expand Down Expand Up @@ -320,6 +321,10 @@ private function upgrade_payments() {
/**
* MemberPress transaction.
*/
if ( ! is_string( $payment_source_id ) ) {
continue;
}

$memberpress_transaction_id = $payment_source_id;

$memberpress_transaction = MemberPress::get_transaction_by_id( $memberpress_transaction_id );
Expand Down
10 changes: 8 additions & 2 deletions views/subscription-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ function ( $post ) {
echo '<li>';

// Status.
$status_label = __( 'Unknown status', 'pronamic_ideal' );

$post_status = get_post_status( $subscription_id );

if ( 'trash' === $post_status ) {
$post_status = get_post_meta( $subscription_id, '_wp_trash_meta_status', true );
}

$status_object = get_post_status_object( $post_status );
if ( is_string( $post_status ) ) {
$status_object = get_post_status_object($post_status);

Check failure on line 78 in views/subscription-form.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Expected 1 spaces after opening parenthesis; 0 found

Check failure on line 78 in views/subscription-form.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Expected 1 spaces before closing parenthesis; 0 found

$status_label = isset( $status_object, $status_object->label ) ? $status_object->label : __( 'Unknown status', 'pronamic_ideal' );
if ( null !== $status_object && isset( $status_object->label ) ) {
$status_label = $status_object->label;
}
}

// Next payment date.
$next_payment = __( 'No payment scheduled', 'pronamic_ideal' );
Expand Down
10 changes: 8 additions & 2 deletions views/transaction-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ function ( $post ) {
echo '<li>';

// Status.
$status_label = __( 'Unknown status', 'pronamic_ideal' );

$post_status = get_post_status( $payment_id );

if ( 'trash' === $post_status ) {
$post_status = get_post_meta( $payment_id, '_wp_trash_meta_status', true );
}

$status_object = get_post_status_object( $post_status );
if ( is_string( $post_status ) ) {
$status_object = get_post_status_object( $post_status );

$status_label = isset( $status_object, $status_object->label ) ? $status_object->label : __( 'Unknown status', 'pronamic_ideal' );
if ( null !== $status_object && isset( $status_object->label ) ) {
$status_label = $status_object->label;
}
}

\printf(
'<a href="%s">%s</a> — %s',
Expand Down

0 comments on commit 83d425c

Please sign in to comment.