From 09c2ce653c70141ee1b5bb2ac99e8436fcdf9a00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Lys=C3=BD?=
@@ -201,7 +201,8 @@ class Widget extends \WP_Widget { if ($form->getStatus() !== FormEntity::STATUS_ENABLED) return ''; $formType = 'widget'; - if (isset($instance['form_type']) && in_array( + if ( + isset($instance['form_type']) && in_array( $instance['form_type'], [ 'html', @@ -209,7 +210,8 @@ class Widget extends \WP_Widget { 'iframe', 'shortcode', ] - )) { + ) + ) { $formType = $instance['form_type']; } diff --git a/lib/Mailer/MetaInfo.php b/lib/Mailer/MetaInfo.php index 73f21db0a7..26546aa01b 100644 --- a/lib/Mailer/MetaInfo.php +++ b/lib/Mailer/MetaInfo.php @@ -57,7 +57,7 @@ class MetaInfo { return $this->makeMetaInfo($type, $subscriber->status, $subscriber->source); } - private function makeMetaInfo($emailType, $subscriberStatus, $subscriberSource) { + private function makeMetaInfo($emailType, $subscriberStatus, $subscriberSource) { return [ 'email_type' => $emailType, 'subscriber_status' => $subscriberStatus, diff --git a/lib/Mailer/Methods/MailPoet.php b/lib/Mailer/Methods/MailPoet.php index 6419d42f21..604b88a9fc 100644 --- a/lib/Mailer/Methods/MailPoet.php +++ b/lib/Mailer/Methods/MailPoet.php @@ -74,7 +74,8 @@ class MailPoet { public function processSendError($result, $subscriber, $newsletter) { if (!empty($result['code']) && $result['code'] === API::RESPONSE_CODE_KEY_INVALID) { Bridge::invalidateKey(); - } elseif (!empty($result['code']) + } elseif ( + !empty($result['code']) && $result['code'] === API::RESPONSE_CODE_CAN_NOT_SEND && $result['message'] === MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED ) { diff --git a/lib/Models/Newsletter.php b/lib/Models/Newsletter.php index 39e69318e1..83165aa479 100644 --- a/lib/Models/Newsletter.php +++ b/lib/Models/Newsletter.php @@ -163,13 +163,15 @@ class Newsletter extends Model { return $this; } } - if (in_array($status, [ - self::STATUS_DRAFT, - self::STATUS_SCHEDULED, - self::STATUS_SENDING, - self::STATUS_SENT, - self::STATUS_ACTIVE, - ])) { + if ( + in_array($status, [ + self::STATUS_DRAFT, + self::STATUS_SCHEDULED, + self::STATUS_SENDING, + self::STATUS_SENT, + self::STATUS_ACTIVE, + ]) + ) { $this->set('status', $status); $this->save(); } @@ -404,26 +406,30 @@ class Newsletter extends Model { } public static function filterStatus($orm, $status = false) { - if (in_array($status, [ + if ( + in_array($status, [ self::STATUS_DRAFT, self::STATUS_SCHEDULED, self::STATUS_SENDING, self::STATUS_SENT, self::STATUS_ACTIVE, - ])) { + ]) + ) { $orm->where('status', $status); } return $orm; } public static function filterType($orm, $type = false, $group = false) { - if (in_array($type, [ + if ( + in_array($type, [ self::TYPE_STANDARD, self::TYPE_WELCOME, self::TYPE_AUTOMATIC, self::TYPE_NOTIFICATION, self::TYPE_NOTIFICATION_HISTORY, - ])) { + ]) + ) { if ($type === self::TYPE_AUTOMATIC && $group) { $orm = $orm->join( NewsletterOptionField::$_table, diff --git a/lib/Models/StatisticsNewsletters.php b/lib/Models/StatisticsNewsletters.php index ff23dbb0b2..ef71251194 100644 --- a/lib/Models/StatisticsNewsletters.php +++ b/lib/Models/StatisticsNewsletters.php @@ -11,9 +11,10 @@ class StatisticsNewsletters extends Model { public static function createMultiple(array $data) { $values = []; foreach ($data as $value) { - if (!empty($value['newsletter_id']) && - !empty($value['subscriber_id']) && - !empty($value['queue_id']) + if ( + !empty($value['newsletter_id']) && + !empty($value['subscriber_id']) && + !empty($value['queue_id']) ) { $values[] = $value['newsletter_id']; $values[] = $value['subscriber_id']; diff --git a/lib/Newsletter/Links/Links.php b/lib/Newsletter/Links/Links.php index 0928ef891f..ad736f7723 100644 --- a/lib/Newsletter/Links/Links.php +++ b/lib/Newsletter/Links/Links.php @@ -184,9 +184,10 @@ class Links { } public function ensureInstantUnsubscribeLink(array $processedLinks) { - if (in_array( - NewsletterLinkEntity::INSTANT_UNSUBSCRIBE_LINK_SHORT_CODE, - array_column($processedLinks, 'link')) + if ( + in_array( + NewsletterLinkEntity::INSTANT_UNSUBSCRIBE_LINK_SHORT_CODE, + array_column($processedLinks, 'link')) ) { return $processedLinks; } @@ -211,7 +212,8 @@ class Links { // convert either only link shortcodes or all hashes links if "convert all" // option is specified - if (($newsletterLink instanceof NewsletterLinkEntity) && + if ( + ($newsletterLink instanceof NewsletterLinkEntity) && (preg_match('/\[link:/', $newsletterLink->getUrl()) || $convertAll) ) { $content = str_replace($link, $newsletterLink->getUrl(), $content); diff --git a/lib/Newsletter/Renderer/Blocks/AbandonedCartContent.php b/lib/Newsletter/Renderer/Blocks/AbandonedCartContent.php index bb8333544d..1573aca410 100644 --- a/lib/Newsletter/Renderer/Blocks/AbandonedCartContent.php +++ b/lib/Newsletter/Renderer/Blocks/AbandonedCartContent.php @@ -36,7 +36,8 @@ class AbandonedCartContent { $optionField = $newsletterOption->getOptionField(); return $optionField && $optionField->getName() === 'event'; })->first(); - if (($groupOption instanceof NewsletterOptionEntity && $groupOption->getValue() !== WooCommerceEmail::SLUG) + if ( + ($groupOption instanceof NewsletterOptionEntity && $groupOption->getValue() !== WooCommerceEmail::SLUG) || ($eventOption instanceof NewsletterOptionEntity && $eventOption->getValue() !== AbandonedCart::SLUG) ) { // Do not display the block if not an AbandonedCart email diff --git a/lib/Newsletter/Renderer/Blocks/Image.php b/lib/Newsletter/Renderer/Blocks/Image.php index 785e046914..3bbb71bd8c 100644 --- a/lib/Newsletter/Renderer/Blocks/Image.php +++ b/lib/Newsletter/Renderer/Blocks/Image.php @@ -60,7 +60,8 @@ class Image { $element['height'] = (int)ceil($element['height'] / $ratio); } // resize image if the image is padded and wider than padded column width - if ($element['fullWidth'] === false && + if ( + $element['fullWidth'] === false && $element['width'] > ($columnBaseWidth - $paddedWidth) ) { $ratio = $element['width'] / ($columnBaseWidth - $paddedWidth); diff --git a/lib/Newsletter/Renderer/Blocks/Text.php b/lib/Newsletter/Renderer/Blocks/Text.php index ae349c6b35..a197cb40f4 100644 --- a/lib/Newsletter/Renderer/Blocks/Text.php +++ b/lib/Newsletter/Renderer/Blocks/Text.php @@ -91,9 +91,10 @@ class Text { false; // if previous or next paragraphs are empty OR previous paragraph // is a heading, insert a break line - if (!$nextElement || - !$previousElement || - (preg_match('/h\d+/', $previousElementTag)) + if ( + !$nextElement || + !$previousElement || + (preg_match('/h\d+/', $previousElementTag)) ) { $paragraph = $this->insertLineBreak($paragraph); } diff --git a/lib/Newsletter/Renderer/Columns/Renderer.php b/lib/Newsletter/Renderer/Columns/Renderer.php index af4a2dae25..27b8c3d5de 100644 --- a/lib/Newsletter/Renderer/Columns/Renderer.php +++ b/lib/Newsletter/Renderer/Columns/Renderer.php @@ -129,7 +129,8 @@ class Renderer { } private function getBgColorAttribute($styles, $image) { - if (($image === null || $image['src'] === null) + if ( + ($image === null || $image['src'] === null) && isset($styles['backgroundColor']) && $styles['backgroundColor'] !== 'transparent' ) { diff --git a/lib/Newsletter/Scheduler/WelcomeScheduler.php b/lib/Newsletter/Scheduler/WelcomeScheduler.php index 07830c85a5..b2480b4496 100644 --- a/lib/Newsletter/Scheduler/WelcomeScheduler.php +++ b/lib/Newsletter/Scheduler/WelcomeScheduler.php @@ -52,7 +52,8 @@ class WelcomeScheduler { if (empty($newsletters)) return false; $result = []; foreach ($newsletters as $newsletter) { - if ($newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_EVENT) === 'segment' && + if ( + $newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_EVENT) === 'segment' && in_array($newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_SEGMENT), $segments) ) { $sendingTask = $this->createWelcomeNotificationSendingTask($newsletter, $subscriberId); @@ -80,13 +81,15 @@ class WelcomeScheduler { // do not schedule welcome newsletter if roles have not changed $oldRole = $oldUserData['roles']; $newRole = $wpUser['roles']; - if ($newsletterRole === self::WORDPRESS_ALL_ROLES || + if ( + $newsletterRole === self::WORDPRESS_ALL_ROLES || !array_diff($oldRole, $newRole) ) { continue; } } - if ($newsletterRole === self::WORDPRESS_ALL_ROLES || + if ( + $newsletterRole === self::WORDPRESS_ALL_ROLES || in_array($newsletterRole, $wpUser['roles']) ) { $this->createWelcomeNotificationSendingTask($newsletter, $subscriberId); diff --git a/lib/Newsletter/Shortcodes/Categories/Subscriber.php b/lib/Newsletter/Shortcodes/Categories/Subscriber.php index 6cd64b204f..9af203c0ae 100644 --- a/lib/Newsletter/Shortcodes/Categories/Subscriber.php +++ b/lib/Newsletter/Shortcodes/Categories/Subscriber.php @@ -56,7 +56,8 @@ class Subscriber implements CategoryInterface { case 'count': return (string)$this->subscribersRepository->getTotalSubscribers(); default: - if (preg_match('/cf_(\d+)/', $shortcodeDetails['action'], $customField) && + if ( + preg_match('/cf_(\d+)/', $shortcodeDetails['action'], $customField) && !empty($subscriber->getId()) ) { $customField = $this->subscriberCustomFieldRepository->findOneBy([ diff --git a/lib/Router/Endpoints/Track.php b/lib/Router/Endpoints/Track.php index 201d7aced4..faf0aa4ea2 100644 --- a/lib/Router/Endpoints/Track.php +++ b/lib/Router/Endpoints/Track.php @@ -80,7 +80,8 @@ class Track { public function _processTrackData($data) { $data = (object)$this->links->transformUrlDataObject($data); - if (empty($data->queue_id) || // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps + if ( + empty($data->queue_id) || // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps empty($data->subscriber_id) || // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps empty($data->subscriber_token) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps ) { diff --git a/lib/Segments/DynamicSegments/FilterDataMapper.php b/lib/Segments/DynamicSegments/FilterDataMapper.php index 1a9f824861..8a6ba74df8 100644 --- a/lib/Segments/DynamicSegments/FilterDataMapper.php +++ b/lib/Segments/DynamicSegments/FilterDataMapper.php @@ -213,7 +213,8 @@ class FilterDataMapper { $filterData['country_code'] = $data['country_code']; $filterData['operator'] = $data['operator'] ?? DynamicSegmentFilterData::OPERATOR_ANY; } elseif ($data['action'] === WooCommerceNumberOfOrders::ACTION_NUMBER_OF_ORDERS) { - if (!isset($data['number_of_orders_type']) + if ( + !isset($data['number_of_orders_type']) || !isset($data['number_of_orders_count']) || $data['number_of_orders_count'] < 0 || !isset($data['number_of_orders_days']) || $data['number_of_orders_days'] < 1 ) { @@ -223,7 +224,8 @@ class FilterDataMapper { $filterData['number_of_orders_count'] = $data['number_of_orders_count']; $filterData['number_of_orders_days'] = $data['number_of_orders_days']; } elseif ($data['action'] === WooCommerceTotalSpent::ACTION_TOTAL_SPENT) { - if (!isset($data['total_spent_type']) + if ( + !isset($data['total_spent_type']) || !isset($data['total_spent_amount']) || $data['total_spent_amount'] < 0 || !isset($data['total_spent_days']) || $data['total_spent_days'] < 1 ) { diff --git a/lib/Segments/WP.php b/lib/Segments/WP.php index 7c43edc181..4b68cd6867 100644 --- a/lib/Segments/WP.php +++ b/lib/Segments/WP.php @@ -92,7 +92,8 @@ class WP { } // we want to mark a new subscriber as unsubscribed when the checkbox on Woo checkout is unchecked - if (isset($_POST[WooCommerceSubscription::CHECKOUT_OPTIN_PRESENCE_CHECK_INPUT_NAME]) + if ( + isset($_POST[WooCommerceSubscription::CHECKOUT_OPTIN_PRESENCE_CHECK_INPUT_NAME]) && !isset($_POST[WooCommerceSubscription::CHECKOUT_OPTIN_INPUT_NAME]) ) { $status = SubscriberEntity::STATUS_UNSUBSCRIBED; diff --git a/lib/Services/Bridge.php b/lib/Services/Bridge.php index 9120ab9e9b..778dd0e7bd 100644 --- a/lib/Services/Bridge.php +++ b/lib/Services/Bridge.php @@ -132,7 +132,8 @@ class Bridge { } public function storeMSSKeyAndState($key, $state) { - if (empty($state['state']) + if ( + empty($state['state']) || $state['state'] === self::KEY_CHECK_ERROR ) { return false; @@ -167,7 +168,8 @@ class Bridge { ]; if (!empty($result['code']) && isset($stateMap[$result['code']])) { - if ($stateMap[$result['code']] == self::KEY_VALID + if ( + $stateMap[$result['code']] == self::KEY_VALID && !empty($result['data']['expire_at']) ) { $keyState = self::KEY_EXPIRING; @@ -185,7 +187,8 @@ class Bridge { } public function storePremiumKeyAndState($key, $state) { - if (empty($state['state']) + if ( + empty($state['state']) || $state['state'] === self::KEY_CHECK_ERROR ) { return false; diff --git a/lib/Statistics/Track/Clicks.php b/lib/Statistics/Track/Clicks.php index 4ebe0dfa46..831b0bb479 100644 --- a/lib/Statistics/Track/Clicks.php +++ b/lib/Statistics/Track/Clicks.php @@ -98,9 +98,10 @@ class Clicks { $queue, $userAgent ); - if ($userAgent instanceof UserAgentEntity && - ($userAgent->getUserAgentType() === UserAgentEntity::USER_AGENT_TYPE_HUMAN - || $statisticsClicks->getUserAgentType() === UserAgentEntity::USER_AGENT_TYPE_MACHINE) + if ( + $userAgent instanceof UserAgentEntity && + ($userAgent->getUserAgentType() === UserAgentEntity::USER_AGENT_TYPE_HUMAN + || $statisticsClicks->getUserAgentType() === UserAgentEntity::USER_AGENT_TYPE_MACHINE) ) { $statisticsClicks->setUserAgent($userAgent); $statisticsClicks->setUserAgentType($userAgent->getUserAgentType()); diff --git a/lib/Statistics/Track/Opens.php b/lib/Statistics/Track/Opens.php index 74b3c8dda2..614d28d3aa 100644 --- a/lib/Statistics/Track/Opens.php +++ b/lib/Statistics/Track/Opens.php @@ -54,7 +54,8 @@ class Opens { if ($oldStatistics) { if (!empty($data->userAgent)) { $userAgent = $this->userAgentsRepository->findOrCreate($data->userAgent); - if ($userAgent->getUserAgentType() === UserAgentEntity::USER_AGENT_TYPE_HUMAN + if ( + $userAgent->getUserAgentType() === UserAgentEntity::USER_AGENT_TYPE_HUMAN || $oldStatistics->getUserAgentType() === UserAgentEntity::USER_AGENT_TYPE_MACHINE ) { $oldStatistics->setUserAgent($userAgent); diff --git a/lib/Subscribers/ImportExport/Export/Export.php b/lib/Subscribers/ImportExport/Export/Export.php index 9991655d39..e53a6d2fb9 100644 --- a/lib/Subscribers/ImportExport/Export/Export.php +++ b/lib/Subscribers/ImportExport/Export/Export.php @@ -160,7 +160,8 @@ class Export { // sorted by segment name (due to slow queries when using ORDER BY and LIMIT), // we need to keep track of processed segments so that we do not create header // multiple times when switching from one segment to another and back. - if ((!count($processedSegments) || $lastSegment !== $currentSegment) && + if ( + (!count($processedSegments) || $lastSegment !== $currentSegment) && (!in_array($lastSegment, $processedSegments) || !in_array($currentSegment, $processedSegments)) ) { $this->writeXLSX( @@ -173,7 +174,8 @@ class Export { $lastSegment = ucwords($subscriber['segment_name']); // detect RTL language and set Excel to properly display the sheet $rTLRegex = '/\p{Arabic}|\p{Hebrew}/u'; - if (!$xLSXWriter->rtl && ( + if ( + !$xLSXWriter->rtl && ( preg_grep($rTLRegex, $subscriber) || preg_grep($rTLRegex, $this->formattedSubscriberFieldsWithList)) ) { diff --git a/lib/Subscribers/ImportExport/Import/Import.php b/lib/Subscribers/ImportExport/Import/Import.php index 0492a89aec..6e58fe1427 100644 --- a/lib/Subscribers/ImportExport/Import/Import.php +++ b/lib/Subscribers/ImportExport/Import/Import.php @@ -104,8 +104,9 @@ class Import { ]; // 1. data should contain all required fields // 2. column names should only contain alphanumeric & underscore characters - if (count(array_intersect_key(array_flip($requiredDataFields), $data)) !== count($requiredDataFields) || - preg_grep('/[^a-zA-Z0-9_]/', array_keys($data['columns'])) + if ( + count(array_intersect_key(array_flip($requiredDataFields), $data)) !== count($requiredDataFields) || + preg_grep('/[^a-zA-Z0-9_]/', array_keys($data['columns'])) ) { throw new \Exception(__('Missing or invalid import data.', 'mailpoet')); } @@ -268,7 +269,7 @@ class Import { // We attempt converting with both date formats foreach ($data as $index => $date) { - if (empty($date) ) { + if (empty($date)) { $dateTimeDates[$index] = $date; $customFormatDates[$index] = $date; continue; diff --git a/lib/Subscription/Captcha.php b/lib/Subscription/Captcha.php index 889991b3c4..2f4b65caf7 100644 --- a/lib/Subscription/Captcha.php +++ b/lib/Subscription/Captcha.php @@ -55,7 +55,8 @@ class Captcha { // Check limits per recipient if enabled if ($subscriberEmail) { $subscriber = Subscriber::where('email', $subscriberEmail)->findOne(); - if ($subscriber instanceof Subscriber + if ( + $subscriber instanceof Subscriber && $subscriber->countConfirmations >= $subscriptionCaptchaRecipientLimit ) { return true; diff --git a/lib/Subscription/Pages.php b/lib/Subscription/Pages.php index a8ecf0d410..57fe5365d1 100644 --- a/lib/Subscription/Pages.php +++ b/lib/Subscription/Pages.php @@ -205,7 +205,8 @@ class Pages { } public function unsubscribe() { - if (!$this->isPreview() + if ( + !$this->isPreview() && ($this->subscriber !== null) && ($this->subscriber->status !== Subscriber::STATUS_UNSUBSCRIBED) ) { diff --git a/lib/WP/DateTime.php b/lib/WP/DateTime.php index b8921f0e41..2d49a9b3e6 100644 --- a/lib/WP/DateTime.php +++ b/lib/WP/DateTime.php @@ -34,23 +34,23 @@ class DateTime { return $dateFormat; } - public function getCurrentTime($format=false) { + public function getCurrentTime($format = false) { if (empty($format)) $format = $this->getTimeFormat(); return $this->wp->currentTime($format); } - public function getCurrentDate($format=false) { + public function getCurrentDate($format = false) { if (empty($format)) $format = $this->getDateFormat(); return $this->getCurrentTime($format); } - public function formatTime($timestamp, $format=false) { + public function formatTime($timestamp, $format = false) { if (empty($format)) $format = $this->getTimeFormat(); return date($format, $timestamp); } - public function formatDate($timestamp, $format=false) { + public function formatDate($timestamp, $format = false) { if (empty($format)) $format = $this->getDateFormat(); return date($format, $timestamp); @@ -61,9 +61,9 @@ class DateTime { * formatted and mapped from DEFAULT_TIME_FORMAT to WordPress time strings. */ public function getTimeInterval( - $startTime='00:00:00', - $timeStep='+1 hour', - $totalSteps=24 + $startTime = '00:00:00', + $timeStep = '+1 hour', + $totalSteps = 24 ) { $steps = []; diff --git a/lib/WP/Functions.php b/lib/WP/Functions.php index 0f9b5aa2ff..4d3b24269a 100644 --- a/lib/WP/Functions.php +++ b/lib/WP/Functions.php @@ -559,7 +559,7 @@ class Functions { return wp_parse_url($url, $component); } - public function wpSpecialcharsDecode($string, $quoteStyle = ENT_NOQUOTES ) { + public function wpSpecialcharsDecode($string, $quoteStyle = ENT_NOQUOTES) { return wp_specialchars_decode($string, $quoteStyle); } diff --git a/mailpoet_initializer.php b/mailpoet_initializer.php index 057c73697f..7a4844cb0c 100644 --- a/mailpoet_initializer.php +++ b/mailpoet_initializer.php @@ -65,7 +65,8 @@ Env::init( $requirements = new RequirementsChecker(); $requirementsCheckResults = $requirements->checkAllRequirements(); -if (!$requirementsCheckResults[RequirementsChecker::TEST_PDO_EXTENSION] || +if ( + !$requirementsCheckResults[RequirementsChecker::TEST_PDO_EXTENSION] || !$requirementsCheckResults[RequirementsChecker::TEST_VENDOR_SOURCE] ) { return; diff --git a/tasks/code_sniffer/MailPoet/Sniffs/ControlStructures/FunctionDeclarationSniff.php b/tasks/code_sniffer/MailPoet/Sniffs/ControlStructures/FunctionDeclarationSniff.php index a648e72649..7a528da7fe 100644 --- a/tasks/code_sniffer/MailPoet/Sniffs/ControlStructures/FunctionDeclarationSniff.php +++ b/tasks/code_sniffer/MailPoet/Sniffs/ControlStructures/FunctionDeclarationSniff.php @@ -54,7 +54,8 @@ class FunctionDeclarationSniff implements Sniff { public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - if (isset($tokens[$stackPtr]['parenthesis_opener']) === false + if ( + isset($tokens[$stackPtr]['parenthesis_opener']) === false || isset($tokens[$stackPtr]['parenthesis_closer']) === false || $tokens[$stackPtr]['parenthesis_opener'] === null || $tokens[$stackPtr]['parenthesis_closer'] === null @@ -156,7 +157,8 @@ class FunctionDeclarationSniff implements Sniff { $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($opener - 1), $closeBracket, true); $next = $phpcsFile->findNext(T_WHITESPACE, ($opener + 1), null, true); - if ($tokens[$prev]['line'] < $tokens[$opener]['line'] + if ( + $tokens[$prev]['line'] < $tokens[$opener]['line'] && $tokens[$next]['line'] > $tokens[$opener]['line'] ) { // Clear the whole line. @@ -242,7 +244,8 @@ class FunctionDeclarationSniff implements Sniff { true ); - if ($tokens[$closeBracket]['line'] !== $tokens[$tokens[$closeBracket]['parenthesis_opener']]['line'] + if ( + $tokens[$closeBracket]['line'] !== $tokens[$tokens[$closeBracket]['parenthesis_opener']]['line'] && $tokens[$prev]['line'] === $tokens[$closeBracket]['line'] ) { $error = 'The closing parenthesis of a multi-line ' . $type . ' declaration must be on a new line'; @@ -268,7 +271,8 @@ class FunctionDeclarationSniff implements Sniff { true ); - if ($tokens[$closeBracket]['line'] !== $tokens[$tokens[$closeBracket]['parenthesis_opener']]['line'] + if ( + $tokens[$closeBracket]['line'] !== $tokens[$tokens[$closeBracket]['parenthesis_opener']]['line'] && $tokens[$prev]['line'] === $tokens[$closeBracket]['line'] ) { $error = 'The closing parenthesis of a multi-line use declaration must be on a new line'; @@ -285,7 +289,8 @@ class FunctionDeclarationSniff implements Sniff { $lastLine = $tokens[$openBracket]['line']; for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { if ($tokens[$i]['line'] !== $lastLine) { - if ($i === $tokens[$stackPtr]['parenthesis_closer'] + if ( + $i === $tokens[$stackPtr]['parenthesis_closer'] || ($tokens[$i]['code'] === T_WHITESPACE && (($i + 1) === $closeBracket || ($i + 1) === $tokens[$stackPtr]['parenthesis_closer'])) diff --git a/tasks/form-export/form-export.php b/tasks/form-export/form-export.php index 48200a4fa0..177bd0f351 100644 --- a/tasks/form-export/form-export.php +++ b/tasks/form-export/form-export.php @@ -177,7 +177,7 @@ function mailpoetReplaceAssetUrl(string $url): array { /** * @see https://stackoverflow.com/questions/24316347/how-to-format-var-export-to-php5-4-array-syntax */ -function mailpoetVarExport($var, $indent=" "): string { +function mailpoetVarExport($var, $indent = " "): string { switch (gettype($var)) { case 'string': return '\'' . addcslashes($var, "\\\$'\r\n\t\v\f") . '\''; diff --git a/tests/_support/DefaultsExtension.php b/tests/_support/DefaultsExtension.php index fbde0b75cd..16fec52a09 100644 --- a/tests/_support/DefaultsExtension.php +++ b/tests/_support/DefaultsExtension.php @@ -94,7 +94,7 @@ class DefaultsExtension extends Extension { delete_transient('_wc_activation_redirect'); // mark all WC cron actions complete - $tableName = ! empty($wpdb->actionscheduler_actions) ? $wpdb->actionscheduler_actions : $wpdb->prefix . 'actionscheduler_actions';// phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps + $tableName = !empty($wpdb->actionscheduler_actions) ? $wpdb->actionscheduler_actions : $wpdb->prefix . 'actionscheduler_actions';// phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps $sql = "UPDATE {$tableName} SET status = 'complete'"; $wpdb->query($sql); } diff --git a/tests/acceptance/Newsletters/EditorProductsCest.php b/tests/acceptance/Newsletters/EditorProductsCest.php index c314a03224..e9d87b1e04 100644 --- a/tests/acceptance/Newsletters/EditorProductsCest.php +++ b/tests/acceptance/Newsletters/EditorProductsCest.php @@ -68,7 +68,7 @@ class EditorProductsCest { } // Add product image - $image = $i->cliToArray(['media', 'import', dirname(__DIR__) . '/../_data/600x400.jpg', '--title="A product picture"', '--porcelain']); + $image = $i->cliToArray(['media', 'import', dirname(__DIR__) . '/../_data/600x400.jpg', '--title="A product picture"', '--porcelain']); $imageUrlData = $i->cliToArray(['post', 'get', $image[0], '--field=guid']); $imageUrl = $imageUrlData[0]; diff --git a/tests/integration/API/JSON/v1/SegmentsTest.php b/tests/integration/API/JSON/v1/SegmentsTest.php index b26abea5e0..62bae20a77 100644 --- a/tests/integration/API/JSON/v1/SegmentsTest.php +++ b/tests/integration/API/JSON/v1/SegmentsTest.php @@ -250,7 +250,7 @@ class SegmentsTest extends \MailPoetTest { expect($subsribers)->count(0); } - private function createForm(string $formName, array $settings ) { + private function createForm(string $formName, array $settings) { $form = new FormEntity($formName); $form->setSettings($settings); $this->entityManager->persist($form); diff --git a/tests/integration/Cron/Workers/WooCommerceOrdersTest.php b/tests/integration/Cron/Workers/WooCommerceOrdersTest.php index 7dc349317b..2997a27335 100644 --- a/tests/integration/Cron/Workers/WooCommerceOrdersTest.php +++ b/tests/integration/Cron/Workers/WooCommerceOrdersTest.php @@ -123,7 +123,7 @@ class WooCommerceOrdersTest extends \MailPoetTest { $this->entityManager->clear(); $tasks = $this->scheduledTaskRepository->findBy(['type' => WooCommercePastOrders::TASK_TYPE]); expect($tasks)->count(1); - expect($tasks[0]->getStatus())->equals(null); // null means 'running' + expect($tasks[0]->getStatus())->equals(null); // null means 'running' } public function testItContinuesFromLastId() { diff --git a/tests/integration/Newsletter/RendererTest.php b/tests/integration/Newsletter/RendererTest.php index 35bfd0e31c..1d61e9d66a 100644 --- a/tests/integration/Newsletter/RendererTest.php +++ b/tests/integration/Newsletter/RendererTest.php @@ -663,7 +663,7 @@ class RendererTest extends \MailPoetTest { } public function makeAttachment($upload, $parentPostId = 0) { - if ( ! function_exists( 'wp_crop_image' ) ) { + if (!function_exists( 'wp_crop_image' )) { include( ABSPATH . 'wp-admin/includes/image.php' ); } diff --git a/tests/integration/Newsletter/Scheduler/PostNotificationTest.php b/tests/integration/Newsletter/Scheduler/PostNotificationTest.php index 35cbc20dfe..0ac4b73908 100644 --- a/tests/integration/Newsletter/Scheduler/PostNotificationTest.php +++ b/tests/integration/Newsletter/Scheduler/PostNotificationTest.php @@ -339,7 +339,7 @@ class PostNotificationTest extends \MailPoetTest { } private function createNewsletterOptions(NewsletterEntity $newsletter, array $options) { - foreach ($options as $name => $value) { + foreach ($options as $name => $value) { $newsletterOptionField = $this->newsletterOptionFieldsRepository->findOneBy([ 'name' => $name, ]); diff --git a/tests/integration/Subscribers/ImportExport/Import/ImportTest.php b/tests/integration/Subscribers/ImportExport/Import/ImportTest.php index 13f3a6de37..2ee5b70fca 100644 --- a/tests/integration/Subscribers/ImportExport/Import/ImportTest.php +++ b/tests/integration/Subscribers/ImportExport/Import/ImportTest.php @@ -309,7 +309,7 @@ class ImportTest extends \MailPoetTest { 'subscribed_ip' => '127.0.0.1', 'confirmed_at' => '2020-12-31 16:32:48', 'confirmed_ip' => '127.1.1.1', - ], [ + ], [ 'first_name' => 'Steve', 'last_name' => 'Sorrow', 'email' => 'sTeve.sorrow@exaMple.com',