Skip to content

Commit

Permalink
Fix some PHPStan warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Oct 5, 2023
1 parent fd4ac90 commit 51ae265
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
10 changes: 3 additions & 7 deletions src/Core/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,9 @@ public function redirect_via_html( Payment $payment ) {
* @return void
* @throws \Exception When payment action URL is empty.
*/
private function output_form( Payment $payment ) {
$action_url = $payment->get_action_url();

if ( empty( $action_url ) ) {
throw new \Exception( 'Action URL is empty, can not get form HTML.' );
}

public function output_form( // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- Parameter is used in include.
Payment $payment
) {
include __DIR__ . '/../../views/form.php';
}

Expand Down
5 changes: 1 addition & 4 deletions views/exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
* @copyright 2005-2023 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
* @var \Exception $exception Exception.
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! isset( $exception ) ) {
return;
}

?>

<div class="error">
Expand Down
10 changes: 10 additions & 0 deletions views/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @copyright 2005-2023 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
* @var \Pronamic\WordPress\Pay\Payments\Payment $payment Payment.
* @var \Pronamic\WordPress\Pay\Core\Gateway $this Gateway.
*/

use Pronamic\WordPress\Html\Element;
Expand All @@ -15,6 +17,14 @@
exit;
}

$action_url = $payment->get_action_url();

if ( empty( $action_url ) ) {
esc_html_e( 'It is currently not possible to pay, please contact us for more information (error: no action URL found).', 'pronamic_ideal' );

return;
}

?>
<form id="pronamic_ideal_form" name="pronamic_ideal_form" method="post" action="<?php echo esc_url( $action_url ); ?>">
<?php
Expand Down
8 changes: 3 additions & 5 deletions views/redirect-via-html.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
* @copyright 2005-2023 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
* @var \Pronamic\WordPress\Pay\Payments\Payment $payment Payment.
* @var \Pronamic\WordPress\Pay\Core\Gateway $this Gateway.
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! isset( $payment ) ) {
return;
}

?>
<!DOCTYPE html>

Expand Down Expand Up @@ -81,7 +79,7 @@
<?php endif; ?>

<dt><?php esc_html_e( 'Description', 'pronamic_ideal' ); ?></dt>
<dd><?php echo esc_html( $payment->get_description() ); ?></dd>
<dd><?php echo esc_html( (string) $payment->get_description() ); ?></dd>

<dt><?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?></dt>
<dd><?php echo esc_html( $payment->get_total_amount()->format_i18n() ); ?></dd>
Expand Down

0 comments on commit 51ae265

Please sign in to comment.