Skip to content

Commit

Permalink
chore: implement strict phpstan rules and fix (#66)
Browse files Browse the repository at this point in the history
* chore: implement strict phpstan rules and fix

* fix: param conflict
  • Loading branch information
justlevine authored Apr 6, 2024
1 parent c35bbe7 commit eb92a52
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## Unreleased

- chore: Implement strict phpstan rules and lint.
- chore: Update Composer dependencies and lint.
- ci: Test against WP 6.5.
- ci: update GitHub Workflows.
- ci: Update GitHub Workflows.

## v0.4.4

Expand Down
2 changes: 1 addition & 1 deletion access-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static function () use ( $type_name ) {
/**
* Get the facets that are allowed to be queried via GraphQL.
*
* @return array<string, mixed>
* @return array<string,mixed>
*
* @since 0.4.1
*/
Expand Down
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
featureToggles:
disableRuntimeReflectionProvider: true
stubFiles:
Expand Down
28 changes: 14 additions & 14 deletions src/Registry/FacetRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class FacetRegistry {
/**
* The facet configs to register to WPGraphQL
*
* @var ?array
* @var ?array<string,mixed>[]
*/
protected static $facets;

/**
* Gets the facet configs to be registered to WPGraphQL.
*
* @return array<string, mixed>
* @return array<string,mixed>[]
*
* @since 0.4.1
*/
Expand Down Expand Up @@ -59,9 +59,9 @@ static function ( $config ) {
/**
* Gets the GraphQL input type for a facet.
*
* @param array<string, mixed> $config The facet config.
* @param array<string,mixed> $config The facet config.
*
* @return string|array<string, mixed> The GraphQL input type.
* @return string|array<string,mixed> The GraphQL input type.
*
* @since 0.4.1
*/
Expand Down Expand Up @@ -162,7 +162,7 @@ public static function register( string $type ): void {
/**
* Register facet-type root field.
*
* @param array<string, mixed> $facet_config The config array.
* @param array<string,mixed> $facet_config The config array.
*/
private static function register_root_field( array $facet_config ): void {
$type = $facet_config['type'];
Expand Down Expand Up @@ -289,7 +289,7 @@ static function ( $post_ids ) use ( &$filtered_ids ) {
/**
* Register input argument types.
*
* @param array<string, mixed> $facet_config The config array.
* @param array<string,mixed> $facet_config The config array.
*/
private static function register_input_arg_types( array $facet_config ): void {
$field = $facet_config['field'];
Expand Down Expand Up @@ -411,7 +411,7 @@ static function ( $prev, $cur ) {
/**
* Register custom output types.
*
* @param array<string, mixed> $facet_config The config array.
* @param array<string,mixed> $facet_config The config array.
*/
private static function register_custom_output_types( array $facet_config ): void {
$singular = $facet_config['singular'];
Expand Down Expand Up @@ -449,7 +449,7 @@ private static function register_custom_output_types( array $facet_config ): voi
/**
* Register facet-type connection types.
*
* @param array<string, mixed> $facet_config The config array.
* @param array<string,mixed> $facet_config The config array.
*/
private static function register_facet_connection( array $facet_config ): void {
$type = $facet_config['type'];
Expand Down Expand Up @@ -504,9 +504,9 @@ private static function register_facet_connection( array $facet_config ): void {
/**
* Parse WPGraphQL query into FacetWP query
*
* @param array<string, mixed> $query The WPGraphQL query.
* @param array<string,mixed> $query The WPGraphQL query.
*
* @return array<string, mixed> The FacetWP query.
* @return array<string,mixed> The FacetWP query.
*/
private static function parse_query( array $query ): array {
// Bail early if no query set.
Expand Down Expand Up @@ -607,8 +607,8 @@ static function ( $prev, $cur ) use ( $query ) {
*
* @todo move to helper class.
*
* @param string|array<string, string> $input The string or list of strings to convert.
* @return string|array<string, string> The converted string or list of strings.
* @param string|array<string,string> $input The string or list of strings to convert.
* @return string|array<string,string> The converted string or list of strings.
*/
private static function to_camel_case( $input ) {
if ( is_array( $input ) ) {
Expand Down Expand Up @@ -693,9 +693,9 @@ public static function use_graphql_pagination(): bool {
*
* @see \FacetWP_Facet_Sort::parse_sort_facet()
*
* @param array<string, mixed> $facet The facet configuration.
* @param array<string,mixed> $facet The facet configuration.
*
* @return array<string, array<string, mixed>> The parsed sort options.
* @return array<string,array<string,mixed>> The parsed sort options.
*/
private static function parse_sort_facet_options( array $facet ): array {
$sort_options = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Enum/SortOptionsEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static function ( $facet ) {
/**
* Registers the enum type for the provided facet.
*
* @param array<string, mixed> $facet The facet to register the enum type for.
* @param array<string,mixed> $facet The facet to register the enum type for.
*/
public static function register_enum( array $facet ): string {
$name = self::get_type_name( $facet['name'] );
Expand Down
2 changes: 1 addition & 1 deletion src/Type/WPInterface/FacetConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function get_fields(): array {
/**
* {@inheritDoc}
*
* @param array $value The value.
* @param array<string,mixed> $value The value.
*/
public static function get_resolved_type_name( $value ): ?string {
return graphql_format_type_name( $value['type'] ) . 'Facet';
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'hsimah-services/wp-graphql-facetwp',
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'reference' => '6b912ce060b68ed4c8b1c31c882cf70f099e912f',
'reference' => 'c35bbe72d12734aac2a052bd0623d8e3fd12d444',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -22,7 +22,7 @@
'hsimah-services/wp-graphql-facetwp' => array(
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'reference' => '6b912ce060b68ed4c8b1c31c882cf70f099e912f',
'reference' => 'c35bbe72d12734aac2a052bd0623d8e3fd12d444',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down
2 changes: 1 addition & 1 deletion wp-graphql-facetwp.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function graphql_facetwp_constants(): void {
/**
* Checks if all the the required plugins are installed and activated.
*
* @return array<class-string, string> The list of missing dependencies.
* @return array<class-string,string> The list of missing dependencies.
*/
function graphql_facetwp_deps_not_ready(): array {
$wpgraphql_version = '1.6.0';
Expand Down

0 comments on commit eb92a52

Please sign in to comment.