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..dc7d57b97b 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']; } /** @@ -1126,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/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..91ea72c682 100644 --- a/composer.json +++ b/composer.json @@ -35,12 +35,11 @@ "wp-coding-standards/wpcs": "^3.0", "automattic/vipwpcs": "^3.0", "squizlabs/php_codesniffer": "^3.10", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-strict-rules": "^1.5", + "phpstan/phpstan": "^2.1.33", "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/phpstan.neon b/phpstan.neon index 70f272a630..85e6050ca5 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)+#' @@ -73,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 @@ -198,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 @@ -261,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/rector.php b/rector.php index e498b6ff1b..e40bb8d73a 100644 --- a/rector.php +++ b/rector.php @@ -32,6 +32,75 @@ 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\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector; +use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; +use Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector; +use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; +use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector; +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\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\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\Php70\Rector\FuncCall\MultiDirnameRector; +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; +use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; +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; +use Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector; +use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector; define( 'ABSPATH', '' ); @@ -41,6 +110,7 @@ __DIR__ . '/classes', __DIR__ . '/stripe', __DIR__ . '/square', + __DIR__ . '/tests', ) ) // here we can define, what prepared sets of rules will be applied @@ -48,7 +118,35 @@ // deadCode true, // codeQuality - true + true, + // codingStyle + true, + // typeDeclarations + true, + // typeDeclarationDocblocks + true, + // privatization + true, + // naming + true, + // instanceOf + true, + // earlyReturn + true, + // strictBooleans + false, + // carbon + false, + // rectorPreset + true, + // phpunitCodeQuality + true, + // doctrineCodeQuality + false, + // symfonyCodeQuality + false, + // symfonyConfigs + false ) ->withPhpSets( // PHP 8.3 @@ -104,5 +202,76 @@ InlineConstructorDefaultToPropertyRector::class, SimplifyRegexPatternRector::class, RemoveUnusedConstructorParamRector::class, + // Enable this one soon. + 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, + StrictArraySearchRector::class, + RenameVariableToMatchMethodCallReturnTypeRector::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, + BoolReturnTypeFromBooleanConstReturnsRector::class, + ReturnTypeFromReturnCastRector::class, + StringReturnTypeFromStrictScalarReturnsRector::class, + ReturnTypeFromStrictConstantReturnRector::class, + PostIncDecToPreIncDecRector::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, + 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, + AbsolutizeRequireAndIncludePathRector::class, + CompleteDynamicPropertiesRector::class, + RemoveParentCallWithoutParentRector::class, ) ); 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']; 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; } /** 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/emails/test_FrmEmail.php b/tests/phpunit/emails/test_FrmEmail.php index 929c6e7dcc..3a2e042b5b 100644 --- a/tests/phpunit/emails/test_FrmEmail.php +++ b/tests/phpunit/emails/test_FrmEmail.php @@ -430,12 +430,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 +502,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_FrmPersonalData.php b/tests/phpunit/entries/test_FrmPersonalData.php index de28329836..ed697dc797 100644 --- a/tests/phpunit/entries/test_FrmPersonalData.php +++ b/tests/phpunit/entries/test_FrmPersonalData.php @@ -61,6 +61,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..270105dcbe 100644 --- a/tests/phpunit/entries/test_FrmShowEntryShortcode.php +++ b/tests/phpunit/entries/test_FrmShowEntryShortcode.php @@ -756,9 +756,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 +772,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 +793,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 +838,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 +851,8 @@ protected function one_cell_table_row( $field_key, $atts ) { $html = 'Test
\nMiddle
\nTesterson