From 80d8aaa3b0d613393a8384e7e45d86508b5e06e3 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 6 Jan 2026 12:44:45 -0400 Subject: [PATCH 1/5] Organize the rector config --- rector.php | 282 +++++++++++++++++++++++------------------------------ 1 file changed, 124 insertions(+), 158 deletions(-) diff --git a/rector.php b/rector.php index 5c1c4c5ff4..898c123c53 100644 --- a/rector.php +++ b/rector.php @@ -1,100 +1,85 @@ withSkip( array( - SwitchNegatedTernaryRector::class, + // CodeQuality + AbsolutizeRequireAndIncludePathRector::class, + ChangeArrayPushToArrayAssignRector::class, + CombinedAssignRector::class, + CombineIfRector::class, CompactToVariablesRector::class, - IssetOnPropertyObjectToPropertyExistsRector::class, + CompleteDynamicPropertiesRector::class, ExplicitBoolCompareRector::class, - UnusedForeachValueToArrayKeysRector::class, - CombinedAssignRector::class, - SimplifyEmptyCheckOnEmptyArrayRector::class, - CountArrayToEmptyArrayComparisonRector::class, - DisallowedEmptyRuleFixerRector::class, - LocallyCalledStaticMethodToNonStaticRector::class, + FlipTypeControlToUseExclusiveTypeRector::class, + InlineConstructorDefaultToPropertyRector::class, + IssetOnPropertyObjectToPropertyExistsRector::class, // This changes \t to an actual tab character. We don't want this rule. JoinStringConcatRector::class, - ChangeArrayPushToArrayAssignRector::class, - // We never want to remove a param tag. Leave this exception. - RemoveUselessParamTagRector::class, - RemoveDeadReturnRector::class, - RemoveAlwaysTrueIfConditionRector::class, + LocallyCalledStaticMethodToNonStaticRector::class, + RepeatedAndNotEqualToNotInArrayRector::class, + ShortenElseIfRector::class, // This changes if is_array() && empty() to if === []. SimplifyEmptyArrayCheckRector::class, - LongArrayToShortArrayRector::class, - TernaryToElvisRector::class, - // TODO: Try this for some files and not others. - RemoveUnusedPrivateMethodRector::class, - ShortenElseIfRector::class, - CombineIfRector::class, + SimplifyEmptyCheckOnEmptyArrayRector::class, + SimplifyRegexPatternRector::class, SingleInArrayToCompareRector::class, - RemoveUnusedForeachKeyRector::class, SingularSwitchToIfRector::class, - RemoveUnusedPrivateMethodParameterRector::class, - InlineConstructorDefaultToPropertyRector::class, - SimplifyRegexPatternRector::class, - RemoveUnusedConstructorParamRector::class, - // Enable this one soon. + SwitchNegatedTernaryRector::class, + UnusedForeachValueToArrayKeysRector::class, + UseIdenticalOverEqualWithSameTypeRector::class, + + // CodingStyle + CallUserFuncArrayToVariadicRector::class, + CatchExceptionNameMatchingTypeRector::class, + CountArrayToEmptyArrayComparisonRector::class, + EncapsedStringsToSprintfRector::class, + MakeInheritedMethodVisibilitySameAsParentRector::class, + // We do not need these many new lines. NewlineAfterStatementRector::class, - // Try these - RemoveUselessReturnTagRector::class, - RenameVariableToMatchNewTypeRector::class, - AddMethodCallBasedStrictParamTypeRector::class, - AddVoidReturnTypeWhereNoReturnRector::class, - BoolReturnTypeFromBooleanStrictReturnsRector::class, - ReturnNullableTypeRector::class, - ReturnTypeFromReturnDirectArrayRector::class, - ReturnTypeFromStrictNewArrayRector::class, - StrictArrayParamDimFetchRector::class, - DeclareStrictTypesRector::class, NewlineBeforeNewAssignSetRector::class, - EncapsedStringsToSprintfRector::class, + NewlineBetweenClassLikeStmtsRector::class, + NullableCompareToNullRector::class, + PostIncDecToPreIncDecRector::class, + SimplifyQuoteEscapeRector::class, StrictArraySearchRector::class, - RenameVariableToMatchMethodCallReturnTypeRector::class, - ReturnTypeFromStrictNativeCallRector::class, - ReturnUnionTypeRector::class, - StringReturnTypeFromStrictStringReturnsRector::class, - ClosureReturnTypeRector::class, WrapEncapsedVariableInCurlyBracesRector::class, - ReturnTypeFromStrictTypedCallRector::class, - StrictStringParamConcatRector::class, + + // DeadCode + RemoveAlwaysTrueIfConditionRector::class, + RemoveDeadReturnRector::class, + RemoveParentCallWithoutParentRector::class, + RemoveUnusedConstructorParamRector::class, + RemoveUnusedForeachKeyRector::class, + RemoveUnusedPrivateMethodParameterRector::class, + RemoveUnusedPrivateMethodRector::class, + // We never want to remove a param tag. Leave this exception. + RemoveUselessParamTagRector::class, + RemoveUselessReturnTagRector::class, + + // EarlyReturn + ChangeOrIfContinueToMultiContinueRector::class, ReturnBinaryOrToEarlyReturnRector::class, - RenamePropertyToMatchTypeRector::class, - NumericReturnTypeFromStrictReturnsRector::class, - TypedPropertyFromAssignsRector::class, - TypedPropertyFromStrictConstructorRector::class, - AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, + ReturnEarlyIfVariableRector::class, + + // Naming RenameForeachValueVariableToMatchExprVariableRector::class, - BoolReturnTypeFromBooleanConstReturnsRector::class, - ReturnTypeFromReturnCastRector::class, - StringReturnTypeFromStrictScalarReturnsRector::class, - ReturnTypeFromStrictConstantReturnRector::class, - PostIncDecToPreIncDecRector::class, + RenameParamToMatchTypeRector::class, + RenamePropertyToMatchTypeRector::class, + RenameVariableToMatchMethodCallReturnTypeRector::class, + RenameVariableToMatchNewTypeRector::class, + + // Php53, Php54, Php70 + LongArrayToShortArrayRector::class, MultiDirnameRector::class, - ReturnTypeFromStrictTernaryRector::class, - AddClosureVoidReturnTypeWhereNoReturnRector::class, - FlipTypeControlToUseExclusiveTypeRector::class, - NullableCompareToNullRector::class, - ReturnTypeFromReturnNewRector::class, - MakeInheritedMethodVisibilitySameAsParentRector::class, - NumericReturnTypeFromStrictScalarReturnsRector::class, - ReturnNeverTypeRector::class, - CallUserFuncArrayToVariadicRector::class, - CatchExceptionNameMatchingTypeRector::class, - ChangeOrIfContinueToMultiContinueRector::class, - ReturnEarlyIfVariableRector::class, - SimplifyQuoteEscapeRector::class, + // The WP standard does not encourage the Elvis operator for readability. + TernaryToElvisRector::class, + + // Strict + DisallowedEmptyRuleFixerRector::class, + + // TypeDeclarationDocblocks AddParamArrayDocblockFromAssignsParamToParamReferenceRector::class, AddParamArrayDocblockFromDimFetchAccessRector::class, - RepeatedAndNotEqualToNotInArrayRector::class, - UseIdenticalOverEqualWithSameTypeRector::class, - AddParamFromDimFetchKeyUseRector::class, DocblockReturnArrayFromDirectArrayInstanceRector::class, - AddArrayFunctionClosureParamTypeRector::class, - RenameParamToMatchTypeRector::class, - AddArrowFunctionParamArrayWhereDimFetchRector::class, - NewlineBetweenClassLikeStmtsRector::class, - AddClosureParamTypeForArrayMapRector::class, - KnownMagicClassMethodTypeRector::class, - AddParamStringTypeFromSprintfUseRector::class, - AbsolutizeRequireAndIncludePathRector::class, - CompleteDynamicPropertiesRector::class, - RemoveParentCallWithoutParentRector::class, ) ); From 19aac5ac0573ea2fecd598bc36c58dfd544b7b40 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 6 Jan 2026 12:50:29 -0400 Subject: [PATCH 2/5] Stop ignoring UseIdenticalOverEqualWithSameTypeRector --- classes/helpers/FrmAppHelper.php | 6 +++--- classes/helpers/FrmFormsHelper.php | 2 +- classes/models/FrmEntry.php | 2 +- classes/models/FrmStyle.php | 2 +- classes/views/frm-form-actions/_action_inside.php | 2 +- rector.php | 2 -- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 0e62631875..997e866f61 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -3076,7 +3076,7 @@ public static function truncate( $original_string, $length, $minword = 3, $conti $str = wp_strip_all_tags( (string) $original_string ); $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); - if ( $length == 0 ) { + if ( $length === 0 ) { return ''; } @@ -3462,7 +3462,7 @@ public static function json_to_array( $json_vars ) { $l3 = $name; } - $this_val = $p == $last ? $jv['value'] : array(); + $this_val = $p === $last ? $jv['value'] : array(); switch ( $p ) { case 0: @@ -3702,7 +3702,7 @@ public static function maybe_json_decode( $string, $single_to_array = true ) { $single_value = is_array( $new_string ) && count( $new_string ) === 1 && isset( $new_string[0] ); } - if ( json_last_error() == JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) { + if ( json_last_error() === JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) { $string = $new_string; } } diff --git a/classes/helpers/FrmFormsHelper.php b/classes/helpers/FrmFormsHelper.php index 496786886a..7dde65f625 100644 --- a/classes/helpers/FrmFormsHelper.php +++ b/classes/helpers/FrmFormsHelper.php @@ -1874,7 +1874,7 @@ private static function create_unsafe_param_warning( $unsafe_params_in_redirect return false; } - if ( $count == 1 ) { + if ( $count === 1 ) { /* translators: %s: the name of a single parameter in the redirect URL */ return sprintf( esc_html__( 'The redirect URL is using the parameter "%s", which is reserved by WordPress. ', 'formidable' ), $unsafe_params_in_redirect[0] ) . $caution . $reserved_words_link; } diff --git a/classes/models/FrmEntry.php b/classes/models/FrmEntry.php index 7abc5957f3..72abf0aabd 100644 --- a/classes/models/FrmEntry.php +++ b/classes/models/FrmEntry.php @@ -659,7 +659,7 @@ public static function getAll( $where, $order_by = '', $limit = '', $meta = fals $meta_where = array( 'field_id !' => 0 ); - if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { + if ( $limit == '' && is_array( $where ) && count( $where ) === 1 && isset( $where['it.form_id'] ) ) { $meta_where['fi.form_id'] = $where['it.form_id']; } else { $meta_where['item_id'] = array_keys( $entries ); diff --git a/classes/models/FrmStyle.php b/classes/models/FrmStyle.php index 8121f32965..16d83c5d47 100644 --- a/classes/models/FrmStyle.php +++ b/classes/models/FrmStyle.php @@ -822,7 +822,7 @@ public function force_balanced_quotation( $value ) { foreach ( $balanced_characters as $char ) { $char_count = substr_count( $value, $char ); - $is_balanced = $char_count % 2 == 0; + $is_balanced = $char_count % 2 === 0; if ( $is_balanced ) { continue; diff --git a/classes/views/frm-form-actions/_action_inside.php b/classes/views/frm-form-actions/_action_inside.php index c11b95125a..d50435bfcc 100644 --- a/classes/views/frm-form-actions/_action_inside.php +++ b/classes/views/frm-form-actions/_action_inside.php @@ -34,7 +34,7 @@ $action_control->action_options['event'] = explode( ',', $action_control->action_options['event'] ); } -if ( count( $action_control->action_options['event'] ) == 1 || $action_control->action_options['force_event'] ) { +if ( count( $action_control->action_options['event'] ) === 1 || $action_control->action_options['force_event'] ) { foreach ( $action_control->action_options['event'] as $e ) { ?> diff --git a/rector.php b/rector.php index 898c123c53..2c2960d6ea 100644 --- a/rector.php +++ b/rector.php @@ -12,7 +12,6 @@ use Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector; use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector; use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; -use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector; use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector; use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector; use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector; @@ -173,7 +172,6 @@ SingularSwitchToIfRector::class, SwitchNegatedTernaryRector::class, UnusedForeachValueToArrayKeysRector::class, - UseIdenticalOverEqualWithSameTypeRector::class, // CodingStyle CallUserFuncArrayToVariadicRector::class, From 91e679fae7f8b84a19a2df6208f46ad7bf52f218 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 6 Jan 2026 12:53:51 -0400 Subject: [PATCH 3/5] Try naming too --- rector.php | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/rector.php b/rector.php index 2c2960d6ea..c11f7807cb 100644 --- a/rector.php +++ b/rector.php @@ -57,21 +57,11 @@ use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; -// Naming -use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector; -use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector; -use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector; -use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector; -use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector; - // Php53, Php54, Php70 use Rector\Php53\Rector\Ternary\TernaryToElvisRector; use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector; use Rector\Php70\Rector\FuncCall\MultiDirnameRector; -// Renaming -use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; - // Strict use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; @@ -106,7 +96,7 @@ // privatization true, // naming - true, + false, // instanceOf true, // earlyReturn @@ -206,13 +196,6 @@ ReturnBinaryOrToEarlyReturnRector::class, ReturnEarlyIfVariableRector::class, - // Naming - RenameForeachValueVariableToMatchExprVariableRector::class, - RenameParamToMatchTypeRector::class, - RenamePropertyToMatchTypeRector::class, - RenameVariableToMatchMethodCallReturnTypeRector::class, - RenameVariableToMatchNewTypeRector::class, - // Php53, Php54, Php70 LongArrayToShortArrayRector::class, MultiDirnameRector::class, From c2e1afa7bfa8d3f88142d5423e51660119c6c90b Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 6 Jan 2026 12:58:28 -0400 Subject: [PATCH 4/5] Add more comments to rector config --- rector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rector.php b/rector.php index c11f7807cb..315e04e253 100644 --- a/rector.php +++ b/rector.php @@ -193,10 +193,12 @@ // EarlyReturn ChangeOrIfContinueToMultiContinueRector::class, + // This breaks a return statement up into multiple return statements. It does not look very good. ReturnBinaryOrToEarlyReturnRector::class, ReturnEarlyIfVariableRector::class, // Php53, Php54, Php70 + // The WP standard still uses the long array syntax, so ignore this for now. LongArrayToShortArrayRector::class, MultiDirnameRector::class, // The WP standard does not encourage the Elvis operator for readability. From a6ee8a44c510f9c057dc736722632ff3d7b64d33 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 6 Jan 2026 13:04:32 -0400 Subject: [PATCH 5/5] Drop unused use --- rector.php | 1 - 1 file changed, 1 deletion(-) diff --git a/rector.php b/rector.php index 315e04e253..0826b46a55 100644 --- a/rector.php +++ b/rector.php @@ -8,7 +8,6 @@ use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; -use Rector\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector; use Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector; use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector; use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;