Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.0 #10

Merged
merged 3 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ composer require axewp/wp-graphql-plugin-boilerplate
},
```


### As a plugin starter

#### 1. Initialize the plugin
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
}
],
"require": {
"php": ">=7.4 || ^8.0 || ^8.1"
"php": ">=7.4"
},
"require-dev": {
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.2",
"axepress/wp-graphql-stubs": "^1.12.2",
"axepress/wp-graphql-cs": "^1.0.0-beta",
"axepress/wp-graphql-cs": "^2.0.0-beta",
"phpcompatibility/php-compatibility": "dev-develop as 9.9.9",
"szepeviktor/phpstan-wordpress": "^1.0",
"wp-cli/wp-cli-bundle": "^2.8.1"
},
Expand Down
1,521 changes: 991 additions & 530 deletions composer.lock

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
parameters:
level: 8
checkAlwaysTrueCheckTypeFunctionCall: true
checkAlwaysTrueInstanceof: true
checkAlwaysTrueStrictComparison: true
checkExplicitMixedMissingReturn: true
checkFunctionNameCase: true
checkInternalClassCaseSensitivity: true
checkMissingIterableValueType: true
checkTooWideReturnTypesInProtectedAndPublicMethods: true
inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false
polluteScopeWithAlwaysIterableForeach: false
polluteScopeWithLoopInitialAssignments: false
reportAlwaysTrueInLastCondition: true
reportStaticMethodSignatures: true
reportWrongPhpDocTypeInVarTag: true
treatPhpDocTypesAsCertain: false
stubFiles:
# Simulate added properties
- phpstan/class-wp-post-type.stub
Expand Down
29 changes: 11 additions & 18 deletions src/Abstracts/ConnectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

use AxeWP\GraphQL\Interfaces\GraphQLType;
Expand All @@ -16,22 +18,21 @@
/**
* Class - ConnectionType
*
* @phpstan-type ConnectionConfig array{
* fromType: string,
* @phpstan-type ConnectionConfig array{fromType:string,
* fromFieldName: string,
* resolve: callable,
* oneToOne?: bool,
* toType?: string,
* connectionArgs?: array<string, array{
* type: string|array<string, string | array<string, string>>,
* connectionArgs?: array<string,array{
* type: string|array<string,string | array<string,string>>,
* description: string,
* defaultValue?: mixed
* }>,
* connectionFields?: array<string, array{
* type: string|array<string, string | array<string, string>>,
* connectionFields?: array<string,array{
* type: string|array<string,string | array<string,string>>,
* description: string,
* args?: array<string, array{
* type: string|array<string, string | array<string, string>>,
* args?: array<string,array{
* type: string|array<string,string | array<string,string>>,
* description: string,
* defaultValue?: mixed,
* }>,
Expand All @@ -53,11 +54,7 @@ public static function init(): void {
/**
* Defines all possible connection args for the GraphQL type.
*
* @return array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* defaultValue?: mixed
* }>,
* @return array<string,array{type:string|array<string,string|array<string,string>>,description:string,defaultValue?:mixed}>
*/
abstract protected static function connection_args(): array;

Expand All @@ -82,11 +79,7 @@ protected static function get_connection_config( $config ): array {
*
* @param ?string[] $filter_by an array of specific connections to return.
*
* @return array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* defaultValue?: mixed
* }>
* @return array<string,array{type:string|array<string,string|array<string,string>>,description:string,defaultValue?:mixed}>
*/
final public static function get_connection_args( ?array $filter_by = null ): array {
$connection_args = static::connection_args();
Expand Down
8 changes: 3 additions & 5 deletions src/Abstracts/EnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

if ( ! class_exists( '\AxeWP\GraphQL\Abstracts\EnumType' ) ) {
Expand All @@ -16,11 +18,7 @@ abstract class EnumType extends Type {
/**
* Gets the Enum values configuration array.
*
* @return array<string, array{
* description: string,
* value: mixed,
* deprecationReason?: string
* }>
* @return array<string,array{description:string,value:mixed,deprecationReason?:string}>
*/
abstract public static function get_values(): array;

Expand Down
2 changes: 2 additions & 0 deletions src/Abstracts/FieldsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

use AxeWP\GraphQL\Interfaces\GraphQLType;
Expand Down
2 changes: 2 additions & 0 deletions src/Abstracts/InputType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

use AxeWP\GraphQL\Interfaces\TypeWithInputFields;
Expand Down
2 changes: 2 additions & 0 deletions src/Abstracts/InterfaceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

use AxeWP\GraphQL\Interfaces\TypeWithFields;
Expand Down
20 changes: 4 additions & 16 deletions src/Abstracts/MutationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

if ( ! class_exists( '\AxeWP\GraphQL\Abstracts\MutationType' ) ) {
Expand All @@ -16,28 +18,14 @@ abstract class MutationType extends Type {
/**
* Gets the input fields for the mutation.
*
* @return array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* defaultValue?: string
* }>
* @return array<string,array{type:string|array<string,string|array<string,string>>,description:string,defaultValue?:string}>
*/
abstract public static function get_input_fields(): array;

/**
* Gets the fields for the type.
*
* @return array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* args?: array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* defaultValue?: mixed
* }>,
* resolve?: callable,
* deprecationReason?: string,
* }>
* @return array<string,array{type:string|array<string,string|array<string,string>>,description:string,args?:array<string,array{type:string|array<string,string|array<string,string>>,description:string,defaultValue?:mixed}>,resolve?:callable,deprecationReason?:string}>
*/
abstract public static function get_output_fields(): array;

Expand Down
2 changes: 2 additions & 0 deletions src/Abstracts/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

use AxeWP\GraphQL\Interfaces\TypeWithFields;
Expand Down
4 changes: 3 additions & 1 deletion src/Abstracts/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

use AxeWP\GraphQL\Interfaces\GraphQLType;
Expand Down Expand Up @@ -39,7 +41,7 @@ abstract public static function get_description(): string;
/**
* Gets the $config array used to register the type to WPGraphQL.
*
* @return array<string, mixed>
* @return array<string,mixed>
*/
protected static function get_type_config(): array {
return [
Expand Down
2 changes: 2 additions & 0 deletions src/Abstracts/UnionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Abstracts
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Abstracts;

use AxeWP\GraphQL\Traits\TypeResolverTrait;
Expand Down
12 changes: 7 additions & 5 deletions src/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Helper
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Helper;

if ( ! class_exists( '\AxeWP\GraphQL\Helper\Helper' ) ) {
Expand All @@ -13,11 +15,11 @@
* Class - Helper
*/
class Helper {
/**
* The hook prefix for the plugin.
*
* @var string
*/
/**
* The hook prefix for the plugin.
*
* @var string
*/
public static string $hook_prefix;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/GraphQLType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Interfaces
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Interfaces;

if ( ! interface_exists( '\AxeWP\GraphQL\Interfaces\GraphQLType' ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/Registrable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Interfaces
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Interfaces;

if ( ! interface_exists( '\AxeWP\GraphQL\Interfaces\Registrable' ) ) {
Expand Down
15 changes: 3 additions & 12 deletions src/Interfaces/TypeWithConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Interfaces
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Interfaces;

if ( ! interface_exists( '\AxeWP\GraphQL\Interfaces\TypeWithConnections' ) ) {
Expand All @@ -16,18 +18,7 @@ interface TypeWithConnections extends GraphQLType {
/**
* Gets the properties for the type.
*
* @return array<string, array{
* toType: string,
* description: string,
* args?: array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* defaultValue?: mixed
* }>,
* connectionInterfaces?: string[],
* oneToOne?: bool,
* resolve?: callable,
* }>
* @return array<string,array{toType:string,description:string,args?:array<string,array{type:string|array<string,string|array<string,string>>,description:string,defaultValue?:mixed}>,connectionInterfaces?:string[],oneToOne?:bool,resolve?:callable}>
*/
public static function get_connections(): array;
}
Expand Down
14 changes: 3 additions & 11 deletions src/Interfaces/TypeWithFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Interfaces
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Interfaces;

if ( ! interface_exists( '\AxeWP\GraphQL\Interfaces\TypeWithFields' ) ) {
Expand All @@ -16,17 +18,7 @@ interface TypeWithFields extends GraphQLType {
/**
* Gets the fields for the type.
*
* @return array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* args?: array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* defaultValue?: mixed
* }>,
* resolve?: callable,
* deprecationReason?: string,
* }>
* @return array<string,array{type:string|array<string,string|array<string,string>>,description:string,args?:array<string,array{type:string|array<string,string|array<string,string>>,description:string,defaultValue?:mixed}>,resolve?:callable,deprecationReason?:string}>
*/
public static function get_fields(): array;
}
Expand Down
8 changes: 3 additions & 5 deletions src/Interfaces/TypeWithInputFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Interfaces
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Interfaces;

if ( ! interface_exists( '\AxeWP\GraphQL\Interfaces\TypeWithInputFields' ) ) {
Expand All @@ -16,11 +18,7 @@ interface TypeWithInputFields extends GraphQLType {
/**
* Gets the input fields for the type.
*
* @return array<string, array{
* type: string|array<string, string | array<string, string>>,
* description: string,
* defaultValue?: string
* }>
* @return array<string,array{type:string|array<string,string|array<string,string>>,description:string,defaultValue?:string}>
*/
public static function get_fields(): array;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/TypeWithInterfaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Interfaces
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Interfaces;

if ( ! interface_exists( '\AxeWP\GraphQL\Interfaces\TypeWithInterfaces' ) ) {
Expand Down
7 changes: 4 additions & 3 deletions src/Traits/TypeNameTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package AxeWP\GraphQL\Traits
*/

declare( strict_types=1 );

namespace AxeWP\GraphQL\Traits;

use AxeWP\GraphQL\Helper\Helper;
Expand All @@ -22,14 +24,13 @@ trait TypeNameTrait {
* @throws \Exception When the implementing class has no type name.
*/
final public static function get_type_name(): string {
if ( ! method_exists( static::class, 'type_name' ) ) {
if ( ! is_callable( [ static::class, 'type_name' ] ) ) {
throw new Exception(
// translators: the implementing class.
sprintf( __( 'To use TypeNameTrait, a %s must implement a `type_name()` method.', 'wp-graphql-plugin-name' ), static::class )
sprintf( esc_html__( 'To use TypeNameTrait, a %s must implement a `type_name()` method.', 'wp-graphql-plugin-name' ), static::class )
);
}

// @phpstan-ignore-next-line
$type_name = static::type_name();

$hook_prefix = Helper::hook_prefix();
Expand Down
Loading
Loading