From c5fc61b3cb2cc457cc71e87377efda678ae9d5da Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 19:04:40 -0400 Subject: [PATCH 01/16] New rector rule PreparedValueToEarlyReturnRector --- classes/controllers/FrmAppController.php | 9 +- classes/helpers/FrmAppHelper.php | 10 +- classes/helpers/FrmFieldsHelper.php | 6 +- classes/models/FrmAddon.php | 7 +- classes/models/FrmCreateFile.php | 7 +- classes/models/FrmFormApi.php | 13 +-- classes/models/fields/FrmFieldType.php | 14 +-- composer.json | 2 +- rector.php | 141 ++++++++++++++++++++++- stripe/helpers/FrmTransLiteAppHelper.php | 6 +- 10 files changed, 164 insertions(+), 51 deletions(-) diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index 7e7c650341..5c1ea5a633 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -271,15 +271,14 @@ public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) * @return string */ private static function get_current_page() { - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); - $current_page = isset( $_GET['page'] ) ? $page : $post_type; + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); if ( FrmAppHelper::is_view_builder_page() ) { - $current_page = 'frm_display'; + return 'frm_display'; } - return $current_page; + return isset( $_GET['page'] ) ? $page : $post_type; } /** diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 6b9b699d3e..dcd513d519 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -436,13 +436,12 @@ public static function is_form_builder_page( $check_for_settings = true ) { */ public static function is_formidable_admin() { $page = self::simple_get( 'page', 'sanitize_title' ); - $is_formidable = strpos( $page, 'formidable' ) !== false; if ( empty( $page ) ) { - $is_formidable = self::is_view_builder_page(); + return self::is_view_builder_page(); } - return $is_formidable; + return strpos( $page, 'formidable' ) !== false; } /** @@ -3207,13 +3206,12 @@ private static function add_time_to_date( $time_format, $date ) { } $trimmed_format = trim( $time_format ); - $time = ''; if ( $time_format && ! empty( $trimmed_format ) ) { - $time = ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date ); + return ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date ); } - return $time; + return ''; } /** diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php index 5737492f05..fd366a4f48 100644 --- a/classes/helpers/FrmFieldsHelper.php +++ b/classes/helpers/FrmFieldsHelper.php @@ -751,12 +751,10 @@ private static function hidden_field_option( $field ) { * @return string radio or checkbox */ private static function get_default_value_type( $field ) { - $default_type = $field['type']; - if ( $field['type'] === 'select' ) { - $default_type = FrmField::is_multiple_select( $field ) ? 'checkbox' : 'radio'; + return FrmField::is_multiple_select( $field ) ? 'checkbox' : 'radio'; } - return $default_type; + return $field['type']; } /** diff --git a/classes/models/FrmAddon.php b/classes/models/FrmAddon.php index 659d58e928..98dc94f219 100644 --- a/classes/models/FrmAddon.php +++ b/classes/models/FrmAddon.php @@ -151,13 +151,8 @@ public function insert_installed_addon( $plugins ) { */ public static function get_addon( $plugin_slug ) { $plugins = apply_filters( 'frm_installed_addons', array() ); - $plugin = false; - if ( isset( $plugins[ $plugin_slug ] ) ) { - $plugin = $plugins[ $plugin_slug ]; - } - - return $plugin; + return $plugins[ $plugin_slug ] ?? false; } /** diff --git a/classes/models/FrmCreateFile.php b/classes/models/FrmCreateFile.php index 37c9b6ebab..234d3a652f 100644 --- a/classes/models/FrmCreateFile.php +++ b/classes/models/FrmCreateFile.php @@ -141,13 +141,10 @@ public function combine_files( $file_names ) { * @return string */ public function get_file_contents() { - $content = ''; - if ( $this->has_permission ) { - $content = $this->get_contents(); + return $this->get_contents(); } - - return $content; + return ''; } /** diff --git a/classes/models/FrmFormApi.php b/classes/models/FrmFormApi.php index 976aedef56..6fb584b156 100644 --- a/classes/models/FrmFormApi.php +++ b/classes/models/FrmFormApi.php @@ -369,12 +369,10 @@ protected function set_cached( $addons ) { * @return string */ protected function get_cache_timeout( $addons ) { - $timeout = $this->cache_timeout; - if ( isset( $addons['response_code'] ) && 429 === $addons['response_code'] ) { - $timeout = '+5 minutes'; + return '+5 minutes'; } - return $timeout; + return $this->cache_timeout; } /** @@ -397,13 +395,10 @@ public function reset_cached() { * @return array */ public function error_for_license() { - $errors = array(); - if ( ! empty( $this->license ) ) { - $errors = $this->get_error_from_response(); + return $this->get_error_from_response(); } - - return $errors; + return array(); } /** diff --git a/classes/models/fields/FrmFieldType.php b/classes/models/fields/FrmFieldType.php index 67b9a16d82..d8ba1c1275 100644 --- a/classes/models/fields/FrmFieldType.php +++ b/classes/models/fields/FrmFieldType.php @@ -120,13 +120,10 @@ public function __construct( $field = 0, $type = '' ) { * @return string */ public function __get( $key ) { - $value = ''; - if ( property_exists( $this, $key ) ) { - $value = $this->{$key}; + return $this->{$key}; } - - return $value; + return ''; } /** @@ -433,13 +430,10 @@ protected function default_field_settings() { * @return array */ protected function field_settings_for_type() { - $settings = array(); - if ( ! $this->has_input ) { - $settings = $this->no_input_settings(); + return $this->no_input_settings(); } - - return $settings; + return array(); } /** diff --git a/composer.json b/composer.json index 44a91eea25..e10caf7bc5 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "phpstan/extension-installer": "^1.3", "slevomat/coding-standard": "~8.0", "friendsofphp/php-cs-fixer": "^3.54", - "rector/rector": "^1.0" + "rector/rector": "^2.2.14" }, "config": { "allow-plugins": { diff --git a/rector.php b/rector.php index e498b6ff1b..25ec217b6e 100644 --- a/rector.php +++ b/rector.php @@ -32,6 +32,61 @@ use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector; use Rector\Php53\Rector\Ternary\TernaryToElvisRector; +use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; +use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector; +use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector; +use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanStrictReturnsRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNullableTypeRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector; +use Rector\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector; +use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; +use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector; +use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector; +use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; +use Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector; +use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector; +use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; +use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; +use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector; +use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector; +use Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictStringReturnsRector; +use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector; +use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector; +use Rector\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector; +use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; +use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector; +use Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictReturnsRector; +use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; +use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector; +use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector; +use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector; +use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanConstReturnsRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnCastRector; +use Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictScalarReturnsRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector; +use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; +use Rector\Carbon\Rector\FuncCall\TimeFuncCallToCarbonRector; +use Rector\Carbon\Rector\New_\DateTimeInstanceToCarbonRector; +use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; +use Rector\Php70\Rector\FuncCall\MultiDirnameRector; +use Rector\Strict\Rector\Ternary\BooleanInTernaryOperatorRuleFixerRector; +use Rector\TypeDeclaration\Rector\Class_\ReturnTypeFromStrictTernaryRector; +use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector; +use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector; +use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector; +use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector; +use Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; +use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector; +use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; define( 'ABSPATH', '' ); @@ -48,7 +103,33 @@ // deadCode true, // codeQuality - true + true, + // codingStyle + true, + // typeDeclarations + true, + // privatization + true, + // naming + true, + // instanceOf + true, + // earlyReturn + true, + // strictBooleans + true, + // carbon + true, + // rectorPreset + true, + // phpunitCodeQuality + true, + // doctrineCodeQuality + false, + // symfonyCodeQuality + false, + // symfonyConfigs + false, ) ->withPhpSets( // PHP 8.3 @@ -104,5 +185,63 @@ InlineConstructorDefaultToPropertyRector::class, SimplifyRegexPatternRector::class, RemoveUnusedConstructorParamRector::class, + // Try these + // Enable this one soon. + NewlineAfterStatementRector::class, + RemoveUselessReturnTagRector::class, + ChangeOrIfContinueToMultiContinueRector::class, + RenameVariableToMatchNewTypeRector::class, + AddMethodCallBasedStrictParamTypeRector::class, + AddVoidReturnTypeWhereNoReturnRector::class, + BoolReturnTypeFromBooleanStrictReturnsRector::class, + ReturnNullableTypeRector::class, + ReturnTypeFromReturnDirectArrayRector::class, + ReturnTypeFromStrictNewArrayRector::class, + StrictArrayParamDimFetchRector::class, + DeclareStrictTypesRector::class, + NewlineBeforeNewAssignSetRector::class, + EncapsedStringsToSprintfRector::class, + StrictArraySearchRector::class, + SymplifyQuoteEscapeRector::class, + ReturnEarlyIfVariableRector::class, + RenameVariableToMatchMethodCallReturnTypeRector::class, + BooleanInBooleanNotRuleFixerRector::class, + ReturnTypeFromStrictNativeCallRector::class, + ReturnUnionTypeRector::class, + StringReturnTypeFromStrictStringReturnsRector::class, + ClosureReturnTypeRector::class, + WrapEncapsedVariableInCurlyBracesRector::class, + ReturnTypeFromStrictTypedCallRector::class, + StrictStringParamConcatRector::class, + ReturnBinaryOrToEarlyReturnRector::class, + RenamePropertyToMatchTypeRector::class, + NumericReturnTypeFromStrictReturnsRector::class, + TypedPropertyFromAssignsRector::class, + TypedPropertyFromStrictConstructorRector::class, + AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, + RenameForeachValueVariableToMatchExprVariableRector::class, + BooleanInIfConditionRuleFixerRector::class, + BoolReturnTypeFromBooleanConstReturnsRector::class, + ReturnTypeFromReturnCastRector::class, + StringReturnTypeFromStrictScalarReturnsRector::class, + ReturnTypeFromStrictConstantReturnRector::class, + PostIncDecToPreIncDecRector::class, + TimeFuncCallToCarbonRector::class, + DateTimeInstanceToCarbonRector::class, + ChangeIfElseValueAssignToEarlyReturnRector::class, + MultiDirnameRector::class, + BooleanInTernaryOperatorRuleFixerRector::class, + ReturnTypeFromStrictConstantReturnRector::class, + ReturnTypeFromStrictTernaryRector::class, + AddClosureVoidReturnTypeWhereNoReturnRector::class, + FlipTypeControlToUseExclusiveTypeRector::class, + NullableCompareToNullRector::class, + MakeInheritedMethodVisibilitySameAsParentRector::class, + ReturnTypeFromReturnNewRector::class, + MakeInheritedMethodVisibilitySameAsParentRector::class, + NumericReturnTypeFromStrictScalarReturnsRector::class, + ReturnNeverTypeRector::class, + CallUserFuncArrayToVariadicRector::class, + CatchExceptionNameMatchingTypeRector::class, ) ); diff --git a/stripe/helpers/FrmTransLiteAppHelper.php b/stripe/helpers/FrmTransLiteAppHelper.php index fc42766c0d..377e7085b8 100755 --- a/stripe/helpers/FrmTransLiteAppHelper.php +++ b/stripe/helpers/FrmTransLiteAppHelper.php @@ -380,12 +380,10 @@ public static function format_the_date( $date, $format = '' ) { * @return int */ public static function get_user_id_for_current_payment() { - $user_id = 0; - if ( is_user_logged_in() ) { - $user_id = get_current_user_id(); + return get_current_user_id(); } - return $user_id; + return 0; } /** From f38b5cbcb8774ee1beb7b0db1ce83a8f1b2f3ae9 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 19:07:09 -0400 Subject: [PATCH 02/16] Bump phpstan --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e10caf7bc5..611d4e4d1d 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "wp-coding-standards/wpcs": "^3.0", "automattic/vipwpcs": "^3.0", "squizlabs/php_codesniffer": "^3.10", - "phpstan/phpstan": "^1.4", + "phpstan/phpstan": "^2.1.33", "phpstan/phpstan-strict-rules": "^1.5", "phpstan/extension-installer": "^1.3", "slevomat/coding-standard": "~8.0", From 20c8964c0f3ee9a94ad64fb9f009d2b1be79006e Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 19:10:04 -0400 Subject: [PATCH 03/16] Drop phpstan strict rules for now --- composer.json | 1 - phpstan.neon | 6 ------ 2 files changed, 7 deletions(-) diff --git a/composer.json b/composer.json index 611d4e4d1d..91ea72c682 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,6 @@ "automattic/vipwpcs": "^3.0", "squizlabs/php_codesniffer": "^3.10", "phpstan/phpstan": "^2.1.33", - "phpstan/phpstan-strict-rules": "^1.5", "phpstan/extension-installer": "^1.3", "slevomat/coding-standard": "~8.0", "friendsofphp/php-cs-fixer": "^3.54", diff --git a/phpstan.neon b/phpstan.neon index 70f272a630..01707b0a02 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,12 +15,6 @@ parameters: - */fonts/* - */rector.php - */phpcs-sniffs/* - strictRules: - disallowedLooseComparison: false - booleansInConditions: false - requireParentConstructorCall: false - strictCalls: false - noVariableVariables: false ignoreErrors: - '#Access to an undefined property#' - '#Cannot access (offset|property)+#' From 2d41eebfaea32f2f90377d7e8e548e282a1a8d04 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 20:07:46 -0400 Subject: [PATCH 04/16] Update rector config --- rector.php | 75 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/rector.php b/rector.php index 25ec217b6e..1d4992c542 100644 --- a/rector.php +++ b/rector.php @@ -43,15 +43,11 @@ use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector; use Rector\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector; use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; -use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector; use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector; use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; use Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector; -use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector; use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; -use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector; -use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictStringReturnsRector; @@ -59,24 +55,18 @@ use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector; use Rector\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector; -use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictReturnsRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector; use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector; -use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector; use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanConstReturnsRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnCastRector; use Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictScalarReturnsRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector; use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; -use Rector\Carbon\Rector\FuncCall\TimeFuncCallToCarbonRector; -use Rector\Carbon\Rector\New_\DateTimeInstanceToCarbonRector; -use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; use Rector\Php70\Rector\FuncCall\MultiDirnameRector; -use Rector\Strict\Rector\Ternary\BooleanInTernaryOperatorRuleFixerRector; use Rector\TypeDeclaration\Rector\Class_\ReturnTypeFromStrictTernaryRector; use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector; use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector; @@ -87,6 +77,29 @@ use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector; use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; +use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; +use Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector; +use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; +use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector; +use Rector\CodingStyle\Rector\String_\SimplifyQuoteEscapeRector; +use Rector\Php80\Rector\Identical\StrStartsWithRector; +use Rector\Php80\Rector\NotIdentical\StrContainsRector; +use Rector\TypeDeclarationDocblocks\Rector\ClassMethod\AddParamArrayDocblockFromAssignsParamToParamReferenceRector; +use Rector\TypeDeclarationDocblocks\Rector\ClassMethod\AddParamArrayDocblockFromDimFetchAccessRector; +use Rector\CodeQuality\Rector\BooleanAnd\RepeatedAndNotEqualToNotInArrayRector; +use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector; +use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddParamFromDimFetchKeyUseRector; +use Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector; +use Rector\TypeDeclarationDocblocks\Rector\ClassMethod\DocblockReturnArrayFromDirectArrayInstanceRector; +use Rector\Php80\Rector\Identical\StrEndsWithRector; +use Rector\TypeDeclaration\Rector\FuncCall\AddArrayFunctionClosureParamTypeRector; +use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector; +use Rector\TypeDeclaration\Rector\FuncCall\AddArrowFunctionParamArrayWhereDimFetchRector; +use Rector\CodingStyle\Rector\ClassLike\NewlineBetweenClassLikeStmtsRector; +use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeForArrayMapRector; +use Rector\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddParamStringTypeFromSprintfUseRector; define( 'ABSPATH', '' ); @@ -108,6 +121,8 @@ true, // typeDeclarations true, + // typeDeclarationDocblocks + true, // privatization true, // naming @@ -117,9 +132,9 @@ // earlyReturn true, // strictBooleans - true, + false, // carbon - true, + false, // rectorPreset true, // phpunitCodeQuality @@ -185,11 +200,10 @@ InlineConstructorDefaultToPropertyRector::class, SimplifyRegexPatternRector::class, RemoveUnusedConstructorParamRector::class, - // Try these // Enable this one soon. NewlineAfterStatementRector::class, + // Try these RemoveUselessReturnTagRector::class, - ChangeOrIfContinueToMultiContinueRector::class, RenameVariableToMatchNewTypeRector::class, AddMethodCallBasedStrictParamTypeRector::class, AddVoidReturnTypeWhereNoReturnRector::class, @@ -202,10 +216,7 @@ NewlineBeforeNewAssignSetRector::class, EncapsedStringsToSprintfRector::class, StrictArraySearchRector::class, - SymplifyQuoteEscapeRector::class, - ReturnEarlyIfVariableRector::class, RenameVariableToMatchMethodCallReturnTypeRector::class, - BooleanInBooleanNotRuleFixerRector::class, ReturnTypeFromStrictNativeCallRector::class, ReturnUnionTypeRector::class, StringReturnTypeFromStrictStringReturnsRector::class, @@ -220,17 +231,12 @@ TypedPropertyFromStrictConstructorRector::class, AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, RenameForeachValueVariableToMatchExprVariableRector::class, - BooleanInIfConditionRuleFixerRector::class, BoolReturnTypeFromBooleanConstReturnsRector::class, ReturnTypeFromReturnCastRector::class, StringReturnTypeFromStrictScalarReturnsRector::class, ReturnTypeFromStrictConstantReturnRector::class, PostIncDecToPreIncDecRector::class, - TimeFuncCallToCarbonRector::class, - DateTimeInstanceToCarbonRector::class, - ChangeIfElseValueAssignToEarlyReturnRector::class, MultiDirnameRector::class, - BooleanInTernaryOperatorRuleFixerRector::class, ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictTernaryRector::class, AddClosureVoidReturnTypeWhereNoReturnRector::class, @@ -243,5 +249,30 @@ ReturnNeverTypeRector::class, CallUserFuncArrayToVariadicRector::class, CatchExceptionNameMatchingTypeRector::class, + ReturnBinaryOrToEarlyReturnRector::class, + CompleteMissingIfElseBracketRector::class, + ChangeOrIfContinueToMultiContinueRector::class, + ReturnEarlyIfVariableRector::class, + CompleteMissingIfElseBracketRector::class, + SimplifyQuoteEscapeRector::class, + StrStartsWithRector::class, + StrContainsRector::class, + AddParamArrayDocblockFromAssignsParamToParamReferenceRector::class, + AddParamArrayDocblockFromDimFetchAccessRector::class, + RepeatedAndNotEqualToNotInArrayRector::class, + UseIdenticalOverEqualWithSameTypeRector::class, + ChangeIfElseValueAssignToEarlyReturnRector::class, + AddParamFromDimFetchKeyUseRector::class, + ArrayKeyFirstLastRector::class, + DocblockReturnArrayFromDirectArrayInstanceRector::class, + StrEndsWithRector::class, + AddArrayFunctionClosureParamTypeRector::class, + RenameParamToMatchTypeRector::class, + AddArrowFunctionParamArrayWhereDimFetchRector::class, + NewlineBetweenClassLikeStmtsRector::class, + + AddClosureParamTypeForArrayMapRector::class, + KnownMagicClassMethodTypeRector::class, + AddParamStringTypeFromSprintfUseRector::class, ) ); From a731030f20d10547080d9c5f2b60400f12aa8eb5 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 20:08:40 -0400 Subject: [PATCH 05/16] Remove extra comma --- rector.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rector.php b/rector.php index 1d4992c542..a6bb9629ac 100644 --- a/rector.php +++ b/rector.php @@ -144,7 +144,7 @@ // symfonyCodeQuality false, // symfonyConfigs - false, + false ) ->withPhpSets( // PHP 8.3 @@ -270,7 +270,6 @@ RenameParamToMatchTypeRector::class, AddArrowFunctionParamArrayWhereDimFetchRector::class, NewlineBetweenClassLikeStmtsRector::class, - AddClosureParamTypeForArrayMapRector::class, KnownMagicClassMethodTypeRector::class, AddParamStringTypeFromSprintfUseRector::class, From 713b1a718d1f0318f23b56b5352aafcf6543aabc Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 21:43:46 -0400 Subject: [PATCH 06/16] Update phpstan baseline --- classes/helpers/FrmFieldsHelper.php | 2 +- phpstan.neon | 62 ++++++++----------- .../helpers/FrmStrpLiteSubscriptionHelper.php | 2 +- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php index fd366a4f48..dc7d57b97b 100644 --- a/classes/helpers/FrmFieldsHelper.php +++ b/classes/helpers/FrmFieldsHelper.php @@ -1124,7 +1124,7 @@ private static function trigger_shortcode_atts( $replace_with, $atts ) { } $function = 'atts_' . $included_att; - $replace_with = self::$function( $replace_with, $atts ); + $replace_with = self::$function( $replace_with ); } return $replace_with; } diff --git a/phpstan.neon b/phpstan.neon index 01707b0a02..85e6050ca5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -67,20 +67,6 @@ parameters: - message: '#Cannot use array destructuring on#' path: classes/helpers/FrmStylesHelper.php - - - message: '#should be contravariant with#' - paths: - - classes/helpers/FrmFormsListHelper.php - - classes/models/FrmInstallerSkin.php - - '#Construct empty\(\) is not allowed. Use more strict comparison#' - - - message: '#Foreach overwrites \$ip with its value variable.#' - path: classes/helpers/FrmAppHelper.php - - - message: '#Only numeric types are allowed#' - paths: - - classes/helpers/FrmCSVExportHelper.php - - classes/models/FrmStyle.php - message: '#Call to an undefined method FrmFieldType::get_export_headings#' path: classes/helpers/FrmCSVExportHelper.php @@ -192,7 +178,6 @@ parameters: - classes/helpers/FrmEntriesHelper.php - classes/helpers/FrmEntriesListHelper.php - classes/helpers/FrmFieldsHelper.php - - classes/helpers/FrmFormMigratorsHelper.php - classes/helpers/FrmFormsHelper.php - classes/helpers/FrmListHelper.php - classes/helpers/FrmStylesHelper.php @@ -255,33 +240,38 @@ parameters: - classes/models/fields/FrmFieldUserID.php - classes/views/frm-form-actions/email_action.php - classes/views/styles/components/FrmSliderStyleComponent.php - - classes/views/styles/components/FrmStyleComponent.php - square/controllers/FrmSquareLiteActionsController.php - square/helpers/FrmSquareLiteConnectHelper.php - square/models/FrmSquareLiteSettings.php - stripe/controllers/FrmStrpLiteEventsController.php - stripe/controllers/FrmTransLitePaymentsController.php - - stripe/controllers/FrmTransLiteSubscriptionsController.php - stripe/helpers/FrmStrpLiteAppHelper.php - stripe/helpers/FrmStrpLiteConnectApiAdapter.php - - stripe/helpers/FrmStrpLiteSubscriptionHelper.php - stripe/helpers/FrmTransLiteListHelper.php - stripe/models/FrmStrpLiteSettings.php - - - message: '#results in an error.#' - paths: - - classes/controllers/FrmAddonsController.php - - classes/controllers/FrmAppController.php - - classes/controllers/FrmFormsController.php - - classes/helpers/FrmCSVExportHelper.php - - classes/helpers/FrmFieldsHelper.php - - classes/helpers/FrmFormsHelper.php - - classes/helpers/FrmFormsListHelper.php - - classes/helpers/FrmStylesHelper.php - - classes/helpers/FrmXMLHelper.php - - classes/models/FrmFieldFormHtml.php - - classes/models/FrmHoneypot.php - - classes/models/FrmReviews.php - - classes/models/fields/FrmFieldType.php - - stripe/controllers/FrmStrpLiteAppController.php - - stripe/helpers/FrmStrpLiteSubscriptionHelper.php + - message: '#results in an error.#' + - message: '#Possibly invalid array key type mixed#' + - message: '#of encapsed string cannot be cast to string#' + - message: '#but returns mixed#' + - message: '#mixed given#' + - message: '#cannot be converted to string.#' + - message: '#Cannot access an offset on mixed#' + - message: '#might not exist on#' + - message: '#is not a file or it does not exist#' + - message: '#so it can be removed from the property type#' + - message: '#Cannot use \+\+ on mixed#' + - message: '#Cannot use -- on mixed#' + - message: '#Cannot use array destructuring on mixed#' + - message: '#always exists and is not nullable#' + - message: '#Possibly invalid array key#' + - message: '#should return string but returns float#' + - message: '#on a separate line has no effect#' + - message: '#but returns array#' + - message: '#Cannot clone non-object variable#' + - message: '#so it can be removed from the by-ref type#' + - message: '#function array_map expects#' + - message: '#expects resource#' + - message: '#might not be defined#' + - message: '#expects false, string given#' + - message: '#array given#' + - message: '#Cannot use \+\+ on int\|false#' diff --git a/stripe/helpers/FrmStrpLiteSubscriptionHelper.php b/stripe/helpers/FrmStrpLiteSubscriptionHelper.php index 9f4159587f..352f6170ee 100644 --- a/stripe/helpers/FrmStrpLiteSubscriptionHelper.php +++ b/stripe/helpers/FrmStrpLiteSubscriptionHelper.php @@ -86,7 +86,7 @@ public static function create_new_subscription( $atts ) { * @type string $amount * } * - * @return string Plan id. + * @return false|string Plan id. */ public static function get_plan_from_atts( $atts ) { $action = $atts['action']; From 1bf0c73ca07705e25c21956fc0ac67a9519ad51c Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 21:45:08 -0400 Subject: [PATCH 07/16] Remove duplicate rector rules --- rector.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/rector.php b/rector.php index a6bb9629ac..382a74c6ec 100644 --- a/rector.php +++ b/rector.php @@ -242,15 +242,12 @@ AddClosureVoidReturnTypeWhereNoReturnRector::class, FlipTypeControlToUseExclusiveTypeRector::class, NullableCompareToNullRector::class, - MakeInheritedMethodVisibilitySameAsParentRector::class, ReturnTypeFromReturnNewRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, NumericReturnTypeFromStrictScalarReturnsRector::class, ReturnNeverTypeRector::class, CallUserFuncArrayToVariadicRector::class, CatchExceptionNameMatchingTypeRector::class, - ReturnBinaryOrToEarlyReturnRector::class, - CompleteMissingIfElseBracketRector::class, ChangeOrIfContinueToMultiContinueRector::class, ReturnEarlyIfVariableRector::class, CompleteMissingIfElseBracketRector::class, From df7b1dc1b7e8680b24a38e4b0e8f6d3b93568a49 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 21:49:11 -0400 Subject: [PATCH 08/16] Apply rector to unit tests --- rector.php | 1 + tests/phpunit/base/FrmUnitTest.php | 2 +- tests/phpunit/bootstrap.php | 2 +- tests/phpunit/database/test_FrmMigrate.php | 1 + tests/phpunit/emails/test_FrmEmail.php | 11 +-- .../test_FrmEntriesAJAXSubmitController.php | 1 + .../entries/test_FrmEntriesController.php | 1 + .../phpunit/entries/test_FrmEntriesHelper.php | 1 + .../entries/test_FrmEntriesListHelper.php | 1 + tests/phpunit/entries/test_FrmEntry.php | 1 + .../entries/test_FrmEntryFormatter.php | 1 + tests/phpunit/entries/test_FrmEntryMeta.php | 1 + .../phpunit/entries/test_FrmEntryValidate.php | 1 + .../phpunit/entries/test_FrmPersonalData.php | 7 ++ .../entries/test_FrmShowEntryShortcode.php | 71 ++++--------------- tests/phpunit/fields/test_FrmField.php | 1 + tests/phpunit/fields/test_FrmFieldCombo.php | 1 + .../phpunit/fields/test_FrmFieldFormHtml.php | 1 + .../fields/test_FrmFieldGridHelper.php.php | 7 +- tests/phpunit/fields/test_FrmFieldName.php | 1 + tests/phpunit/fields/test_FrmFieldType.php | 1 + .../phpunit/fields/test_FrmFieldValidate.php | 1 + tests/phpunit/fields/test_FrmFieldsAjax.php | 1 + .../fields/test_FrmFieldsController.php | 1 + tests/phpunit/fields/test_FrmFieldsHelper.php | 1 + tests/phpunit/fields/test_FrmSubmitHelper.php | 1 + tests/phpunit/forms/test_FrmForm.php | 1 + tests/phpunit/forms/test_FrmFormAction.php | 1 + .../phpunit/forms/test_FrmFormsController.php | 9 +-- .../forms/test_FrmFormsControllerAjax.php | 1 + tests/phpunit/forms/test_FrmFormsHelper.php | 1 + .../phpunit/forms/test_FrmOnSubmitAction.php | 1 + tests/phpunit/misc/test_FrmAntiSpam.php | 1 + tests/phpunit/misc/test_FrmAppHelper.php | 11 +-- .../phpunit/misc/test_FrmCSVExportHelper.php | 3 +- .../misc/test_FrmOverlayController.php | 5 -- tests/phpunit/stripe/FrmStrpLiteUnitTest.php | 13 ++-- .../test_FrmTransLiteActionsController.php | 7 +- .../styles/test_FrmStylesController.php | 2 +- tests/phpunit/styles/test_FrmStylesHelper.php | 1 + tests/phpunit/test_ajax.php | 1 + .../shortcodes/test_FrmFieldShortcodes.php | 5 +- 42 files changed, 82 insertions(+), 101 deletions(-) diff --git a/rector.php b/rector.php index 382a74c6ec..2bc29fb1e6 100644 --- a/rector.php +++ b/rector.php @@ -109,6 +109,7 @@ __DIR__ . '/classes', __DIR__ . '/stripe', __DIR__ . '/square', + __DIR__ . '/tests', ) ) // here we can define, what prepared sets of rules will be applied diff --git a/tests/phpunit/base/FrmUnitTest.php b/tests/phpunit/base/FrmUnitTest.php index 862e194986..c0a23d9894 100644 --- a/tests/phpunit/base/FrmUnitTest.php +++ b/tests/phpunit/base/FrmUnitTest.php @@ -601,7 +601,7 @@ public static function generate_xml( $type, $xml_args ) { $path = "{$cwd}/temp.xml"; @chmod( $path, 0755 ); $fw = fopen( $path, 'w' ); - fputs( $fw, $xml, strlen( $xml ) ); + fwrite( $fw, $xml, strlen( $xml ) ); fclose( $fw ); return $path; diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index 67bbe64daf..29e01712af 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -23,7 +23,7 @@ if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) { require getenv( 'WP_DEVELOP_DIR' ) . 'tests/phpunit/includes/bootstrap.php'; } else { - require '../../../../tests/phpunit/includes/bootstrap.php'; + require __DIR__ . '/../../../../tests/phpunit/includes/bootstrap.php'; } require_once __DIR__ . '/base/frm_factory.php'; diff --git a/tests/phpunit/database/test_FrmMigrate.php b/tests/phpunit/database/test_FrmMigrate.php index 03596e4f70..4759e8e8eb 100644 --- a/tests/phpunit/database/test_FrmMigrate.php +++ b/tests/phpunit/database/test_FrmMigrate.php @@ -5,6 +5,7 @@ */ class test_FrmMigrate extends FrmUnitTest { + public $factory; /** * @covers FrmMigrate::upgrade * diff --git a/tests/phpunit/emails/test_FrmEmail.php b/tests/phpunit/emails/test_FrmEmail.php index 929c6e7dcc..539ea32d92 100644 --- a/tests/phpunit/emails/test_FrmEmail.php +++ b/tests/phpunit/emails/test_FrmEmail.php @@ -6,6 +6,7 @@ */ class test_FrmEmail extends FrmUnitTest { + public $factory; /** * @var string */ @@ -430,12 +431,7 @@ public function test_trigger_email_six() { } protected function prepare_subject( $subject ) { - $subject = wp_specialchars_decode( strip_tags( stripslashes( $subject ) ), ENT_QUOTES ); - return $subject; - - // TODO: Run this with the frm_encode_subject filter. - $charset = get_option( 'blog_charset' ); - return '=?' . $charset . '?B?' . base64_encode( $subject ) . '?='; + return wp_specialchars_decode( strip_tags( stripslashes( $subject ) ), ENT_QUOTES ); } protected function get_email_action_for_form( $form_id ) { @@ -507,8 +503,7 @@ public function add_to_emails( $to_emails, $values, $form_id, $args ) { } public function change_email_subject( $subject, $args ) { - $subject = 'New subject'; - return $subject; + return 'New subject'; } public function send_separate_emails( $is_single, $args ) { diff --git a/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php b/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php index 5d0e9030bb..7a7575dc85 100644 --- a/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php +++ b/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php @@ -5,6 +5,7 @@ */ class test_FrmEntriesAJAXSubmitController extends FrmUnitTest { + public $factory; /** * @covers FrmEntriesAJAXSubmitController::maybe_modify_ajax_error */ diff --git a/tests/phpunit/entries/test_FrmEntriesController.php b/tests/phpunit/entries/test_FrmEntriesController.php index 34631df592..8ee7450027 100644 --- a/tests/phpunit/entries/test_FrmEntriesController.php +++ b/tests/phpunit/entries/test_FrmEntriesController.php @@ -5,6 +5,7 @@ */ class test_FrmEntriesController extends FrmUnitTest { + public $factory; /** * @covers FrmEntriesController::delete_entry_after_save * @covers FrmEntriesController::_delete_entry diff --git a/tests/phpunit/entries/test_FrmEntriesHelper.php b/tests/phpunit/entries/test_FrmEntriesHelper.php index 798acf14c0..f2c5adf680 100644 --- a/tests/phpunit/entries/test_FrmEntriesHelper.php +++ b/tests/phpunit/entries/test_FrmEntriesHelper.php @@ -5,6 +5,7 @@ */ class test_FrmEntriesHelper extends FrmUnitTest { + public $factory; /** * @covers FrmEntriesHelper::display_value */ diff --git a/tests/phpunit/entries/test_FrmEntriesListHelper.php b/tests/phpunit/entries/test_FrmEntriesListHelper.php index e36e7aa07e..318cebbcb1 100644 --- a/tests/phpunit/entries/test_FrmEntriesListHelper.php +++ b/tests/phpunit/entries/test_FrmEntriesListHelper.php @@ -5,6 +5,7 @@ */ class test_FrmEntriesListHelper extends FrmUnitTest { + public $factory; /** * @covers FrmEntriesListHelper::column_value */ diff --git a/tests/phpunit/entries/test_FrmEntry.php b/tests/phpunit/entries/test_FrmEntry.php index c6d55c21dc..6774bbcf9e 100644 --- a/tests/phpunit/entries/test_FrmEntry.php +++ b/tests/phpunit/entries/test_FrmEntry.php @@ -5,6 +5,7 @@ */ class test_FrmEntry extends FrmUnitTest { + public $factory; public static function wpSetUpBeforeClass() { $_POST = array(); self::empty_tables(); diff --git a/tests/phpunit/entries/test_FrmEntryFormatter.php b/tests/phpunit/entries/test_FrmEntryFormatter.php index 3ec493d87c..ea76928bfd 100644 --- a/tests/phpunit/entries/test_FrmEntryFormatter.php +++ b/tests/phpunit/entries/test_FrmEntryFormatter.php @@ -5,6 +5,7 @@ */ class test_FrmEntryFormatter extends FrmUnitTest { + public $factory; private $formatter; /** diff --git a/tests/phpunit/entries/test_FrmEntryMeta.php b/tests/phpunit/entries/test_FrmEntryMeta.php index f802402357..e1d00e6afa 100644 --- a/tests/phpunit/entries/test_FrmEntryMeta.php +++ b/tests/phpunit/entries/test_FrmEntryMeta.php @@ -5,6 +5,7 @@ */ class test_FrmEntryMeta extends FrmUnitTest { + public $factory; /** * @covers FrmEntryMeta::update_entry_metas */ diff --git a/tests/phpunit/entries/test_FrmEntryValidate.php b/tests/phpunit/entries/test_FrmEntryValidate.php index 985f6e6c46..1160dc3edf 100644 --- a/tests/phpunit/entries/test_FrmEntryValidate.php +++ b/tests/phpunit/entries/test_FrmEntryValidate.php @@ -6,6 +6,7 @@ */ class test_FrmEntryValidate extends FrmUnitTest { + public $factory; /** * @covers FrmEntryValidate::validate */ diff --git a/tests/phpunit/entries/test_FrmPersonalData.php b/tests/phpunit/entries/test_FrmPersonalData.php index de28329836..5d8d27357d 100644 --- a/tests/phpunit/entries/test_FrmPersonalData.php +++ b/tests/phpunit/entries/test_FrmPersonalData.php @@ -5,6 +5,7 @@ */ class test_FrmPersonalData extends FrmUnitTest { + public $factory; public static function wpSetUpBeforeClass() { $_POST = array(); self::empty_tables(); @@ -61,6 +62,12 @@ private function create_entries_for_user( $entry_data, $email ) { return $entry_ids; } + /** + * @param mixed $entry_data + * @param mixed $email + * + * @return string[] + */ private function create_entries_for_email( $entry_data, $email ) { $email_field = $this->factory->field->get_id_by_key( 'contact-email' ); diff --git a/tests/phpunit/entries/test_FrmShowEntryShortcode.php b/tests/phpunit/entries/test_FrmShowEntryShortcode.php index e76e3d4575..ba9a1f7a8d 100644 --- a/tests/phpunit/entries/test_FrmShowEntryShortcode.php +++ b/tests/phpunit/entries/test_FrmShowEntryShortcode.php @@ -10,6 +10,7 @@ */ class test_FrmShowEntryShortcode extends FrmUnitTest { + public $factory; public static function wpSetUpBeforeClass() { $_POST = array(); self::empty_tables(); @@ -27,8 +28,6 @@ public static function wpSetUpBeforeClass() { protected $is_repeater_child = false; public function __construct() { - parent::__construct(); - $defaults = $this->get_defaults(); $this->td_style = str_replace( '#1D2939', $defaults['text_color'], $this->td_style ); $this->td_style = str_replace( '#cccccc', $defaults['border_color'], $this->td_style ); @@ -756,9 +755,7 @@ protected function expected_html_content( $atts ) { $table .= $this->user_info_rows( $atts ); - $table .= $this->table_footer(); - - return $table; + return $table . $this->table_footer(); } protected function expected_plain_text_content( $atts ) { @@ -774,9 +771,7 @@ protected function expected_plain_text_content( $atts ) { $content .= $this->label_and_value_plain_text_row( 'free-hidden-field', $atts ); $content .= $this->single_value_plain_text_row( 'free-html-field', $atts ); - $content .= $this->user_info_plain_text_rows( $atts ); - - return $content; + return $content . $this->user_info_plain_text_rows( $atts ); } protected function table_header( $atts ) { @@ -797,9 +792,7 @@ protected function table_header( $atts ) { $header .= 'border-bottom:' . $border_width . ' solid ' . $border_color . ';"'; } - $header .= '>' . "\r\n"; - - return $header; + return $header . '>' . "\r\n"; } protected function get_defaults() { @@ -844,9 +837,7 @@ protected function two_cell_table_row_for_value( $label, $field_value, $atts ) { $html .= $field_value; } - $html .= '' . "\r\n"; - - return $html; + return $html . '' . "\r\n"; } protected function one_cell_table_row( $field_key, $atts ) { @@ -859,9 +850,8 @@ protected function one_cell_table_row( $field_key, $atts ) { $html = 'tr_style . '>'; $html .= 'td_style . '>' . $field_value . ''; - $html .= '' . "\r\n"; - return $html; + return $html . '' . "\r\n"; } protected function label_and_value_plain_text_row( $field_key, $atts ) { @@ -878,9 +868,7 @@ protected function label_and_value_plain_text_row( $field_key, $atts ) { $content = $field->name . ': ' . $field_value; } - $content .= "\r\n"; - - return $content; + return $content . "\r\n"; } protected function single_value_plain_text_row( $field_key, $atts ) { @@ -891,9 +879,7 @@ protected function single_value_plain_text_row( $field_key, $atts ) { return ''; } - $content = $field_value . "\r\n"; - - return $content; + return $field_value . "\r\n"; } /** @@ -910,7 +896,7 @@ protected function is_field_included( $atts, $field, $field_value ) { $include = in_array( $field->type, $this->include_extras, true ); } - if ( $include === true ) { + if ( $include ) { if ( ! empty( $this->include_fields ) ) { $include = $this->is_self_or_parent_in_array( $field->field_key, $this->include_fields ); } elseif ( ! empty( $this->exclude_fields ) ) { @@ -957,15 +943,12 @@ protected function user_info_plain_text_rows( $atts ) { protected function get_field_html_value( $entry, $field, $atts ) { $field_value = $this->get_field_value( $entry, $field, $atts ); - $field_value = str_replace( array( "\r\n", "\n" ), '
', $field_value ); - return $field_value; + return str_replace( array( "\r\n", "\n" ), '
', $field_value ); } protected function get_field_plain_text_value( $entry, $field, $atts ) { - $field_value = $this->get_field_value( $entry, $field, $atts ); - - return $field_value; + return $this->get_field_value( $entry, $field, $atts ); } /** @@ -1101,43 +1084,19 @@ protected function get_expected_default_shortcodes( $type, $atts ) { } protected function table_row_start_tags( $type, $field ) { - if ( $type === 'html' ) { - $html = 'td_style . '>'; - } else { - $html = ''; - } - - return $html; + return $type === 'html' ? 'td_style . '>' : ''; } protected function cell_separator( $type ) { - if ( $type === 'html' ) { - $html = 'td_style . '>'; - } else { - $html = ': '; - } - - return $html; + return $type === 'html' ? 'td_style . '>' : ': '; } protected function table_row_end_tags( $type ) { - if ( $type === 'html' ) { - $html = ''; - } else { - $html = ''; - } - - return $html; + return $type === 'html' ? '' : ''; } protected function after_table_row_tags( $type ) { - if ( $type === 'html' ) { - $html = "\r\n"; - } else { - $html = ''; - } - - return $html; + return $type === 'html' ? "\r\n" : ''; } protected function expected_default_array( $atts ) { diff --git a/tests/phpunit/fields/test_FrmField.php b/tests/phpunit/fields/test_FrmField.php index a1d334d196..efc6e9bfe5 100644 --- a/tests/phpunit/fields/test_FrmField.php +++ b/tests/phpunit/fields/test_FrmField.php @@ -5,6 +5,7 @@ */ class test_FrmField extends FrmUnitTest { + public $factory; public static function wpSetUpBeforeClass() { $_POST = array(); self::empty_tables(); diff --git a/tests/phpunit/fields/test_FrmFieldCombo.php b/tests/phpunit/fields/test_FrmFieldCombo.php index 00ab9ac404..9eba66da03 100644 --- a/tests/phpunit/fields/test_FrmFieldCombo.php +++ b/tests/phpunit/fields/test_FrmFieldCombo.php @@ -5,6 +5,7 @@ */ class test_FrmFieldCombo extends FrmUnitTest { + public $factory; protected function get_combo_field_without_sub_field_options() { $combo_field = new FrmFieldCombo(); diff --git a/tests/phpunit/fields/test_FrmFieldFormHtml.php b/tests/phpunit/fields/test_FrmFieldFormHtml.php index 4dd34d7a9e..7898b1c730 100644 --- a/tests/phpunit/fields/test_FrmFieldFormHtml.php +++ b/tests/phpunit/fields/test_FrmFieldFormHtml.php @@ -3,6 +3,7 @@ * @group fields */ class test_FrmFieldFormHtml extends FrmUnitTest { + public $factory; /** * @covers FrmFieldFormHtml::add_multiple_input_attributes */ diff --git a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php index bc77e30554..6b954b157c 100644 --- a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php +++ b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php @@ -5,6 +5,7 @@ */ class test_FrmFieldGridHelper extends FrmUnitTest { + public $factory; private $form_id; private $helper; @@ -83,9 +84,9 @@ private function create_field_with_classes( $type, $classes = '' ) { } public function test_with_sections() { - $this->form_id = $this->factory->form->create(); - $half_width_field = $this->create_field_with_classes( 'text', 'frm_half' ); - $quarter_width_field = $this->create_field_with_classes( 'text', 'frm_fourth' ); + $this->form_id = $this->factory->form->create(); + $half_width_field = $this->create_field_with_classes( 'text', 'frm_half' ); + $this->create_field_with_classes( 'text', 'frm_fourth' ); $half_width_section = $this->create_field_with_classes( 'divider', 'frm_half' ); $quarter_width_section = $this->create_field_with_classes( 'divider', 'frm_fourth' ); $end_divider = $this->create_field_with_classes( 'end_divider' ); diff --git a/tests/phpunit/fields/test_FrmFieldName.php b/tests/phpunit/fields/test_FrmFieldName.php index b7d9421d10..05585fe186 100644 --- a/tests/phpunit/fields/test_FrmFieldName.php +++ b/tests/phpunit/fields/test_FrmFieldName.php @@ -5,6 +5,7 @@ */ class test_FrmFieldName extends FrmUnitTest { + public $factory; public function test_get_processed_sub_fields() { $field = $this->factory->field->create_and_get( array( diff --git a/tests/phpunit/fields/test_FrmFieldType.php b/tests/phpunit/fields/test_FrmFieldType.php index 3ad13fa957..0b5797b5e8 100644 --- a/tests/phpunit/fields/test_FrmFieldType.php +++ b/tests/phpunit/fields/test_FrmFieldType.php @@ -5,6 +5,7 @@ */ class test_FrmFieldType extends FrmUnitTest { + public $factory; /** * @covers FrmFieldNumber::add_min_max */ diff --git a/tests/phpunit/fields/test_FrmFieldValidate.php b/tests/phpunit/fields/test_FrmFieldValidate.php index 7d9e6de3d5..2afe9bfe5f 100644 --- a/tests/phpunit/fields/test_FrmFieldValidate.php +++ b/tests/phpunit/fields/test_FrmFieldValidate.php @@ -5,6 +5,7 @@ */ class test_FrmFieldValidate extends FrmUnitTest { + public $factory; protected $form; public function setUp(): void { diff --git a/tests/phpunit/fields/test_FrmFieldsAjax.php b/tests/phpunit/fields/test_FrmFieldsAjax.php index 911b33914f..e039a98d42 100644 --- a/tests/phpunit/fields/test_FrmFieldsAjax.php +++ b/tests/phpunit/fields/test_FrmFieldsAjax.php @@ -6,6 +6,7 @@ */ class test_FrmFieldsAjax extends FrmAjaxUnitTest { + public $factory; protected $form_id = 0; protected $user_id = 0; diff --git a/tests/phpunit/fields/test_FrmFieldsController.php b/tests/phpunit/fields/test_FrmFieldsController.php index b58e97a270..6b1f523421 100644 --- a/tests/phpunit/fields/test_FrmFieldsController.php +++ b/tests/phpunit/fields/test_FrmFieldsController.php @@ -5,6 +5,7 @@ */ class test_FrmFieldsController extends FrmUnitTest { + public $factory; /** * @covers FrmFieldsController::prepare_placeholder */ diff --git a/tests/phpunit/fields/test_FrmFieldsHelper.php b/tests/phpunit/fields/test_FrmFieldsHelper.php index 758b2f787f..d1e1773409 100644 --- a/tests/phpunit/fields/test_FrmFieldsHelper.php +++ b/tests/phpunit/fields/test_FrmFieldsHelper.php @@ -7,6 +7,7 @@ */ class test_FrmFieldsHelper extends FrmUnitTest { + public $factory; /** * Tests where $observed_value is a single value, not an array. * diff --git a/tests/phpunit/fields/test_FrmSubmitHelper.php b/tests/phpunit/fields/test_FrmSubmitHelper.php index 96138ef803..0523d689eb 100644 --- a/tests/phpunit/fields/test_FrmSubmitHelper.php +++ b/tests/phpunit/fields/test_FrmSubmitHelper.php @@ -2,6 +2,7 @@ class test_FrmSubmitHelper extends FrmUnitTest { + public $factory; public function test_copy_submit_field_settings_to_form() { $form = $this->factory->form->create_and_get(); $this->assertEquals( $form, FrmSubmitHelper::copy_submit_field_settings_to_form( $form ) ); diff --git a/tests/phpunit/forms/test_FrmForm.php b/tests/phpunit/forms/test_FrmForm.php index daf2c08ba8..735e9f1182 100644 --- a/tests/phpunit/forms/test_FrmForm.php +++ b/tests/phpunit/forms/test_FrmForm.php @@ -5,6 +5,7 @@ */ class test_FrmForm extends FrmUnitTest { + public $factory; public function setUp(): void { parent::setUp(); $this->create_users(); diff --git a/tests/phpunit/forms/test_FrmFormAction.php b/tests/phpunit/forms/test_FrmFormAction.php index 5f9c027d7f..20f4d790ad 100644 --- a/tests/phpunit/forms/test_FrmFormAction.php +++ b/tests/phpunit/forms/test_FrmFormAction.php @@ -5,6 +5,7 @@ */ class test_FrmFormAction extends FrmUnitTest { + public $factory; /** * @covers FrmFormAction::update_callback */ diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index bf4569ab40..b4f6160cd9 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -6,6 +6,7 @@ */ class test_FrmFormsController extends FrmUnitTest { + public $factory; public function test_register_widgets() { global $wp_widget_factory; $this->assertTrue( isset( $wp_widget_factory->widgets['FrmShowForm'] ) ); @@ -53,7 +54,7 @@ public function test_form_update_no_ajax() { ob_start(); FrmFormsController::update(); - $html = ob_get_contents(); + ob_get_contents(); ob_end_clean(); self::_check_updated_values( $form_id ); @@ -111,11 +112,7 @@ private function _setup_post_values( $form_id ) { * Make sure DOING_AJAX is false. */ private function _check_doing_ajax() { - if ( defined( 'DOING_AJAX' ) ) { - $doing_ajax = true; - } else { - $doing_ajax = false; - } + $doing_ajax = defined( 'DOING_AJAX' ); $this->assertFalse( $doing_ajax, 'DOING_AJAX must be false for this test to work. Maybe run this test individually to make sure DOING_AJAX is false.' ); } diff --git a/tests/phpunit/forms/test_FrmFormsControllerAjax.php b/tests/phpunit/forms/test_FrmFormsControllerAjax.php index b6f3eed959..3549618da6 100644 --- a/tests/phpunit/forms/test_FrmFormsControllerAjax.php +++ b/tests/phpunit/forms/test_FrmFormsControllerAjax.php @@ -5,6 +5,7 @@ */ class test_FrmFormsControllerAjax extends FrmAjaxUnitTest { + public $factory; public function setUp(): void { parent::setUp(); diff --git a/tests/phpunit/forms/test_FrmFormsHelper.php b/tests/phpunit/forms/test_FrmFormsHelper.php index 989c55da6b..8a21a392fb 100644 --- a/tests/phpunit/forms/test_FrmFormsHelper.php +++ b/tests/phpunit/forms/test_FrmFormsHelper.php @@ -5,6 +5,7 @@ */ class test_FrmFormsHelper extends FrmUnitTest { + public $factory; /** * @var stdClass|null */ diff --git a/tests/phpunit/forms/test_FrmOnSubmitAction.php b/tests/phpunit/forms/test_FrmOnSubmitAction.php index 0b74e560f6..f835b59190 100644 --- a/tests/phpunit/forms/test_FrmOnSubmitAction.php +++ b/tests/phpunit/forms/test_FrmOnSubmitAction.php @@ -5,6 +5,7 @@ */ class test_FrmOnSubmitAction extends FrmUnitTest { + public $factory; public function test_adding_sanitize_url_after_updating() { $form_id = $this->factory->form->create(); $field_id = $this->factory->field->create( diff --git a/tests/phpunit/misc/test_FrmAntiSpam.php b/tests/phpunit/misc/test_FrmAntiSpam.php index 1a5a322014..8ccd6bd9de 100644 --- a/tests/phpunit/misc/test_FrmAntiSpam.php +++ b/tests/phpunit/misc/test_FrmAntiSpam.php @@ -5,6 +5,7 @@ */ class test_FrmAntiSpam extends FrmUnitTest { + private $factory; private $antispam; public function setUp(): void { diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index de3204ffc3..12d7c90cb5 100644 --- a/tests/phpunit/misc/test_FrmAppHelper.php +++ b/tests/phpunit/misc/test_FrmAppHelper.php @@ -4,6 +4,7 @@ */ class test_FrmAppHelper extends FrmUnitTest { + public $factory; public function setUp(): void { parent::setUp(); $this->create_users(); @@ -566,7 +567,7 @@ public function test_get_unique_key() { $key = FrmAppHelper::get_unique_key( $name, $table_name, $column ); $this->assertEquals( $name . 3, $key, 'Key value should increment' ); - add_filter( 'frm_unique_field_key_separator', array( __CLASS__, 'underscore_key_separator' ) ); + add_filter( 'frm_unique_field_key_separator', array( self::class, 'underscore_key_separator' ) ); $key = FrmAppHelper::get_unique_key( $name, $table_name, $column ); $this->assertNotEquals( $name, $key, 'Field key should be unique' ); @@ -574,7 +575,7 @@ public function test_get_unique_key() { $this->assertEquals( strlen( $name ) + 4, strlen( $key ), 'Field key should be the previous key + 3 character separator + "2" incremented counter value' ); $this->assertEquals( $name . '___2', $key ); - remove_filter( 'frm_unique_field_key_separator', array( __CLASS__, 'underscore_key_separator' ) ); + remove_filter( 'frm_unique_field_key_separator', array( self::class, 'underscore_key_separator' ) ); // Test form keys $table_name = 'frm_forms'; @@ -620,7 +621,7 @@ public function test_count_decimals() { * @covers FrmAppHelper::get_ip_address */ public function test_get_ip_address() { - $ip_address = FrmAppHelper::get_ip_address(); + FrmAppHelper::get_ip_address(); $this->assertEquals( $_SERVER['REMOTE_ADDR'], FrmAppHelper::get_ip_address() ); @@ -696,13 +697,13 @@ public function test_clip() { $this->assertEquals( '
My html
', $html ); // Test a callable string. - $echo_function = __CLASS__ . '::echo_function'; + $echo_function = self::class . '::echo_function'; $html = FrmAppHelper::clip( $echo_function ); $this->assertEquals( '
My echo function content
', $html ); // Test something uncallable. // Make sure it isn't fatal just in case. - $echo_function = __CLASS__ . '::something_uncallable'; + $echo_function = self::class . '::something_uncallable'; $html = FrmAppHelper::clip( $echo_function ); $this->assertEquals( '', $html ); } diff --git a/tests/phpunit/misc/test_FrmCSVExportHelper.php b/tests/phpunit/misc/test_FrmCSVExportHelper.php index 4ce01b581b..a42348e084 100644 --- a/tests/phpunit/misc/test_FrmCSVExportHelper.php +++ b/tests/phpunit/misc/test_FrmCSVExportHelper.php @@ -4,6 +4,7 @@ */ class test_FrmCSVExportHelper extends FrmUnitTest { + public $factory; private $form; /** @@ -94,7 +95,7 @@ public function test_csv_headings_for_embedded_sections() { ); $parent_form = $this->factory->form->create_and_get(); - $embed_field = $this->factory->field->create_and_get( + $this->factory->field->create_and_get( array( 'form_id' => $parent_form->id, 'type' => 'embed', diff --git a/tests/phpunit/misc/test_FrmOverlayController.php b/tests/phpunit/misc/test_FrmOverlayController.php index b1f3f253d2..32e78759b6 100644 --- a/tests/phpunit/misc/test_FrmOverlayController.php +++ b/tests/phpunit/misc/test_FrmOverlayController.php @@ -2,13 +2,8 @@ class test_FrmOverlayController extends FrmUnitTest { - private $time_mock; - public function setUp(): void { parent::setUp(); - $this->time_mock = $this->getMockBuilder( 'FrmOverlayController' ) - ->setMethods( array( 'time', 'strtotime', 'date' ) ) - ->getMock(); } public function test_open_overlay() { diff --git a/tests/phpunit/stripe/FrmStrpLiteUnitTest.php b/tests/phpunit/stripe/FrmStrpLiteUnitTest.php index 0884597910..80b153e7d1 100644 --- a/tests/phpunit/stripe/FrmStrpLiteUnitTest.php +++ b/tests/phpunit/stripe/FrmStrpLiteUnitTest.php @@ -2,6 +2,7 @@ class FrmStrpLiteUnitTest extends FrmUnitTest { + public $factory; public static function wpSetUpBeforeClass() { parent::wpSetUpBeforeClass(); self::empty_tables(); @@ -234,10 +235,7 @@ protected function get_test_credit_card() { * @return string */ protected function get_test_credit_card_number() { - if ( isset( $this->use_test_credit_card_number ) ) { - return $this->use_test_credit_card_number; - } - return '4242424242424242'; + return $this->use_test_credit_card_number ?? '4242424242424242'; } /** @@ -291,7 +289,7 @@ protected function create_payment_method() { 'card' => $this->get_test_credit_card(), ); - $account_details = $this->get_stripe_account_id_details( $this->account_id ); + $account_details = $this->get_stripe_account_id_details(); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase return $stripe->paymentMethods->create( $card_details, $account_details ); @@ -303,13 +301,12 @@ protected function create_payment_method() { protected function prepare_new_charge_array() { $customer_id = $this->get_customer_id(); $this->add_card( $customer_id ); - $new_charge = array( + return array( 'customer' => $customer_id, 'currency' => 'usd', 'amount' => 1000, 'capture' => false, ); - return $new_charge; } protected function assert_run_new_charge( $charge ) { @@ -452,7 +449,7 @@ protected function get_simple_stripe_action() { * @return false|string */ protected function maybe_create_plan() { - $customer = $this->get_customer(); + $this->get_customer(); $plan = $this->get_plan_options(); return FrmStrpLiteSubscriptionHelper::maybe_create_plan( $plan ); } diff --git a/tests/phpunit/stripe/test_FrmTransLiteActionsController.php b/tests/phpunit/stripe/test_FrmTransLiteActionsController.php index 15257420de..2d8a60abb3 100644 --- a/tests/phpunit/stripe/test_FrmTransLiteActionsController.php +++ b/tests/phpunit/stripe/test_FrmTransLiteActionsController.php @@ -5,6 +5,7 @@ */ class test_FrmTransLiteActionsController extends FrmUnitTest { + public $factory; public function test_get_fields_for_price() { $form_id = $this->factory->form->create(); $field_id = $this->factory->field->create( @@ -14,7 +15,7 @@ public function test_get_fields_for_price() { ) ); - $action_id = $this->factory->post->create( + $this->factory->post->create( array( 'post_content' => json_encode( array( @@ -27,8 +28,8 @@ public function test_get_fields_for_price() { 'post_excerpt' => 'payment', ) ); - $actions = FrmTransLiteActionsController::get_actions_for_form( $form_id ); - $action = reset( $actions ); + $actions = FrmTransLiteActionsController::get_actions_for_form( $form_id ); + $action = reset( $actions ); $fields = $this->get_fields_for_price( $action ); diff --git a/tests/phpunit/styles/test_FrmStylesController.php b/tests/phpunit/styles/test_FrmStylesController.php index 07b49b99c3..72c8f7ee31 100644 --- a/tests/phpunit/styles/test_FrmStylesController.php +++ b/tests/phpunit/styles/test_FrmStylesController.php @@ -57,7 +57,7 @@ private function get_custom_stylesheet() { public function test_save() { $frm_style = new FrmStyle( 'default' ); $style = $frm_style->get_one(); - $defaults = $frm_style->get_defaults(); + $frm_style->get_defaults(); $_POST = array( 'ID' => $style->ID, diff --git a/tests/phpunit/styles/test_FrmStylesHelper.php b/tests/phpunit/styles/test_FrmStylesHelper.php index 27728d0aad..b0559d0d4a 100644 --- a/tests/phpunit/styles/test_FrmStylesHelper.php +++ b/tests/phpunit/styles/test_FrmStylesHelper.php @@ -5,6 +5,7 @@ */ class test_FrmStylesHelper extends FrmUnitTest { + public $factory; /** * @covers FrmStylesHelper::get_upload_base */ diff --git a/tests/phpunit/test_ajax.php b/tests/phpunit/test_ajax.php index a558054fd5..9540825e18 100644 --- a/tests/phpunit/test_ajax.php +++ b/tests/phpunit/test_ajax.php @@ -4,6 +4,7 @@ */ class Tests_Frm_Ajax extends FrmAjaxUnitTest { + public $factory; public function test_plugin_activated() { $this->assertTrue( is_plugin_active( 'formidable/formidable.php' ) ); } diff --git a/tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php b/tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php index 5edd3422e8..25eab73ab6 100644 --- a/tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php +++ b/tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php @@ -7,6 +7,7 @@ */ class test_FrmFieldShortcodes extends FrmUnitTest { + public $factory; protected $test_form; protected $test_entry; @@ -71,7 +72,7 @@ protected function expected_free_meta() { } protected function get_expected_field_values() { - $expected = array( + return array( 'free-text-field' => 'Test Testerson', 'free-paragraph-field' => "

Test
\nMiddle
\nTesterson

\n", 'free-checkboxes' => 'Red, Green', @@ -84,8 +85,6 @@ protected function get_expected_field_values() { 'free-hidden-field' => '', 'free-user-id-field' => '', ); - - return $expected; } protected function get_actual_value( $value ) { From 840615038d77fc795be690b0036ba0f11c305128 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 21:53:47 -0400 Subject: [PATCH 09/16] Revert test bootstrap change --- tests/phpunit/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index 29e01712af..67bbe64daf 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -23,7 +23,7 @@ if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) { require getenv( 'WP_DEVELOP_DIR' ) . 'tests/phpunit/includes/bootstrap.php'; } else { - require __DIR__ . '/../../../../tests/phpunit/includes/bootstrap.php'; + require '../../../../tests/phpunit/includes/bootstrap.php'; } require_once __DIR__ . '/base/frm_factory.php'; From 16e42f154c44ec8f3c63f8da7682077a57c3d55a Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 21:58:56 -0400 Subject: [PATCH 10/16] Revert some unit test changes --- tests/phpunit/database/test_FrmMigrate.php | 1 - tests/phpunit/emails/test_FrmEmail.php | 1 - tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php | 1 - tests/phpunit/entries/test_FrmEntriesController.php | 1 - tests/phpunit/entries/test_FrmEntriesHelper.php | 1 - tests/phpunit/entries/test_FrmEntriesListHelper.php | 1 - tests/phpunit/entries/test_FrmEntry.php | 1 - tests/phpunit/entries/test_FrmEntryFormatter.php | 1 - tests/phpunit/entries/test_FrmEntryMeta.php | 1 - tests/phpunit/entries/test_FrmEntryValidate.php | 1 - tests/phpunit/entries/test_FrmPersonalData.php | 1 - tests/phpunit/entries/test_FrmShowEntryShortcode.php | 1 - tests/phpunit/fields/test_FrmField.php | 1 - tests/phpunit/fields/test_FrmFieldCombo.php | 1 - tests/phpunit/fields/test_FrmFieldFormHtml.php | 1 - tests/phpunit/fields/test_FrmFieldGridHelper.php.php | 1 - tests/phpunit/fields/test_FrmFieldName.php | 1 - tests/phpunit/fields/test_FrmFieldType.php | 1 - tests/phpunit/fields/test_FrmFieldValidate.php | 1 - tests/phpunit/fields/test_FrmFieldsAjax.php | 1 - tests/phpunit/fields/test_FrmFieldsController.php | 1 - tests/phpunit/fields/test_FrmFieldsHelper.php | 1 - tests/phpunit/fields/test_FrmSubmitHelper.php | 1 - tests/phpunit/forms/test_FrmForm.php | 1 - tests/phpunit/forms/test_FrmFormAction.php | 1 - tests/phpunit/forms/test_FrmFormsController.php | 1 - tests/phpunit/forms/test_FrmFormsControllerAjax.php | 1 - tests/phpunit/forms/test_FrmFormsHelper.php | 1 - tests/phpunit/forms/test_FrmOnSubmitAction.php | 1 - tests/phpunit/misc/test_FrmAppHelper.php | 1 - tests/phpunit/misc/test_FrmCSVExportHelper.php | 1 - tests/phpunit/stripe/FrmStrpLiteUnitTest.php | 1 - tests/phpunit/stripe/test_FrmTransLiteActionsController.php | 1 - tests/phpunit/styles/test_FrmStylesHelper.php | 1 - tests/phpunit/test_ajax.php | 1 - tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php | 1 - 36 files changed, 36 deletions(-) diff --git a/tests/phpunit/database/test_FrmMigrate.php b/tests/phpunit/database/test_FrmMigrate.php index 4759e8e8eb..03596e4f70 100644 --- a/tests/phpunit/database/test_FrmMigrate.php +++ b/tests/phpunit/database/test_FrmMigrate.php @@ -5,7 +5,6 @@ */ class test_FrmMigrate extends FrmUnitTest { - public $factory; /** * @covers FrmMigrate::upgrade * diff --git a/tests/phpunit/emails/test_FrmEmail.php b/tests/phpunit/emails/test_FrmEmail.php index 539ea32d92..3a2e042b5b 100644 --- a/tests/phpunit/emails/test_FrmEmail.php +++ b/tests/phpunit/emails/test_FrmEmail.php @@ -6,7 +6,6 @@ */ class test_FrmEmail extends FrmUnitTest { - public $factory; /** * @var string */ diff --git a/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php b/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php index 7a7575dc85..5d0e9030bb 100644 --- a/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php +++ b/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php @@ -5,7 +5,6 @@ */ class test_FrmEntriesAJAXSubmitController extends FrmUnitTest { - public $factory; /** * @covers FrmEntriesAJAXSubmitController::maybe_modify_ajax_error */ diff --git a/tests/phpunit/entries/test_FrmEntriesController.php b/tests/phpunit/entries/test_FrmEntriesController.php index 8ee7450027..34631df592 100644 --- a/tests/phpunit/entries/test_FrmEntriesController.php +++ b/tests/phpunit/entries/test_FrmEntriesController.php @@ -5,7 +5,6 @@ */ class test_FrmEntriesController extends FrmUnitTest { - public $factory; /** * @covers FrmEntriesController::delete_entry_after_save * @covers FrmEntriesController::_delete_entry diff --git a/tests/phpunit/entries/test_FrmEntriesHelper.php b/tests/phpunit/entries/test_FrmEntriesHelper.php index f2c5adf680..798acf14c0 100644 --- a/tests/phpunit/entries/test_FrmEntriesHelper.php +++ b/tests/phpunit/entries/test_FrmEntriesHelper.php @@ -5,7 +5,6 @@ */ class test_FrmEntriesHelper extends FrmUnitTest { - public $factory; /** * @covers FrmEntriesHelper::display_value */ diff --git a/tests/phpunit/entries/test_FrmEntriesListHelper.php b/tests/phpunit/entries/test_FrmEntriesListHelper.php index 318cebbcb1..e36e7aa07e 100644 --- a/tests/phpunit/entries/test_FrmEntriesListHelper.php +++ b/tests/phpunit/entries/test_FrmEntriesListHelper.php @@ -5,7 +5,6 @@ */ class test_FrmEntriesListHelper extends FrmUnitTest { - public $factory; /** * @covers FrmEntriesListHelper::column_value */ diff --git a/tests/phpunit/entries/test_FrmEntry.php b/tests/phpunit/entries/test_FrmEntry.php index 6774bbcf9e..c6d55c21dc 100644 --- a/tests/phpunit/entries/test_FrmEntry.php +++ b/tests/phpunit/entries/test_FrmEntry.php @@ -5,7 +5,6 @@ */ class test_FrmEntry extends FrmUnitTest { - public $factory; public static function wpSetUpBeforeClass() { $_POST = array(); self::empty_tables(); diff --git a/tests/phpunit/entries/test_FrmEntryFormatter.php b/tests/phpunit/entries/test_FrmEntryFormatter.php index ea76928bfd..3ec493d87c 100644 --- a/tests/phpunit/entries/test_FrmEntryFormatter.php +++ b/tests/phpunit/entries/test_FrmEntryFormatter.php @@ -5,7 +5,6 @@ */ class test_FrmEntryFormatter extends FrmUnitTest { - public $factory; private $formatter; /** diff --git a/tests/phpunit/entries/test_FrmEntryMeta.php b/tests/phpunit/entries/test_FrmEntryMeta.php index e1d00e6afa..f802402357 100644 --- a/tests/phpunit/entries/test_FrmEntryMeta.php +++ b/tests/phpunit/entries/test_FrmEntryMeta.php @@ -5,7 +5,6 @@ */ class test_FrmEntryMeta extends FrmUnitTest { - public $factory; /** * @covers FrmEntryMeta::update_entry_metas */ diff --git a/tests/phpunit/entries/test_FrmEntryValidate.php b/tests/phpunit/entries/test_FrmEntryValidate.php index 1160dc3edf..985f6e6c46 100644 --- a/tests/phpunit/entries/test_FrmEntryValidate.php +++ b/tests/phpunit/entries/test_FrmEntryValidate.php @@ -6,7 +6,6 @@ */ class test_FrmEntryValidate extends FrmUnitTest { - public $factory; /** * @covers FrmEntryValidate::validate */ diff --git a/tests/phpunit/entries/test_FrmPersonalData.php b/tests/phpunit/entries/test_FrmPersonalData.php index 5d8d27357d..ed697dc797 100644 --- a/tests/phpunit/entries/test_FrmPersonalData.php +++ b/tests/phpunit/entries/test_FrmPersonalData.php @@ -5,7 +5,6 @@ */ class test_FrmPersonalData extends FrmUnitTest { - public $factory; public static function wpSetUpBeforeClass() { $_POST = array(); self::empty_tables(); diff --git a/tests/phpunit/entries/test_FrmShowEntryShortcode.php b/tests/phpunit/entries/test_FrmShowEntryShortcode.php index ba9a1f7a8d..872ebdc06d 100644 --- a/tests/phpunit/entries/test_FrmShowEntryShortcode.php +++ b/tests/phpunit/entries/test_FrmShowEntryShortcode.php @@ -10,7 +10,6 @@ */ class test_FrmShowEntryShortcode extends FrmUnitTest { - public $factory; public static function wpSetUpBeforeClass() { $_POST = array(); self::empty_tables(); diff --git a/tests/phpunit/fields/test_FrmField.php b/tests/phpunit/fields/test_FrmField.php index efc6e9bfe5..a1d334d196 100644 --- a/tests/phpunit/fields/test_FrmField.php +++ b/tests/phpunit/fields/test_FrmField.php @@ -5,7 +5,6 @@ */ class test_FrmField extends FrmUnitTest { - public $factory; public static function wpSetUpBeforeClass() { $_POST = array(); self::empty_tables(); diff --git a/tests/phpunit/fields/test_FrmFieldCombo.php b/tests/phpunit/fields/test_FrmFieldCombo.php index 9eba66da03..00ab9ac404 100644 --- a/tests/phpunit/fields/test_FrmFieldCombo.php +++ b/tests/phpunit/fields/test_FrmFieldCombo.php @@ -5,7 +5,6 @@ */ class test_FrmFieldCombo extends FrmUnitTest { - public $factory; protected function get_combo_field_without_sub_field_options() { $combo_field = new FrmFieldCombo(); diff --git a/tests/phpunit/fields/test_FrmFieldFormHtml.php b/tests/phpunit/fields/test_FrmFieldFormHtml.php index 7898b1c730..4dd34d7a9e 100644 --- a/tests/phpunit/fields/test_FrmFieldFormHtml.php +++ b/tests/phpunit/fields/test_FrmFieldFormHtml.php @@ -3,7 +3,6 @@ * @group fields */ class test_FrmFieldFormHtml extends FrmUnitTest { - public $factory; /** * @covers FrmFieldFormHtml::add_multiple_input_attributes */ diff --git a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php index 6b954b157c..515a401942 100644 --- a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php +++ b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php @@ -5,7 +5,6 @@ */ class test_FrmFieldGridHelper extends FrmUnitTest { - public $factory; private $form_id; private $helper; diff --git a/tests/phpunit/fields/test_FrmFieldName.php b/tests/phpunit/fields/test_FrmFieldName.php index 05585fe186..b7d9421d10 100644 --- a/tests/phpunit/fields/test_FrmFieldName.php +++ b/tests/phpunit/fields/test_FrmFieldName.php @@ -5,7 +5,6 @@ */ class test_FrmFieldName extends FrmUnitTest { - public $factory; public function test_get_processed_sub_fields() { $field = $this->factory->field->create_and_get( array( diff --git a/tests/phpunit/fields/test_FrmFieldType.php b/tests/phpunit/fields/test_FrmFieldType.php index 0b5797b5e8..3ad13fa957 100644 --- a/tests/phpunit/fields/test_FrmFieldType.php +++ b/tests/phpunit/fields/test_FrmFieldType.php @@ -5,7 +5,6 @@ */ class test_FrmFieldType extends FrmUnitTest { - public $factory; /** * @covers FrmFieldNumber::add_min_max */ diff --git a/tests/phpunit/fields/test_FrmFieldValidate.php b/tests/phpunit/fields/test_FrmFieldValidate.php index 2afe9bfe5f..7d9e6de3d5 100644 --- a/tests/phpunit/fields/test_FrmFieldValidate.php +++ b/tests/phpunit/fields/test_FrmFieldValidate.php @@ -5,7 +5,6 @@ */ class test_FrmFieldValidate extends FrmUnitTest { - public $factory; protected $form; public function setUp(): void { diff --git a/tests/phpunit/fields/test_FrmFieldsAjax.php b/tests/phpunit/fields/test_FrmFieldsAjax.php index e039a98d42..911b33914f 100644 --- a/tests/phpunit/fields/test_FrmFieldsAjax.php +++ b/tests/phpunit/fields/test_FrmFieldsAjax.php @@ -6,7 +6,6 @@ */ class test_FrmFieldsAjax extends FrmAjaxUnitTest { - public $factory; protected $form_id = 0; protected $user_id = 0; diff --git a/tests/phpunit/fields/test_FrmFieldsController.php b/tests/phpunit/fields/test_FrmFieldsController.php index 6b1f523421..b58e97a270 100644 --- a/tests/phpunit/fields/test_FrmFieldsController.php +++ b/tests/phpunit/fields/test_FrmFieldsController.php @@ -5,7 +5,6 @@ */ class test_FrmFieldsController extends FrmUnitTest { - public $factory; /** * @covers FrmFieldsController::prepare_placeholder */ diff --git a/tests/phpunit/fields/test_FrmFieldsHelper.php b/tests/phpunit/fields/test_FrmFieldsHelper.php index d1e1773409..758b2f787f 100644 --- a/tests/phpunit/fields/test_FrmFieldsHelper.php +++ b/tests/phpunit/fields/test_FrmFieldsHelper.php @@ -7,7 +7,6 @@ */ class test_FrmFieldsHelper extends FrmUnitTest { - public $factory; /** * Tests where $observed_value is a single value, not an array. * diff --git a/tests/phpunit/fields/test_FrmSubmitHelper.php b/tests/phpunit/fields/test_FrmSubmitHelper.php index 0523d689eb..96138ef803 100644 --- a/tests/phpunit/fields/test_FrmSubmitHelper.php +++ b/tests/phpunit/fields/test_FrmSubmitHelper.php @@ -2,7 +2,6 @@ class test_FrmSubmitHelper extends FrmUnitTest { - public $factory; public function test_copy_submit_field_settings_to_form() { $form = $this->factory->form->create_and_get(); $this->assertEquals( $form, FrmSubmitHelper::copy_submit_field_settings_to_form( $form ) ); diff --git a/tests/phpunit/forms/test_FrmForm.php b/tests/phpunit/forms/test_FrmForm.php index 735e9f1182..daf2c08ba8 100644 --- a/tests/phpunit/forms/test_FrmForm.php +++ b/tests/phpunit/forms/test_FrmForm.php @@ -5,7 +5,6 @@ */ class test_FrmForm extends FrmUnitTest { - public $factory; public function setUp(): void { parent::setUp(); $this->create_users(); diff --git a/tests/phpunit/forms/test_FrmFormAction.php b/tests/phpunit/forms/test_FrmFormAction.php index 20f4d790ad..5f9c027d7f 100644 --- a/tests/phpunit/forms/test_FrmFormAction.php +++ b/tests/phpunit/forms/test_FrmFormAction.php @@ -5,7 +5,6 @@ */ class test_FrmFormAction extends FrmUnitTest { - public $factory; /** * @covers FrmFormAction::update_callback */ diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index b4f6160cd9..276516ae0b 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -6,7 +6,6 @@ */ class test_FrmFormsController extends FrmUnitTest { - public $factory; public function test_register_widgets() { global $wp_widget_factory; $this->assertTrue( isset( $wp_widget_factory->widgets['FrmShowForm'] ) ); diff --git a/tests/phpunit/forms/test_FrmFormsControllerAjax.php b/tests/phpunit/forms/test_FrmFormsControllerAjax.php index 3549618da6..b6f3eed959 100644 --- a/tests/phpunit/forms/test_FrmFormsControllerAjax.php +++ b/tests/phpunit/forms/test_FrmFormsControllerAjax.php @@ -5,7 +5,6 @@ */ class test_FrmFormsControllerAjax extends FrmAjaxUnitTest { - public $factory; public function setUp(): void { parent::setUp(); diff --git a/tests/phpunit/forms/test_FrmFormsHelper.php b/tests/phpunit/forms/test_FrmFormsHelper.php index 8a21a392fb..989c55da6b 100644 --- a/tests/phpunit/forms/test_FrmFormsHelper.php +++ b/tests/phpunit/forms/test_FrmFormsHelper.php @@ -5,7 +5,6 @@ */ class test_FrmFormsHelper extends FrmUnitTest { - public $factory; /** * @var stdClass|null */ diff --git a/tests/phpunit/forms/test_FrmOnSubmitAction.php b/tests/phpunit/forms/test_FrmOnSubmitAction.php index f835b59190..0b74e560f6 100644 --- a/tests/phpunit/forms/test_FrmOnSubmitAction.php +++ b/tests/phpunit/forms/test_FrmOnSubmitAction.php @@ -5,7 +5,6 @@ */ class test_FrmOnSubmitAction extends FrmUnitTest { - public $factory; public function test_adding_sanitize_url_after_updating() { $form_id = $this->factory->form->create(); $field_id = $this->factory->field->create( diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index 12d7c90cb5..d2f829087d 100644 --- a/tests/phpunit/misc/test_FrmAppHelper.php +++ b/tests/phpunit/misc/test_FrmAppHelper.php @@ -4,7 +4,6 @@ */ class test_FrmAppHelper extends FrmUnitTest { - public $factory; public function setUp(): void { parent::setUp(); $this->create_users(); diff --git a/tests/phpunit/misc/test_FrmCSVExportHelper.php b/tests/phpunit/misc/test_FrmCSVExportHelper.php index a42348e084..71471edd41 100644 --- a/tests/phpunit/misc/test_FrmCSVExportHelper.php +++ b/tests/phpunit/misc/test_FrmCSVExportHelper.php @@ -4,7 +4,6 @@ */ class test_FrmCSVExportHelper extends FrmUnitTest { - public $factory; private $form; /** diff --git a/tests/phpunit/stripe/FrmStrpLiteUnitTest.php b/tests/phpunit/stripe/FrmStrpLiteUnitTest.php index 80b153e7d1..b0593d8340 100644 --- a/tests/phpunit/stripe/FrmStrpLiteUnitTest.php +++ b/tests/phpunit/stripe/FrmStrpLiteUnitTest.php @@ -2,7 +2,6 @@ class FrmStrpLiteUnitTest extends FrmUnitTest { - public $factory; public static function wpSetUpBeforeClass() { parent::wpSetUpBeforeClass(); self::empty_tables(); diff --git a/tests/phpunit/stripe/test_FrmTransLiteActionsController.php b/tests/phpunit/stripe/test_FrmTransLiteActionsController.php index 2d8a60abb3..117b434571 100644 --- a/tests/phpunit/stripe/test_FrmTransLiteActionsController.php +++ b/tests/phpunit/stripe/test_FrmTransLiteActionsController.php @@ -5,7 +5,6 @@ */ class test_FrmTransLiteActionsController extends FrmUnitTest { - public $factory; public function test_get_fields_for_price() { $form_id = $this->factory->form->create(); $field_id = $this->factory->field->create( diff --git a/tests/phpunit/styles/test_FrmStylesHelper.php b/tests/phpunit/styles/test_FrmStylesHelper.php index b0559d0d4a..27728d0aad 100644 --- a/tests/phpunit/styles/test_FrmStylesHelper.php +++ b/tests/phpunit/styles/test_FrmStylesHelper.php @@ -5,7 +5,6 @@ */ class test_FrmStylesHelper extends FrmUnitTest { - public $factory; /** * @covers FrmStylesHelper::get_upload_base */ diff --git a/tests/phpunit/test_ajax.php b/tests/phpunit/test_ajax.php index 9540825e18..a558054fd5 100644 --- a/tests/phpunit/test_ajax.php +++ b/tests/phpunit/test_ajax.php @@ -4,7 +4,6 @@ */ class Tests_Frm_Ajax extends FrmAjaxUnitTest { - public $factory; public function test_plugin_activated() { $this->assertTrue( is_plugin_active( 'formidable/formidable.php' ) ); } diff --git a/tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php b/tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php index 25eab73ab6..70719dfda7 100644 --- a/tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php +++ b/tests/phpunit/views/shortcodes/test_FrmFieldShortcodes.php @@ -7,7 +7,6 @@ */ class test_FrmFieldShortcodes extends FrmUnitTest { - public $factory; protected $test_form; protected $test_entry; From 1a217f9e2f8f31d8d96c30bee8e8068db1572ecc Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 22:03:30 -0400 Subject: [PATCH 11/16] Update rector config --- rector.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 2bc29fb1e6..fbde52f579 100644 --- a/rector.php +++ b/rector.php @@ -100,7 +100,7 @@ use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeForArrayMapRector; use Rector\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamStringTypeFromSprintfUseRector; - +use Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector; define( 'ABSPATH', '' ); return RectorConfig::configure() @@ -271,5 +271,7 @@ AddClosureParamTypeForArrayMapRector::class, KnownMagicClassMethodTypeRector::class, AddParamStringTypeFromSprintfUseRector::class, + AbsolutizeRequireAndIncludePathRector::class, + CompleteDynamicPropertiesRector::class, ) ); From da2963635294b2ae752d8ca628c1835cdb2882de Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 22:06:28 -0400 Subject: [PATCH 12/16] Clean up code --- tests/phpunit/misc/test_FrmAntiSpam.php | 1 - tests/phpunit/misc/test_FrmAppHelper.php | 2 -- tests/phpunit/misc/test_FrmCSVExportHelper.php | 2 +- tests/phpunit/styles/test_FrmStylesController.php | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/phpunit/misc/test_FrmAntiSpam.php b/tests/phpunit/misc/test_FrmAntiSpam.php index 8ccd6bd9de..1a5a322014 100644 --- a/tests/phpunit/misc/test_FrmAntiSpam.php +++ b/tests/phpunit/misc/test_FrmAntiSpam.php @@ -5,7 +5,6 @@ */ class test_FrmAntiSpam extends FrmUnitTest { - private $factory; private $antispam; public function setUp(): void { diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index d2f829087d..3cd01881ee 100644 --- a/tests/phpunit/misc/test_FrmAppHelper.php +++ b/tests/phpunit/misc/test_FrmAppHelper.php @@ -620,8 +620,6 @@ public function test_count_decimals() { * @covers FrmAppHelper::get_ip_address */ public function test_get_ip_address() { - FrmAppHelper::get_ip_address(); - $this->assertEquals( $_SERVER['REMOTE_ADDR'], FrmAppHelper::get_ip_address() ); $_SERVER['HTTP_X_FORWARDED_FOR'] = '1.2.3.4'; diff --git a/tests/phpunit/misc/test_FrmCSVExportHelper.php b/tests/phpunit/misc/test_FrmCSVExportHelper.php index 71471edd41..e4c5f12b5f 100644 --- a/tests/phpunit/misc/test_FrmCSVExportHelper.php +++ b/tests/phpunit/misc/test_FrmCSVExportHelper.php @@ -94,7 +94,7 @@ public function test_csv_headings_for_embedded_sections() { ); $parent_form = $this->factory->form->create_and_get(); - $this->factory->field->create_and_get( + $this->factory->field->create( array( 'form_id' => $parent_form->id, 'type' => 'embed', diff --git a/tests/phpunit/styles/test_FrmStylesController.php b/tests/phpunit/styles/test_FrmStylesController.php index 72c8f7ee31..0bac5c3a89 100644 --- a/tests/phpunit/styles/test_FrmStylesController.php +++ b/tests/phpunit/styles/test_FrmStylesController.php @@ -57,7 +57,6 @@ private function get_custom_stylesheet() { public function test_save() { $frm_style = new FrmStyle( 'default' ); $style = $frm_style->get_one(); - $frm_style->get_defaults(); $_POST = array( 'ID' => $style->ID, From 0f40920efed039d548a626c9bd908cd0dcaec170 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 22:08:57 -0400 Subject: [PATCH 13/16] Clean up --- tests/phpunit/forms/test_FrmFormsController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index 276516ae0b..a6f0d5cb64 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -53,7 +53,6 @@ public function test_form_update_no_ajax() { ob_start(); FrmFormsController::update(); - ob_get_contents(); ob_end_clean(); self::_check_updated_values( $form_id ); From 1deb09d3b574d6f73a615fbec1484134852f3d8c Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 22:10:51 -0400 Subject: [PATCH 14/16] Remove another duplicate rector rule --- rector.php | 1 - 1 file changed, 1 deletion(-) diff --git a/rector.php b/rector.php index fbde52f579..f3e845fb5f 100644 --- a/rector.php +++ b/rector.php @@ -238,7 +238,6 @@ ReturnTypeFromStrictConstantReturnRector::class, PostIncDecToPreIncDecRector::class, MultiDirnameRector::class, - ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictTernaryRector::class, AddClosureVoidReturnTypeWhereNoReturnRector::class, FlipTypeControlToUseExclusiveTypeRector::class, From 9ba27edb77c9eae611021f60ffbb5ec7ae3ee161 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 22:15:53 -0400 Subject: [PATCH 15/16] Small tweaks --- rector.php | 2 -- tests/phpunit/entries/test_FrmShowEntryShortcode.php | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rector.php b/rector.php index f3e845fb5f..cf2d61a3b0 100644 --- a/rector.php +++ b/rector.php @@ -78,7 +78,6 @@ use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector; use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; -use Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector; use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector; use Rector\CodingStyle\Rector\String_\SimplifyQuoteEscapeRector; @@ -250,7 +249,6 @@ CatchExceptionNameMatchingTypeRector::class, ChangeOrIfContinueToMultiContinueRector::class, ReturnEarlyIfVariableRector::class, - CompleteMissingIfElseBracketRector::class, SimplifyQuoteEscapeRector::class, StrStartsWithRector::class, StrContainsRector::class, diff --git a/tests/phpunit/entries/test_FrmShowEntryShortcode.php b/tests/phpunit/entries/test_FrmShowEntryShortcode.php index 872ebdc06d..270105dcbe 100644 --- a/tests/phpunit/entries/test_FrmShowEntryShortcode.php +++ b/tests/phpunit/entries/test_FrmShowEntryShortcode.php @@ -27,6 +27,8 @@ public static function wpSetUpBeforeClass() { protected $is_repeater_child = false; public function __construct() { + parent::__construct(); + $defaults = $this->get_defaults(); $this->td_style = str_replace( '#1D2939', $defaults['text_color'], $this->td_style ); $this->td_style = str_replace( '#cccccc', $defaults['border_color'], $this->td_style ); From b511aa489dfecdc980179af870f6943fedf71b22 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 17 Dec 2025 22:19:00 -0400 Subject: [PATCH 16/16] Ignore another rector rule --- rector.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rector.php b/rector.php index cf2d61a3b0..e40bb8d73a 100644 --- a/rector.php +++ b/rector.php @@ -100,6 +100,8 @@ use Rector\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamStringTypeFromSprintfUseRector; use Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector; +use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector; + define( 'ABSPATH', '' ); return RectorConfig::configure() @@ -270,5 +272,6 @@ AddParamStringTypeFromSprintfUseRector::class, AbsolutizeRequireAndIncludePathRector::class, CompleteDynamicPropertiesRector::class, + RemoveParentCallWithoutParentRector::class, ) );