Skip to content

Commit

Permalink
Fix some PHPStan issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Dec 21, 2023
1 parent b294a67 commit f14e79e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
27 changes: 14 additions & 13 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Pronamic\WordPress\Pay\Extensions\NinjaForms;

use NF_Abstracts_Field;
use NF_Abstracts_PaymentGateway;
use Pronamic\WordPress\Pay\AbstractPluginIntegration;
use Pronamic\WordPress\Pay\Payments\Payment;
use Pronamic\WordPress\Pay\Payments\PaymentStatus;
Expand All @@ -20,6 +22,8 @@
*
* @version 1.5.1
* @since 1.0.0
* @phpstan-type NinjaFormsSection array{id: string, nicename: string, fieldTypes: array<string>}
* @phpstan-type NinjaFormsSettingsGroup array{id: string, label: string, priority: int}
*/
class Extension extends AbstractPluginIntegration {
/**
Expand Down Expand Up @@ -62,7 +66,7 @@ public function setup() {
\add_action( 'pronamic_payment_status_update_' . self::SLUG, [ $this, 'update_status' ] );

\add_filter( 'ninja_forms_field_type_sections', [ $this, 'field_type_sections' ] );
\add_filter( 'ninja_forms_register_fields', [ $this, 'register_fields' ], 10, 3 );
\add_filter( 'ninja_forms_register_fields', [ $this, 'register_fields' ], 10, 1 );
\add_filter( 'ninja_forms_register_payment_gateways', [ $this, 'register_payment_gateways' ], 10, 1 );
\add_filter( 'ninja_forms_field_settings_groups', [ $this, 'register_settings_groups' ] );

Expand All @@ -74,9 +78,8 @@ public function setup() {
/**
* Filter field type sections.
*
* @param array $sections Field type sections.
*
* @return array
* @param array<string, NinjaFormsSection> $sections Ninja Forms sections.
* @return array<string, NinjaFormsSection>
*/
public function field_type_sections( $sections ) {
$sections['pronamic_pay'] = [
Expand All @@ -91,8 +94,8 @@ public function field_type_sections( $sections ) {
/**
* Register custom fields
*
* @param array $fields Fields from Ninja Forms.
* @return array $fields
* @param array<string, NF_Abstracts_Field> $fields Fields from Ninja Forms.
* @return array<string, NF_Abstracts_Field>
*/
public function register_fields( $fields ) {
$fields['pronamic_pay_payment_method'] = new PaymentMethodsField();
Expand All @@ -104,9 +107,8 @@ public function register_fields( $fields ) {
/**
* Register payment gateways.
*
* @param array $gateways Payment gateways.
*
* @return array
* @param array<string, NF_Abstracts_PaymentGateway> $gateways Payment gateways.
* @return array<string, NF_Abstracts_PaymentGateway>
*/
public function register_payment_gateways( $gateways ) {
$gateways['pronamic_pay'] = new PaymentGateway();
Expand All @@ -117,9 +119,8 @@ public function register_payment_gateways( $gateways ) {
/**
* Register settings groups.
*
* @param array $groups Settings groups.
*
* @return array
* @param array<string, NinjaFormsSettingsGroup> $groups Settings groups.
* @return array<string, NinjaFormsSettingsGroup>
*/
public function register_settings_groups( $groups ) {
$groups['pronamic_pay'] = [
Expand All @@ -140,7 +141,6 @@ public function register_settings_groups( $groups ) {
public function update_status( Payment $payment ) {
switch ( $payment->status ) {
case PaymentStatus::SUCCESS:
// Fulfill order.
$this->fulfill_order( $payment );

break;
Expand All @@ -151,6 +151,7 @@ public function update_status( Payment $payment ) {
* Fulfill order.
*
* @param Payment $payment Payment.
* @return void
*/
public function fulfill_order( $payment ) {
// Check if already fulfilled.
Expand Down
7 changes: 5 additions & 2 deletions src/PaymentMethodsField.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*
* @version 1.0.1
* @since 1.0.0
* @phpstan-type Option array{label: string, value: string, calc: string, selected: int, order: int}
* @phpstan-type SettingsOptions array{value: array<int, Option>, columns: array<string, string>}
*/
class PaymentMethodsField extends NF_Abstracts_List {

Expand Down Expand Up @@ -67,14 +69,15 @@ class PaymentMethodsField extends NF_Abstracts_List {
/**
* Old classname for earlier versions.
*
* @override
* @var string
*/
protected $_old_classname = 'list-select';

/**
* Settings.
*
* @var array
* @var array{options?: SettingsOptions}
*/
protected $_settings = [];

Expand All @@ -99,7 +102,7 @@ public function __construct() {
/**
* Get default Pronamic payment method options.
*
* @return array
* @return array<int, Option>
*/
private function get_pronamic_payment_method_options() {
$options = [];
Expand Down

0 comments on commit f14e79e

Please sign in to comment.