Skip to content

Commit

Permalink
Fix code quality issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Aug 12, 2024
1 parent 9407541 commit 1eee405
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 2,463 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@
"overtrue/phplint": "^4.5",
"php-coveralls/php-coveralls": "^2.4",
"phpmd/phpmd": "^2.7",
"phpstan/phpstan": "^1.11",
"pronamic/pronamic-cli": "^1.0",
"pronamic/wp-coding-standards": "^1.3",
"roots/wordpress": "^6.0",
"szepeviktor/phpstan-wordpress": "^1.3",
"vimeo/psalm": "^0.3.14",
"wp-cli/wp-cli": "^2.3",
"wp-phpunit/wp-phpunit": "^6.1",
"yoast/phpunit-polyfills": "^1.0"
Expand Down
6 changes: 3 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
includes:
- vendor-bin/phpstan/vendor/szepeviktor/phpstan-wordpress/extension.neon
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
customRulesetUsed: false
level: max
bootstrapFiles:
- tests/phpstan/bootstrap.php
paths:
- src/
scanDirectories:
- wordpress/
8 changes: 5 additions & 3 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ private function maybe_enrich_payment_methods() {
$payment_method->set_status( 'inactive' );
}

if ( null !== $buckaroo_transaction_specifications->Services ) {
foreach ( $buckaroo_transaction_specifications->Services as $service ) {
$services = is_object( $buckaroo_transaction_specifications ) && property_exists( $buckaroo_transaction_specifications, 'Services' ) ? $buckaroo_transaction_specifications->Services : null;

if ( null !== $services ) {
foreach ( $services as $service ) {
$payment_method_id = PaymentMethods::from_buckaroo_to_pronamic( $service->Name );

if ( null === $payment_method_id ) {
Expand Down Expand Up @@ -742,7 +744,7 @@ public function request( $method, $endpoint, $data = null ) {
/**
* OK.
*/
return $object;
return (object) $object;
}

/**
Expand Down
16 changes: 13 additions & 3 deletions src/PushController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ private function handle_json_push( \WP_REST_Request $request ) {

$data = \json_decode( $json );

if ( ! is_object( $data ) || ! property_exists( $data, 'Transaction' ) ) {
return new \WP_Error(
'pronamic_pay_buckaroo_push_unknown_transaction',
'Unknown Buckaroo push transaction.',
[ 'status' => 500 ]
);
}

$transaction_key = $data->Transaction->Key;

/**
Expand All @@ -102,9 +110,11 @@ private function handle_json_push( \WP_REST_Request $request ) {
* @link https://support.buckaroo.nl/categorie%C3%ABn/integratie/transactietypes-overzicht
* @link https://dev.buckaroo.nl/PaymentMethods/Description/ideal
*/
foreach ( $data->Transaction->RelatedTransactions as $related_transaction ) {
if ( 'refund' === $related_transaction->RelationType ) {
$transaction_key = $related_transaction->RelatedTransactionKey;
if ( property_exists( $data->Transaction, 'RelatedTransactions' ) ) {
foreach ( $data->Transaction->RelatedTransactions as $related_transaction ) {
if ( 'refund' === $related_transaction->RelationType ) {
$transaction_key = $related_transaction->RelatedTransactionKey;
}
}
}

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.

269 changes: 0 additions & 269 deletions vendor-bin/phpstan/composer.lock

This file was deleted.

5 changes: 0 additions & 5 deletions vendor-bin/psalm/composer.json

This file was deleted.

Loading

0 comments on commit 1eee405

Please sign in to comment.