Skip to content

Commit

Permalink
Fix PHPStan issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Aug 12, 2024
1 parent 331bb05 commit 6791b30
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 2,415 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@
"overtrue/phplint": "^9.0",
"php-coveralls/php-coveralls": "^2.6",
"phpmd/phpmd": "^2.14",
"phpstan/phpstan": "^1.11",
"pronamic/pronamic-cli": "^1.1",
"pronamic/wp-coding-standards": "^2.0",
"roots/wordpress": "^6.0",
"szepeviktor/phpstan-wordpress": "^1.3",
"vimeo/psalm": "^5.25",
"wp-phpunit/wp-phpunit": "^6.1",
"yoast/phpunit-polyfills": "^1.0"
},
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<ruleset name="WordPress Pay Gateway Ogone rules">
<file>.</file>

<exclude-pattern type="relative">^build/*</exclude-pattern>
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
<exclude-pattern>tests/wp-config.php</exclude-pattern>

Expand Down
5 changes: 1 addition & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
includes:
- vendor-bin/phpstan/vendor/szepeviktor/phpstan-wordpress/extension.neon
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
checkMissingIterableValueType: false
customRulesetUsed: false
level: max
bootstrapFiles:
- tests/phpstan/bootstrap.php
paths:
- src/
14 changes: 7 additions & 7 deletions src/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class Data {
/**
* Fields
*
* @var array
* @var array<string, string>
*/
private $fields;

/**
* Constructs and initialize a iDEAL kassa object
* Constructs and initialize a Data object
*/
public function __construct() {
$this->fields = [];
Expand All @@ -30,16 +30,16 @@ public function __construct() {
/**
* Get all the fields
*
* @return array
* @return array<string, string>
*/
public function get_fields() {
return $this->fields;
}

/**
* Get field by the specifiek name
* Get field by the specified name
*
* @param string $name
* @param string $name Field name.
* @return string|null
*/
public function get_field( $name ) {
Expand All @@ -55,8 +55,8 @@ public function get_field( $name ) {
/**
* Set field
*
* @param string $name
* @param string $value
* @param string $name Field name.
* @param string $value Field value.
*
* @return Data
*/
Expand Down
8 changes: 4 additions & 4 deletions src/OrderStandard/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function get_signature_in() {
/**
* Get signature OUT
*
* @param array $fields Fields to calculate signature for.
* @param array<string, string> $fields Fields to calculate signature for.
* @return string
*/
public function get_signature_out( $fields ) {
Expand All @@ -265,7 +265,7 @@ public function get_signature_out( $fields ) {
* Get fields
*
* @since 1.2.1
* @return array
* @return array<string, string>
*/
public function get_fields() {
Security::sign_data( $this->data, $this->get_pass_phrase_in(), $this->hash_algorithm );
Expand Down Expand Up @@ -334,8 +334,8 @@ public function get_order_status( $order_id ) {
/**
* Verify request
*
* @param array $data Request data.
* @return array|false
* @param array<string, string> $data Request data.
* @return array<string, scalar|null>|false
*/
public function verify_request( $data ) {
$result = false;
Expand Down
8 changes: 4 additions & 4 deletions src/OrderStandard/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function start( Payment $payment ) {
*
* @param Payment $payment Payment.
*
* @return array
* @return array<string, string>
* @since 1.2.1
* @version 2.0.4
*/
Expand Down Expand Up @@ -350,8 +350,8 @@ public function update_status( Payment $payment ) {
/**
* Update status payment note
*
* @param Payment $payment Payment.
* @param array $data Data.
* @param Payment $payment Payment.
* @param array<string, scalar|null> $data Data.
* @return void
*/
private function update_status_payment_note( Payment $payment, $data ) {
Expand Down Expand Up @@ -384,7 +384,7 @@ private function update_status_payment_note( Payment $payment, $data ) {
foreach ( $labels as $key => $label ) {
if ( isset( $data[ $key ] ) && '' !== $data[ $key ] ) {
$note .= sprintf( '<dt>%s</dt>', esc_html( $label ) );
$note .= sprintf( '<dd>%s</dd>', esc_html( $data[ $key ] ) );
$note .= sprintf( '<dd>%s</dd>', esc_html( (string) $data[ $key ] ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/OrderStandard/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct( $args = [] ) {
/**
* Get settings fields.
*
* @return array
* @return array<int, array<string, mixed>>
*/
public function get_settings_fields() {
return Settings::get_settings_fields();
Expand Down
4 changes: 2 additions & 2 deletions src/PaymentMethodsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class PaymentMethodsList {
/**
* List
*
* @var array
* @var array<string>
*/
private $data;

/**
* Constructs and initialize a payment methods list
*
* @param array $data Data.
* @param array<string> $data Data.
*/
public function __construct( array $data = [] ) {
$this->data = $data;
Expand Down
22 changes: 11 additions & 11 deletions src/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ class Security {
/**
* The Ogone calculations parameters in
*
* @var array|null
* @var array<int, string>|null
*/
private static $calculations_parameters_in;

/**
* The Ogone calculations parameters out
*
* @var array|null
* @var array<int, string>|null
*/
private static $calculations_parameters_out;

/**
* Get calculations parameters in
*
* @return array
* @return array<int, string>
*/
public static function get_calculations_parameters_in() {
if ( ! isset( self::$calculations_parameters_in ) ) {
Expand All @@ -52,7 +52,7 @@ public static function get_calculations_parameters_in() {
/**
* Get calculations parameters in
*
* @return array
* @return array<int, string>
*/
public static function get_calculations_parameters_out() {
if ( ! isset( self::$calculations_parameters_out ) ) {
Expand All @@ -75,7 +75,7 @@ public static function get_calculations_parameters_out() {
/**
* Get request data
*
* @return array
* @return array<string, string>
*/
public static function get_request_data() {
$data = [];
Expand Down Expand Up @@ -103,9 +103,9 @@ public static function get_request_data() {
/**
* Get calculation fields.
*
* @param array $calculation_fields Calculation fields.
* @param array $fields Fields.
* @return array
* @param array<string> $calculation_fields Calculation fields.
* @param array<string, string> $fields Fields.
* @return array<string, string>
*/
public static function get_calculation_fields( $calculation_fields, $fields ) {
$calculation_fields = array_flip( $calculation_fields );
Expand All @@ -116,9 +116,9 @@ public static function get_calculation_fields( $calculation_fields, $fields ) {
/**
* Get signature.
*
* @param array $fields Fields.
* @param string $passphrase Pass phrase.
* @param string $hash_algorithm Hashing algorithm.
* @param array<string, string> $fields Fields.
* @param string $passphrase Pass phrase.
* @param string $hash_algorithm Hashing algorithm.
* @return string
*/
public static function get_signature( $fields, $passphrase, $hash_algorithm ) {
Expand Down
2 changes: 1 addition & 1 deletion src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Settings {
/**
* Fields.
*
* @return array
* @return array<int, array<string, mixed>>
*/
public static function get_settings_fields() {
$fields = [];
Expand Down
11 changes: 0 additions & 11 deletions tests/phpstan/bootstrap.php

This file was deleted.

6 changes: 0 additions & 6 deletions vendor-bin/phpstan/composer.json

This file was deleted.

Loading

0 comments on commit 6791b30

Please sign in to comment.