diff --git a/src/Extension.php b/src/Extension.php index 5dcc5b6..f954f9e 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -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; @@ -20,6 +22,8 @@ * * @version 1.5.1 * @since 1.0.0 + * @phpstan-type NinjaFormsSection array{id: string, nicename: string, fieldTypes: array} + * @phpstan-type NinjaFormsSettingsGroup array{id: string, label: string, priority: int} */ class Extension extends AbstractPluginIntegration { /** @@ -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' ] ); @@ -74,9 +78,8 @@ public function setup() { /** * Filter field type sections. * - * @param array $sections Field type sections. - * - * @return array + * @param array $sections Ninja Forms sections. + * @return array */ public function field_type_sections( $sections ) { $sections['pronamic_pay'] = [ @@ -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 $fields Fields from Ninja Forms. + * @return array */ public function register_fields( $fields ) { $fields['pronamic_pay_payment_method'] = new PaymentMethodsField(); @@ -104,9 +107,8 @@ public function register_fields( $fields ) { /** * Register payment gateways. * - * @param array $gateways Payment gateways. - * - * @return array + * @param array $gateways Payment gateways. + * @return array */ public function register_payment_gateways( $gateways ) { $gateways['pronamic_pay'] = new PaymentGateway(); @@ -117,9 +119,8 @@ public function register_payment_gateways( $gateways ) { /** * Register settings groups. * - * @param array $groups Settings groups. - * - * @return array + * @param array $groups Settings groups. + * @return array */ public function register_settings_groups( $groups ) { $groups['pronamic_pay'] = [ @@ -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; @@ -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. diff --git a/src/PaymentMethodsField.php b/src/PaymentMethodsField.php index 3d99213..3a13f76 100644 --- a/src/PaymentMethodsField.php +++ b/src/PaymentMethodsField.php @@ -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, columns: array} */ class PaymentMethodsField extends NF_Abstracts_List { @@ -67,6 +69,7 @@ class PaymentMethodsField extends NF_Abstracts_List { /** * Old classname for earlier versions. * + * @override * @var string */ protected $_old_classname = 'list-select'; @@ -74,7 +77,7 @@ class PaymentMethodsField extends NF_Abstracts_List { /** * Settings. * - * @var array + * @var array{options?: SettingsOptions} */ protected $_settings = []; @@ -99,7 +102,7 @@ public function __construct() { /** * Get default Pronamic payment method options. * - * @return array + * @return array */ private function get_pronamic_payment_method_options() { $options = [];