Skip to content

Commit

Permalink
chore: implement strict types and PHPStan rules
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Apr 6, 2024
1 parent 7b23b49 commit 7b186f8
Show file tree
Hide file tree
Showing 305 changed files with 642 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,8 @@
- feat: Add plugin dependency header.
- chore: update Composer deps and lint.
- chore: lock WPBrowser to <3.5.0 to prevent conflicts with Codeception.
- chore: Implement PHPStan strict rules.
- chore: Declare `strict_types` in all PHP files.
- ci: Update GitHub Actions to latest versions.
- ci: Test plugin compatibility with WordPress 6.5.0.
- ci: Test plugin compatibility with PHP 8.2.
Expand Down
17 changes: 16 additions & 1 deletion phpstan.neon.dist
@@ -1,9 +1,24 @@
parameters:
level: 8
checkMissingIterableValueType: false # @todo make true
checkAlwaysTrueCheckTypeFunctionCall: true
checkAlwaysTrueInstanceof: true
checkAlwaysTrueStrictComparison: true
checkExplicitMixedMissingReturn: true
checkFunctionNameCase: true
checkInternalClassCaseSensitivity: true
checkTooWideReturnTypesInProtectedAndPublicMethods: true
inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false
polluteScopeWithAlwaysIterableForeach: false
polluteScopeWithLoopInitialAssignments: false
reportAlwaysTrueInLastCondition: true
reportStaticMethodSignatures: true
reportWrongPhpDocTypeInVarTag: true
treatPhpDocTypesAsCertain: false
featureToggles:
disableRuntimeReflectionProvider: true
dynamicConstantNames:
- WPGRAPHQL_GF_AUTOLOAD
stubFiles:
# Simulate added properties
- phpstan/class-app-context.stub
Expand Down
2 changes: 2 additions & 0 deletions src/Connection/AbstractConnection.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Connection;

use WPGraphQL\GF\Interfaces\Hookable;
Expand Down
2 changes: 2 additions & 0 deletions src/Connection/EntriesConnection.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Connection;

use GraphQL\Error\UserError;
Expand Down
2 changes: 2 additions & 0 deletions src/Connection/FormFieldsConnection.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Connection;

use WPGraphQL\GF\Type\Enum\FormFieldTypeEnum;
Expand Down
2 changes: 2 additions & 0 deletions src/Connection/FormsConnection.php
Expand Up @@ -7,6 +7,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Connection;

use GraphQL\Type\Definition\ResolveInfo;
Expand Down
2 changes: 2 additions & 0 deletions src/CoreSchemaFilters.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF;

use WPGraphQL\GF\Data\Factory;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/Connection/EntriesConnectionResolver.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.0.1
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\Connection;

use GFAPI;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/Connection/FormFieldsConnectionResolver.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\Connection;

use GraphQL\Type\Definition\ResolveInfo;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/Connection/FormsConnectionResolver.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.0.1
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\Connection;

use GFAPI;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/EntryObjectMutation.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/Factory.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data;

use GraphQL\Deferred;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/FieldValueInput/AbstractFieldValueInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GF_Field;
Expand Down
4 changes: 4 additions & 0 deletions src/Data/FieldValueInput/AddressValuesInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

/**
Expand Down Expand Up @@ -35,6 +37,8 @@ protected function get_field_name(): string {

/**
* {@inheritDoc}
*
* @return array
*/
protected function prepare_value() {
$value = $this->args;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/FieldValueInput/CaptchaValueInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.11.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GF_Field;
Expand Down
3 changes: 3 additions & 0 deletions src/Data/FieldValueInput/CheckboxValuesInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GFCommon;
Expand Down Expand Up @@ -39,6 +41,7 @@ protected function get_field_name(): string {
/**
* {@inheritDoc}
*
* @return array
* @throws \GraphQL\Error\UserError .
*/
protected function prepare_value() {
Expand Down
4 changes: 4 additions & 0 deletions src/Data/FieldValueInput/ConsentValueInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GFFormsModel;
Expand Down Expand Up @@ -37,6 +39,8 @@ protected function get_field_name(): string {

/**
* {@inheritDoc}
*
* @return array
*/
protected function prepare_value() {
$field = $this->field;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/FieldValueInput/EmailValuesInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Data/FieldValueInput/FileUploadValuesInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GraphQL\Error\UserError;
Expand Down Expand Up @@ -33,6 +35,8 @@ protected function get_field_name(): string {
* {@inheritDoc}
*
* @throws \GraphQL\Error\UserError
*
* @return string|mixed
*/
protected function prepare_value() {
// Draft entries don't upload files.
Expand Down
4 changes: 4 additions & 0 deletions src/Data/FieldValueInput/ImageValuesInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GF_Field;
Expand Down Expand Up @@ -37,6 +39,8 @@ protected function get_field_name(): string {
/**
* {@inheritDoc}
*
* @return array
*
* @throws \GraphQL\Error\UserError
*/
protected function prepare_value() {
Expand Down
2 changes: 2 additions & 0 deletions src/Data/FieldValueInput/ListValuesInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GraphQL\Error\UserError;
Expand Down
4 changes: 4 additions & 0 deletions src/Data/FieldValueInput/NameValuesInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

/**
Expand Down Expand Up @@ -35,6 +37,8 @@ protected function get_field_name(): string {

/**
* {@inheritDoc}
*
* @return array
*/
protected function prepare_value() {
$value = $this->args;
Expand Down
4 changes: 4 additions & 0 deletions src/Data/FieldValueInput/ProductValueInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.12.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GFCommon;
Expand Down Expand Up @@ -92,6 +94,8 @@ public function get_args() {

/**
* {@inheritDoc}
*
* @return array
*/
protected function prepare_value() {
$field = $this->field;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/FieldValueInput/ValueInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

use GFCommon;
Expand Down
2 changes: 2 additions & 0 deletions src/Data/FieldValueInput/ValuesInput.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\FieldValueInput;

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Data/Loader/DraftEntriesLoader.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\Loader;

use GFFormsModel;
Expand Down Expand Up @@ -45,7 +47,7 @@ protected function get_model( $entry, $key ): DraftEntry {
*
* @param array $keys .
*
* @return array|false
* @return array
* @throws \Exception .
*/
public function loadKeys( array $keys ) {
Expand Down
4 changes: 3 additions & 1 deletion src/Data/Loader/EntriesLoader.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.0.1
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\Loader;

use GFAPI;
Expand Down Expand Up @@ -44,7 +46,7 @@ protected function get_model( $entry, $key ): SubmittedEntry {
*
* @param array $keys .
*
* @return array|false
* @return array
* @throws \Exception .
*/
protected function loadKeys( array $keys ) {
Expand Down
4 changes: 3 additions & 1 deletion src/Data/Loader/FormsLoader.php
Expand Up @@ -8,6 +8,8 @@
* @since 0.0.1
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Data\Loader;

use GFAPI;
Expand Down Expand Up @@ -44,7 +46,7 @@ protected function get_model( $entry, $key ): Form {
*
* @param array $keys .
*
* @return array|false
* @return array
* @throws \Exception .
*/
protected function loadKeys( array $keys ) {
Expand Down
2 changes: 2 additions & 0 deletions src/Extensions/Extensions.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Extensions;

use WPGraphQL\GF\Extensions\GFChainedSelects\GFChainedSelects;
Expand Down
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Extensions\GFChainedSelects\Data\FieldValueInput;

use WPGraphQL\GF\Data\FieldValueInput\CheckboxValuesInput;
Expand Down
2 changes: 2 additions & 0 deletions src/Extensions/GFChainedSelects/GFChainedSelects.php
Expand Up @@ -6,6 +6,8 @@
* @since 0.10.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Extensions\GFChainedSelects;

use GF_Field;
Expand Down
Expand Up @@ -6,6 +6,8 @@
* @since 0.4.0
*/

declare( strict_types = 1 );

namespace WPGraphQL\GF\Extensions\GFChainedSelects\Type\Enum;

use WPGraphQL\GF\Type\Enum\AbstractEnum;
Expand Down

0 comments on commit 7b186f8

Please sign in to comment.