Skip to content

Commit

Permalink
Fix PHPStan.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Nov 27, 2023
1 parent 68e004a commit 5a27266
Show file tree
Hide file tree
Showing 22 changed files with 456 additions and 474 deletions.
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
includes:
- vendor-bin/phpstan/vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
checkMissingIterableValueType: false
customRulesetUsed: false
level: max
bootstrapFiles:
Expand Down
5 changes: 5 additions & 0 deletions src/AbstractIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use Pronamic\WordPress\Pay\AbstractGatewayIntegration;

abstract class AbstractIntegration extends AbstractGatewayIntegration {
/**
* Constructor.
*
* @param array<string, mixed> $args Arguments.
*/
public function __construct( $args = [] ) {
$args = wp_parse_args(
$args,
Expand Down
1 change: 1 addition & 0 deletions src/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function get_fields() {
* Get field by the specifiek name
*
* @param string $name
* @return string|null
*/
public function get_field( $name ) {
$value = null;
Expand Down
5 changes: 2 additions & 3 deletions src/DataCreditCardHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ class DataCreditCardHelper extends DataHelper {
/**
* Set credit card number.
*
* @param int $number Credit card number.
*
* @param string|int $number Credit card number.
* @return DataCreditCardHelper
*/
public function set_number( $number ) {
return $this->set_field( 'CARDNO', $number );
return $this->set_field( 'CARDNO', (string) $number );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/DataGeneralHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function set_alias_usage( $alias_usage ) {
/**
* Set PSP ID
*
* @param int $number PSP ID.
* @param string $number PSP ID.
*
* @return DataGeneralHelper
*/
Expand Down
5 changes: 2 additions & 3 deletions src/DataHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class DataHelper {
/**
* Data
*
* @var array
* @var Data
*/
protected $data;

Expand All @@ -34,8 +34,7 @@ public function __construct( Data $data ) {
*
* @param string $name Name.
* @param string $value Value.
*
* @return mixed
* @return static
*/
public function set_field( $name, $value ) {
$this->data->set_field( $name, $value );
Expand Down
6 changes: 6 additions & 0 deletions src/DataUrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DataUrlHelper extends DataHelper {
* URL of the web page to show the customer when the payment is authorized.
*
* @param string $url
* @return DataUrlHelper
*/
public function set_accept_url( $url ) {
return $this->set_field( Parameters::ACCEPT_URL, $url );
Expand All @@ -32,6 +33,7 @@ public function set_accept_url( $url ) {
* URL of the web page to show the customer when he cancels the payment.
*
* @param string $url
* @return DataUrlHelper
*/
public function set_cancel_url( $url ) {
return $this->set_field( Parameters::CANCEL_URL, $url );
Expand All @@ -43,6 +45,7 @@ public function set_cancel_url( $url ) {
* URL of the web page to show the customer when the payment result is uncertain.
*
* @param string $url
* @return DataUrlHelper
*/
public function set_exception_url( $url ) {
return $this->set_field( Parameters::EXCEPTION_URL, $url );
Expand All @@ -56,6 +59,7 @@ public function set_exception_url( $url ) {
* information page).
*
* @param string $url
* @return DataUrlHelper
*/
public function set_decline_url( $url ) {
return $this->set_field( Parameters::DECLINE_URL, $url );
Expand All @@ -65,6 +69,7 @@ public function set_decline_url( $url ) {
* Set home URL
*
* @param string $url
* @return DataUrlHelper
*/
public function set_home_url( $url ) {
return $this->set_field( 'home', $url );
Expand All @@ -74,6 +79,7 @@ public function set_home_url( $url ) {
* Set back URL
*
* @param string $url
* @return DataUrlHelper
*/
public function set_back_url( $url ) {
return $this->set_field( 'backurl', $url );
Expand Down
5 changes: 5 additions & 0 deletions src/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
* @since 1.0.0
*/
class Listener {
/**
* Listen.
*
* @return void
*/
public static function listen() {
$data = Security::get_request_data();

Expand Down
26 changes: 16 additions & 10 deletions src/OrderStandard/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ class Client {
*/
private $direct_query_url;

/**
* The amount
*
* @var int
*/
private $amount;

/**
* Pass phrase IN
*
Expand Down Expand Up @@ -80,6 +73,13 @@ class Client {
*/
private $data;

/**
* Hashing algorithm.
*
* @var string
*/
private $hash_algorithm;

/**
* Constructs and initialize a iDEAL kassa object
*
Expand All @@ -95,7 +95,7 @@ public function __construct( $psp_id ) {
/**
* Get the payment server URL
*
* @return the payment server URL
* @return string Payment server URL.
*/
public function get_payment_server_url() {
return $this->payment_server_url;
Expand All @@ -105,6 +105,7 @@ public function get_payment_server_url() {
* Set the payment server URL
*
* @param string $url Payment server URL.
* @return void
*/
public function set_payment_server_url( $url ) {
$this->payment_server_url = $url;
Expand All @@ -123,6 +124,7 @@ public function get_direct_query_url() {
* Set the Direct Query URL.
*
* @param string $url Direct query URL.
* @return void
*/
public function set_direct_query_url( $url ) {
$this->direct_query_url = $url;
Expand All @@ -141,6 +143,7 @@ public function get_hash_algorithm() {
* Set hash algorithm
*
* @param string $hash_algorithm Hashing algorithm.
* @return void
*/
public function set_hash_algorithm( $hash_algorithm ) {
$this->hash_algorithm = $hash_algorithm;
Expand All @@ -159,6 +162,7 @@ public function get_pass_phrase_in() {
* Set password phrase IN
*
* @param string $pass_phrase_in Pass phrase IN.
* @return void
*/
public function set_pass_phrase_in( $pass_phrase_in ) {
$this->pass_phrase_in = $pass_phrase_in;
Expand All @@ -177,6 +181,7 @@ public function get_pass_phrase_out() {
* Set password phrase OUT
*
* @param string $pass_phrase_out Pass phrase OUT.
* @return void
*/
public function set_pass_phrase_out( $pass_phrase_out ) {
$this->pass_phrase_out = $pass_phrase_out;
Expand All @@ -195,6 +200,7 @@ public function get_user_id() {
* Set API user ID.
*
* @param string $user_id API user ID.
* @return void
*/
public function set_user_id( $user_id ) {
$this->user_id = $user_id;
Expand All @@ -213,6 +219,7 @@ public function get_password() {
* Set API user password.
*
* @param string $password API user password.
* @return void
*/
public function set_password( $password ) {
$this->password = $password;
Expand Down Expand Up @@ -244,7 +251,6 @@ public function get_signature_in() {
* Get signature OUT
*
* @param array $fields Fields to calculate signature for.
*
* @return string
*/
public function get_signature_out( $fields ) {
Expand All @@ -271,7 +277,6 @@ public function get_fields() {
* Get order status
*
* @param string $order_id Order ID.
*
* @return string|null
* @throws \Exception Throw exception on error in retrieving order status.
*/
Expand Down Expand Up @@ -330,6 +335,7 @@ public function get_order_status( $order_id ) {
* Verify request
*
* @param array $data Request data.
* @return array|false
*/
public function verify_request( $data ) {
$result = false;
Expand Down
37 changes: 36 additions & 1 deletion src/OrderStandard/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,46 @@ class Config extends Ingenico_Config {

/**
* Configuration value for the `COMPLUS` parameter.
*
*
* @var string
*/
public $complus = '';

/**
* Configuration value for the `PARAMVAR` parameter.
*
* @var string
*/
public $param_var = '';

/**
* Configuration value for order ID.
*
* @var string
*/
public $order_id = '';

/**
* Template page.
*
* @var string
*/
public $template_page = '';

/**
* Alias enabled.
*
* @var string
*/
public $alias_enabled = '';

/**
* Alias usage.
*
* @var string
*/
public $alias_usage = '';

/**
* Get the Ogone e-Commerce direct query URL.
*
Expand Down
36 changes: 21 additions & 15 deletions src/OrderStandard/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public function get_output_fields( Payment $payment ) {
}

$ogone_data_general
->set_order_id( $order_id )
->set_order_description( $payment->get_description() )
->set_order_id( (string) $order_id )
->set_order_description( (string) $payment->get_description() )
->set_param_plus( 'payment_id=' . $payment->get_id() )
->set_currency( $payment->get_total_amount()->get_currency()->get_alphabetic_code() )
->set_amount( $payment->get_total_amount()->get_minor_units()->format( 0, '', '' ) );
Expand All @@ -184,9 +184,10 @@ public function get_output_fields( Payment $payment ) {
// Alias.
$alias = $payment->get_meta( 'ogone_alias' );

if ( $this->config->alias_enabled && false !== $alias ) {
$ogone_data_general->set_alias( $alias )
->set_alias_usage( $this->config->alias_usage );
if ( $this->config->alias_enabled && is_string( $alias ) && false !== $alias ) {
$ogone_data_general
->set_alias( $alias )
->set_alias_usage( (string) $this->config->alias_usage );
}

$customer = $payment->get_customer();
Expand Down Expand Up @@ -215,18 +216,18 @@ public function get_output_fields( Payment $payment ) {
$ogone_data_customer->set_name( strval( $name ) );
}

$ogone_data_customer->set_email( $customer->get_email() );
$ogone_data_customer->set_email( (string) $customer->get_email() );
}

$billing_address = $payment->get_billing_address();

if ( null !== $billing_address ) {
$ogone_data_customer
->set_address( $billing_address->get_line_1() )
->set_zip( $billing_address->get_postal_code() )
->set_town( $billing_address->get_city() )
->set_country( $billing_address->get_country_code() )
->set_telephone_number( $billing_address->get_phone() );
->set_address( (string) $billing_address->get_line_1() )
->set_zip( (string) $billing_address->get_postal_code() )
->set_town( (string) $billing_address->get_city() )
->set_country( (string) $billing_address->get_country_code() )
->set_telephone_number( (string) $billing_address->get_phone() );
}

/*
Expand Down Expand Up @@ -262,7 +263,11 @@ public function get_output_fields( Payment $payment ) {
->set_brand( Brands::IDEAL )
->set_payment_method( PaymentMethods::IDEAL );

$ogone_data_general->set_field( 'ISSUERID', $payment->get_meta( 'issuer' ) );
$issuer = $payment->get_meta( 'issuer' );

if ( is_string( $issuer ) ) {
$ogone_data_general->set_field( 'ISSUERID', $issuer );
}

break;
case Core_PaymentMethods::BANCONTACT:
Expand Down Expand Up @@ -316,13 +321,13 @@ public function update_status( Payment $payment ) {
$data = $this->client->verify_request( $data );

if ( false !== $data ) {
$status = Statuses::transform( $data[ Parameters::STATUS ] );
$status = Statuses::transform( (string) $data[ Parameters::STATUS ] );

$payment->set_status( $status );

// Update transaction ID.
if ( \array_key_exists( Parameters::PAY_ID, $data ) ) {
$payment->set_transaction_id( $data[ Parameters::PAY_ID ] );
$payment->set_transaction_id( (string) $data[ Parameters::PAY_ID ] );
}

// Add payment note.
Expand All @@ -339,7 +344,7 @@ public function update_status( Payment $payment ) {
}

try {
$status = $this->client->get_order_status( $order_id );
$status = $this->client->get_order_status( (string) $order_id );
} catch ( \Exception $e ) {
$payment->add_note( $e->getMessage() );

Expand All @@ -356,6 +361,7 @@ public function update_status( Payment $payment ) {
*
* @param Payment $payment Payment.
* @param array $data Data.
* @return void
*/
private function update_status_payment_note( Payment $payment, $data ) {
$labels = [
Expand Down
Loading

0 comments on commit 5a27266

Please sign in to comment.