Skip to content

Commit

Permalink
chore: return types
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Apr 6, 2024
1 parent b18036e commit b99ad8d
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Connection/FormFieldsConnection.php
Expand Up @@ -31,7 +31,7 @@ public static function register(): void {
}

/**
* Gets custom connection configuration arguments, such as the resolver, edgeFields, connectionArgs, etc.
* {@inheritDoc}
*/
public static function get_connection_args(): array {
return [
Expand Down
24 changes: 12 additions & 12 deletions src/Data/FieldValueInput/AbstractFieldValueInput.php
Expand Up @@ -26,7 +26,7 @@ abstract class AbstractFieldValueInput {
/**
* The Gravity Forms entry object, if it exists.
*
* @var array|null
* @var array<string|int,mixed>|null
*/
protected ?array $entry;

Expand All @@ -47,7 +47,7 @@ abstract class AbstractFieldValueInput {
/**
* The Gravity Forms form object.
*
* @var array
* @var array<string,mixed>
*/
protected array $form;

Expand Down Expand Up @@ -75,11 +75,11 @@ abstract class AbstractFieldValueInput {
/**
* The class constructor.
*
* @param array $input_args The GraphQL input args for the form field.
* @param array $form The current Gravity Forms form object.
* @param bool $is_draft Whether the mutation is handling a Draft Entry.
* @param \GF_Field $field The current Gravity Forms field object.
* @param array|null $entry The current Gravity Forms entry object.
* @param array $input_args The GraphQL input args for the form field.
* @param array<string,mixed> $form The current Gravity Forms form object.
* @param bool $is_draft Whether the mutation is handling a Draft Entry.
* @param \GF_Field $field The current Gravity Forms field object.
* @param array<int|string,mixed>|null $entry The current Gravity Forms entry object.
*
* @throws \GraphQL\Error\UserError .
*/
Expand All @@ -93,11 +93,11 @@ public function __construct( array $input_args, array $form, bool $is_draft, ?GF
/**
* Filters the accepted GraphQL input value key for the form field.
*
* @param string $name The GraphQL input value name to use. E.g. `nameValues`.
* @param \GF_Field $field The current Gravity Forms field object.
* @param array $form The current Gravity Forms form object.
* @param array|null $entry The current Gravity Forms entry object. Only available when using update (`gfUpdateEntry`, `gfUpdateDraftEntry`) mutations.
* @param bool $is_draft_mutation Whether the mutation is handling a Draft Entry (`gfUpdateDraftEntry`, or `gfSubmitForm` when `saveAsDraft` is `true`).
* @param string $name The GraphQL input value name to use. E.g. `nameValues`.
* @param \GF_Field $field The current Gravity Forms field object.
* @param array<string,mixed> $form The current Gravity Forms form object.
* @param array<int|string,mixed>|null $entry The current Gravity Forms entry object. Only available when using update (`gfUpdateEntry`, `gfUpdateDraftEntry`) mutations.
* @param bool $is_draft_mutation Whether the mutation is handling a Draft Entry (`gfUpdateDraftEntry`, or `gfSubmitForm` when `saveAsDraft` is `true`).
*/
$this->field_name = apply_filters(
'graphql_gf_field_value_input_name',
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/Enum.php
Expand Up @@ -15,6 +15,8 @@
interface Enum {
/**
* Gets the Enum type values.
*
* @return array<string,array<string,mixed>>
*/
public static function get_values(): array;
}
4 changes: 4 additions & 0 deletions src/Interfaces/Mutation.php
Expand Up @@ -15,13 +15,17 @@ interface Mutation {
/**
* Defines the input field configuration.
*
* @return array<string,array<string,mixed>>
*
* @since 0.4.0
*/
public static function get_input_fields(): array;

/**
* Defines the output field configuration.
*
* @return array<string,array<string,mixed>>
*
* @since 0.4.0
*/
public static function get_output_fields(): array;
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/TypeWithConnections.php
Expand Up @@ -14,6 +14,8 @@
interface TypeWithConnections {
/**
* Gets the the connection config for the GraphQL Type.
*
* @return array<string,array<string,mixed>>
*/
public static function get_connections(): array;
}
4 changes: 3 additions & 1 deletion src/Interfaces/TypeWithFields.php
Expand Up @@ -13,7 +13,9 @@
*/
interface TypeWithFields {
/**
* Gets the properties for the type.
* Gets the GraphQL fields for the type.
*
* @return array<string,array<string,mixed>> The GraphQL field configs for the type.
*/
public static function get_fields(): array;
}
14 changes: 10 additions & 4 deletions src/Registry/FormFieldRegistry.php
Expand Up @@ -214,6 +214,8 @@ static function ( TypeRegistry $type_registry ) use ( $field, $interface_setting
* Gets the registered field settings, including those of input types.
*
* @param \GF_Field $field .
*
* @return string[]
*/
public static function get_field_settings( GF_Field $field ): array {
$settings = $field->get_form_editor_field_settings();
Expand Down Expand Up @@ -242,6 +244,8 @@ public static function get_field_settings( GF_Field $field ): array {
*
* @param \GF_Field $field .
* @param array $settings .
*
* @return array{interfaces:string[],fields:array}
*/
public static function get_config_from_settings( GF_Field $field, array $settings ): array {
// Every GF_field is a FormField.
Expand Down Expand Up @@ -339,6 +343,8 @@ public static function get_description( string $field_name ): string {
* @param \GF_Field $field The Gravity Forms field object.
* @param array $settings The Gravity Forms field settings.
* @param array $interfaces The list of interfaces to add to the field.
*
* @return array<string,array<string,mixed>> The GraphQL fields config.
*/
public static function get_fields( GF_Field $field, array $settings, $interfaces ): array {
$fields = [];
Expand All @@ -362,10 +368,10 @@ public static function get_fields( GF_Field $field, array $settings, $interfaces
/**
* Filter to modify the Form Field GraphQL fields.
*
* @param array $fields An array of GraphQL field configs. See https://www.wpgraphql.com/functions/register_graphql_fields/
* @param \GF_Field $field The Gravity Forms Field object.
* @param array $settings The `form_editor_field_settings()` key.
* @param array $interfaces The list of interfaces for the GraphQL type.
* @param array<string,array<string,mixed>> $fields An array of GraphQL field configs. See https://www.wpgraphql.com/functions/register_graphql_fields/
* @param \GF_Field $field The Gravity Forms Field object.
* @param array $settings The `form_editor_field_settings()` key.
* @param array $interfaces The list of interfaces for the GraphQL type.
*/
$fields = apply_filters( 'graphql_gf_form_field_setting_fields', $fields, $field, $settings, $interfaces );

Expand Down
2 changes: 2 additions & 0 deletions src/Type/AbstractType.php
Expand Up @@ -40,6 +40,8 @@ public static function register_hooks(): void {

/**
* Gets the WPGraphQL config array used to register the type.
*
* @return array<string,mixed>
*/
abstract public static function get_type_config(): array;
}
2 changes: 2 additions & 0 deletions src/Type/WPInterface/AbstractInterface.php
Expand Up @@ -46,6 +46,8 @@ public static function register( ?TypeRegistry $type_registry = null ): void {

/**
* {@inheritDoc}
*
* @return array<string,mixed>
*/
public static function get_type_config( ?TypeRegistry $type_registry = null ): array {
return [
Expand Down

0 comments on commit b99ad8d

Please sign in to comment.