From d82507dcb5b36085f2fd4a9af7bde48b1b0f1472 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 7 Apr 2016 18:23:01 +0200 Subject: [PATCH] Unify code style for short syntax arrays --- .../form/AbstractBulkProcessingForm.class.php | 2 +- .../lib/acp/form/UserSearchForm.class.php | 2 +- wcfsetup/install/files/lib/core.functions.php | 8 +-- .../item/ClipboardItemAction.class.php | 4 +- .../lib/data/cronjob/CronjobEditor.class.php | 2 +- .../files/lib/data/tag/TagAction.class.php | 2 +- .../BackgroundQueueHandler.class.php | 6 +- ...AbstractUserBulkProcessingAction.class.php | 2 +- ...erGroupsUserBulkProcessingAction.class.php | 8 +-- ...TemplateListenerCodeCacheBuilder.class.php | 2 +- .../UserGroupPermissionCacheBuilder.class.php | 4 +- .../action/MediaClipboardAction.class.php | 2 +- .../action/TagClipboardAction.class.php | 6 +- ...tractObjectTextPropertyCondition.class.php | 4 +- .../AbstractTimestampCondition.class.php | 6 +- .../BackgroundQueueCleanUpCronjob.class.php | 4 +- .../DatabaseQueryExecutionException.class.php | 2 +- .../files/lib/system/email/Email.class.php | 58 +++++++++---------- .../email/mime/AbstractMimePart.class.php | 2 +- .../email/mime/AttachmentMimePart.class.php | 2 +- .../transport/SmtpEmailTransport.class.php | 38 ++++++------ .../DefaultUploadFileSaveStrategy.class.php | 12 ++-- 22 files changed, 89 insertions(+), 89 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php index 6dc51d4210..8574c0d709 100644 --- a/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php @@ -100,7 +100,7 @@ abstract class AbstractBulkProcessingForm extends AbstractForm { foreach ($conditionObjectTypes as $objectType) { if ($objectType->conditiongroup) { if (!isset($this->conditions[$objectType->conditiongroup])) { - $this->conditions[$objectType->conditiongroup] = [ ]; + $this->conditions[$objectType->conditiongroup] = []; } $this->conditions[$objectType->conditiongroup][$objectType->objectTypeID] = $objectType; diff --git a/wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php b/wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php index e270a5576b..c3b916eb6e 100755 --- a/wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php @@ -143,7 +143,7 @@ class UserSearchForm extends UserOptionListForm { if (!$objectType->conditiongroup) continue; if (!isset($this->conditions[$objectType->conditiongroup])) { - $this->conditions[$objectType->conditiongroup] = [ ]; + $this->conditions[$objectType->conditiongroup] = []; } $this->conditions[$objectType->conditiongroup][$objectType->objectTypeID] = $objectType; diff --git a/wcfsetup/install/files/lib/core.functions.php b/wcfsetup/install/files/lib/core.functions.php index b7929b326d..8b1b806398 100644 --- a/wcfsetup/install/files/lib/core.functions.php +++ b/wcfsetup/install/files/lib/core.functions.php @@ -10,13 +10,13 @@ namespace { use wcf\system\WCF; // set exception handler - set_exception_handler([ WCF::class, 'handleException' ]); + set_exception_handler([WCF::class, 'handleException']); // set php error handler - set_error_handler([ WCF::class, 'handleError' ], E_ALL); + set_error_handler([WCF::class, 'handleError'], E_ALL); // set shutdown function - register_shutdown_function([ WCF::class, 'destruct' ]); + register_shutdown_function([WCF::class, 'destruct']); // set autoload function - spl_autoload_register([ WCF::class, 'autoload' ]); + spl_autoload_register([WCF::class, 'autoload']); // define escape string shortcut function escapeString($string) { diff --git a/wcfsetup/install/files/lib/data/clipboard/item/ClipboardItemAction.class.php b/wcfsetup/install/files/lib/data/clipboard/item/ClipboardItemAction.class.php index dfda53652d..5decb765ba 100644 --- a/wcfsetup/install/files/lib/data/clipboard/item/ClipboardItemAction.class.php +++ b/wcfsetup/install/files/lib/data/clipboard/item/ClipboardItemAction.class.php @@ -109,7 +109,7 @@ class ClipboardItemAction extends AbstractDatabaseObjectAction { public function unmarkAll() { ClipboardHandler::getInstance()->unmarkAll($this->objectTypeID); - return [ 'objectType' => $this->parameters['objectType'] ]; + return ['objectType' => $this->parameters['objectType']]; } /** @@ -158,7 +158,7 @@ class ClipboardItemAction extends AbstractDatabaseObjectAction { 'actionName' => $item->getName(), 'internalData' => $item->getInternalData(), 'parameters' => $item->getParameters(), - 'label' => WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.' . $item->getName(), [ 'count' => $item->getCount() ]), + 'label' => WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.' . $item->getName(), ['count' => $item->getCount()]), 'url' => $item->getURL() ]; } diff --git a/wcfsetup/install/files/lib/data/cronjob/CronjobEditor.class.php b/wcfsetup/install/files/lib/data/cronjob/CronjobEditor.class.php index 9ac7b9eb6b..567020c5bc 100644 --- a/wcfsetup/install/files/lib/data/cronjob/CronjobEditor.class.php +++ b/wcfsetup/install/files/lib/data/cronjob/CronjobEditor.class.php @@ -96,7 +96,7 @@ class CronjobEditor extends DatabaseObjectEditor implements IEditableCachedObjec $sql = "DELETE FROM wcf".WCF_N."_language_item WHERE languageItem = ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([ 'wcf.acp.cronjob.description.cronjob'.$this->cronjobID ]); + $statement->execute(['wcf.acp.cronjob.description.cronjob'.$this->cronjobID]); } // save new descriptions diff --git a/wcfsetup/install/files/lib/data/tag/TagAction.class.php b/wcfsetup/install/files/lib/data/tag/TagAction.class.php index b2fcee0534..c41754f2e0 100644 --- a/wcfsetup/install/files/lib/data/tag/TagAction.class.php +++ b/wcfsetup/install/files/lib/data/tag/TagAction.class.php @@ -109,7 +109,7 @@ class TagAction extends AbstractDatabaseObjectAction implements ISearchAction { * @since 2.2 */ public function validateSetAsSynonyms() { - WCF::getSession()->checkPermissions([ 'admin.content.tag.canManageTag' ]); + WCF::getSession()->checkPermissions(['admin.content.tag.canManageTag']); if (empty($this->objects)) { $this->readObjects(); diff --git a/wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php b/wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php index 067df51e14..b457446b46 100644 --- a/wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php +++ b/wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php @@ -54,7 +54,7 @@ class BackgroundQueueHandler extends SingletonFactory { if ($time < TIME_NOW) { throw new SystemException("You may not schedule a job in the past (".$time." is smaller than the current timestamp ".TIME_NOW.")."); } - if (!is_array($jobs)) $jobs = [ $jobs ]; + if (!is_array($jobs)) $jobs = [$jobs]; foreach ($jobs as $job) { if (!($job instanceof AbstractBackgroundJob)) { throw new SystemException('$jobs contains an item that does not extend \wcf\system\background\job\AbstractBackgroundJob.'); @@ -194,7 +194,7 @@ class BackgroundQueueHandler extends SingletonFactory { $sql = "DELETE FROM wcf".WCF_N."_background_job WHERE jobID = ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([ $row['jobID'] ]); + $statement->execute([$row['jobID']]); } } @@ -212,7 +212,7 @@ class BackgroundQueueHandler extends SingletonFactory { WHERE status = ? AND time <= ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([ 'ready', TIME_NOW ]); + $statement->execute(['ready', TIME_NOW]); return $statement->fetchSingleColumn(); } diff --git a/wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserBulkProcessingAction.class.php b/wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserBulkProcessingAction.class.php index 2c0aa34c20..0c97412380 100644 --- a/wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserBulkProcessingAction.class.php +++ b/wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserBulkProcessingAction.class.php @@ -36,7 +36,7 @@ abstract class AbstractUserBulkProcessingAction extends AbstractBulkProcessingAc protected function getAccessibleUsers(UserList $userList) { // fetch user group ids of all users $conditionBuilder = new PreparedStatementConditionBuilder(); - $conditionBuilder->add('userID IN (?)', [ $userList->getObjectIDs() ]); + $conditionBuilder->add('userID IN (?)', [$userList->getObjectIDs()]); $sql = "SELECT userID, groupID FROM wcf".WCF_N."_user_to_group diff --git a/wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserGroupsUserBulkProcessingAction.class.php b/wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserGroupsUserBulkProcessingAction.class.php index e9eddd6007..3197018396 100644 --- a/wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserGroupsUserBulkProcessingAction.class.php +++ b/wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserGroupsUserBulkProcessingAction.class.php @@ -27,7 +27,7 @@ abstract class AbstractUserGroupsUserBulkProcessingAction extends AbstractUserBu * list of available user groups * @var UserGroup[] */ - public $availableUserGroups = [ ]; + public $availableUserGroups = []; /** * name of the inputs used to store the selected user group ids @@ -39,7 +39,7 @@ abstract class AbstractUserGroupsUserBulkProcessingAction extends AbstractUserBu * ids of selected user groups * @var integer[] */ - public $userGroupIDs = [ ]; + public $userGroupIDs = []; /** * @see \wcf\data\DatabaseObjectDecorator::__construct() @@ -47,7 +47,7 @@ abstract class AbstractUserGroupsUserBulkProcessingAction extends AbstractUserBu public function __construct(DatabaseObject $object) { parent::__construct($object); - $this->availableUserGroups = UserGroup::getAccessibleGroups([ ], [ UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS ]); + $this->availableUserGroups = UserGroup::getAccessibleGroups([], [UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]); uasort($this->availableUserGroups, function(UserGroup $groupA, UserGroup $groupB) { return strcmp($groupA->getName(), $groupB->getName()); @@ -110,7 +110,7 @@ abstract class AbstractUserGroupsUserBulkProcessingAction extends AbstractUserBu * @see \wcf\system\bulk\processing\IBulkProcessingAction::reset() */ public function reset() { - $this->userGroupIDs = [ ]; + $this->userGroupIDs = []; } /** diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php index 81bff15522..1bde544370 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php @@ -35,7 +35,7 @@ class TemplateListenerCodeCacheBuilder extends AbstractCacheBuilder { if ($templateListener->options || $templateListener->permissions) { $templateCode = '{if '; - $options = $permissions = [ ]; + $options = $permissions = []; if ($templateListener->options) { $options = explode(',', strtoupper($templateListener->options)); diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php index df0f49fc79..d0ff5ab55b 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php @@ -31,7 +31,7 @@ class UserGroupPermissionCacheBuilder extends AbstractCacheBuilder { // get option values $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("option_value.groupID IN (?)", [ $parameters ]); + $conditions->add("option_value.groupID IN (?)", [$parameters]); $sql = "SELECT option_table.optionName, option_table.optionType, option_value.optionValue FROM wcf".WCF_N."_user_group_option_value option_value @@ -42,7 +42,7 @@ class UserGroupPermissionCacheBuilder extends AbstractCacheBuilder { $statement->execute($conditions->getParameters()); while ($row = $statement->fetchArray()) { if (!isset($data[$row['optionName']])) { - $data[$row['optionName']] = [ 'type' => $row['optionType'], 'values' => [] ]; + $data[$row['optionName']] = ['type' => $row['optionType'], 'values' => []]; } $data[$row['optionName']]['values'][] = $row['optionValue']; diff --git a/wcfsetup/install/files/lib/system/clipboard/action/MediaClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/MediaClipboardAction.class.php index 79a7898e33..f999d53216 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/MediaClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/MediaClipboardAction.class.php @@ -19,7 +19,7 @@ class MediaClipboardAction extends AbstractClipboardAction { /** * @inheritdoc */ - protected $actionClassActions = [ 'delete' ]; + protected $actionClassActions = ['delete']; /** * @inheritdoc diff --git a/wcfsetup/install/files/lib/system/clipboard/action/TagClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/TagClipboardAction.class.php index dc15c2dce8..5ad1fa1cc4 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/TagClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/TagClipboardAction.class.php @@ -74,7 +74,7 @@ class TagClipboardAction extends AbstractClipboardAction { */ protected function validateDelete() { if (!WCF::getSession()->getPermission('admin.content.tag.canManageTag')) { - return [ ]; + return []; } return array_keys($this->objects); @@ -87,11 +87,11 @@ class TagClipboardAction extends AbstractClipboardAction { */ protected function validateSetAsSynonyms() { if (!WCF::getSession()->getPermission('admin.content.tag.canManageTag')) { - return [ ]; + return []; } if (count($this->objects) < 2) { - return [ ]; + return []; } return array_keys($this->objects); diff --git a/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php index 8ae5aec7da..33c73b1ec0 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php @@ -43,10 +43,10 @@ abstract class AbstractObjectTextPropertyCondition extends AbstractTextCondition if (!($objectList instanceof $className)) return; if ($this->supportsMultipleValues) { - $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' IN (?)', [ $conditionData[$this->fieldName] ]); + $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' IN (?)', [$conditionData[$this->fieldName]]); } else { - $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' = ?', [ $conditionData[$this->fieldName] ]); + $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' = ?', [$conditionData[$this->fieldName]]); } } diff --git a/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php index cbcf45f3f0..34208c7ac4 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php @@ -50,12 +50,12 @@ abstract class AbstractTimestampCondition extends AbstractSingleFieldCondition i $className = $this->getListClassName(); if (!($objectList instanceof $className)) return; - $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' <> ?', [ 0 ]); + $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' <> ?', [0]); if (isset($conditionData['endTime'])) { - $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' < ?', [ strtotime($conditionData['endTime']) + 86400 ]); + $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' < ?', [strtotime($conditionData['endTime']) + 86400]); } if (isset($conditionData['startTime'])) { - $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' >= ?', [ strtotime($conditionData['startTime']) ]); + $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' >= ?', [strtotime($conditionData['startTime'])]); } } diff --git a/wcfsetup/install/files/lib/system/cronjob/BackgroundQueueCleanUpCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/BackgroundQueueCleanUpCronjob.class.php index c028f2c138..a37faf7aba 100644 --- a/wcfsetup/install/files/lib/system/cronjob/BackgroundQueueCleanUpCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/BackgroundQueueCleanUpCronjob.class.php @@ -38,7 +38,7 @@ class BackgroundQueueCleanUpCronjob extends AbstractCronjob { TIME_NOW - 600 // running longer than 10 minutes ]); - $jobIDs = [ ]; + $jobIDs = []; while ($row = $statement->fetchArray()) { $jobIDs[] = $row['jobID']; @@ -67,7 +67,7 @@ class BackgroundQueueCleanUpCronjob extends AbstractCronjob { // delete jobs $condition = new PreparedStatementConditionBuilder(); - $condition->add('jobID IN (?)', [ $jobIDs ]); + $condition->add('jobID IN (?)', [$jobIDs]); $sql = "DELETE FROM wcf".WCF_N."_background_job ".$condition; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($condition->getParameters()); diff --git a/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php b/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php index e2c8c65c93..84e1b90b9c 100644 --- a/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php +++ b/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php @@ -44,7 +44,7 @@ class DatabaseQueryExecutionException extends DatabaseQueryException implements public function getExtraInformation() { return array_map(function ($val) { static $i = 0; - return [ 'Query Parameter '.(++$i), $val ]; + return ['Query Parameter '.(++$i), $val]; }, $this->getParameters()); } } diff --git a/wcfsetup/install/files/lib/system/email/Email.class.php b/wcfsetup/install/files/lib/system/email/Email.class.php index 09a5996f60..d6db5801e6 100644 --- a/wcfsetup/install/files/lib/system/email/Email.class.php +++ b/wcfsetup/install/files/lib/system/email/Email.class.php @@ -39,7 +39,7 @@ class Email { * Recipients of this email. * @var array */ - protected $recipients = [ ]; + protected $recipients = []; /** * Message-Id header @@ -51,13 +51,13 @@ class Email { * References header * @var Mailbox[] */ - protected $references = [ ]; + protected $references = []; /** * In-Reply-To header * @var Mailbox[] */ - protected $inReplyTo = [ ]; + protected $inReplyTo = []; /** * Date header @@ -75,19 +75,19 @@ class Email { * User specified X-* headers * @var array */ - protected $extraHeaders = [ ]; + protected $extraHeaders = []; /** * Text parts of this email * @var array */ - protected $text = [ ]; + protected $text = []; /** * Attachments of this email * @var array */ - protected $attachments = [ ]; + protected $attachments = []; /** * Boundary between the 'Text' parts of this email @@ -338,7 +338,7 @@ class Email { throw new SystemException("The given type '".$type."' is invalid. Must be one of 'to', 'cc', 'bcc'."); } - $this->recipients[$recipient->getAddress()] = [ $type, $recipient ]; + $this->recipients[$recipient->getAddress()] = [$type, $recipient]; } /** @@ -372,7 +372,7 @@ class Email { throw new SystemException("The header '".$header."' may not be set. You may only set user defined headers (starting with 'X-')."); } - $this->extraHeaders[] = [ $header, EmailGrammar::encodeQuotedPrintableHeader($value) ]; + $this->extraHeaders[] = [$header, EmailGrammar::encodeQuotedPrintableHeader($value)]; } /** @@ -406,10 +406,10 @@ class Email { } if ($part instanceof TextMimePart) { - $this->text[] = [ $priority, $part ]; + $this->text[] = [$priority, $part]; } else { - $this->attachments[] = [ $priority, $part ]; + $this->attachments[] = [$priority, $part]; } } @@ -440,58 +440,58 @@ class Email { * @throws SystemException */ public function getHeaders() { - $headers = [ ]; - $to = [ ]; - $cc = [ ]; + $headers = []; + $to = []; + $cc = []; foreach ($this->getRecipients() as $recipient) { if ($recipient[0] == 'to') $to[] = $recipient[1]; else if ($recipient[0] == 'cc') $cc[] = $recipient[1]; } - $headers[] = [ 'from', (string) $this->getSender() ]; + $headers[] = ['from', (string) $this->getSender()]; if ($this->getReplyTo()->getAddress() !== $this->getSender()->getAddress()) { - $headers[] = [ 'reply-to', (string) $this->getReplyTo() ]; + $headers[] = ['reply-to', (string) $this->getReplyTo()]; } if ($to) { - $headers[] = [ 'to', implode(",\r\n ", $to) ]; + $headers[] = ['to', implode(",\r\n ", $to)]; } else { throw new SystemException("Cannot generate message headers, you must specify a recipient."); } if ($cc) { - $headers[] = [ 'cc', implode(",\r\n ", $cc) ]; + $headers[] = ['cc', implode(",\r\n ", $cc)]; } if ($this->getSubject()) { - $headers[] = [ 'subject', EmailGrammar::encodeQuotedPrintableHeader($this->getSubject()) ]; + $headers[] = ['subject', EmailGrammar::encodeQuotedPrintableHeader($this->getSubject())]; } else { throw new SystemException("Cannot generate message headers, you must specify a subject."); } - $headers[] = [ 'date', $this->getDate()->format(\DateTime::RFC2822) ]; - $headers[] = [ 'message-id', $this->getMessageID() ]; + $headers[] = ['date', $this->getDate()->format(\DateTime::RFC2822)]; + $headers[] = ['message-id', $this->getMessageID()]; if ($this->getReferences()) { - $headers[] = [ 'references', implode(' ', $this->getReferences()) ]; + $headers[] = ['references', implode(' ', $this->getReferences())]; } if ($this->getInReplyTo()) { - $headers[] = [ 'in-reply-to', implode(' ', $this->getInReplyTo()) ]; + $headers[] = ['in-reply-to', implode(' ', $this->getInReplyTo())]; } - $headers[] = [ 'mime-version', '1.0' ]; + $headers[] = ['mime-version', '1.0']; if (!$this->text) { throw new SystemException("Cannot generate message headers, you must specify at least one 'Text' part."); } if ($this->attachments) { - $headers[] = [ 'content-type', "multipart/mixed;\r\n boundary=\"".$this->mimeBoundary."\"" ]; + $headers[] = ['content-type', "multipart/mixed;\r\n boundary=\"".$this->mimeBoundary."\""]; } else { if (count($this->text) > 1) { - $headers[] = [ 'content-type', "multipart/alternative;\r\n boundary=\"".$this->textBoundary."\"" ]; + $headers[] = ['content-type', "multipart/alternative;\r\n boundary=\"".$this->textBoundary."\""]; } else { - $headers[] = [ 'content-type', $this->text[0][1]->getContentType() ]; - $headers[] = [ 'content-transfer-encoding', $this->text[0][1]->getContentTransferEncoding() ]; + $headers[] = ['content-type', $this->text[0][1]->getContentType()]; + $headers[] = ['content-transfer-encoding', $this->text[0][1]->getContentTransferEncoding()]; $headers = array_merge($headers, $this->text[0][1]->getAdditionalHeaders()); } } @@ -599,7 +599,7 @@ class Email { * @return AbstractBackgroundJob[] */ public function getJobs() { - $jobs = [ ]; + $jobs = []; // ensure every header is filled in $this->getHeaders(); @@ -615,7 +615,7 @@ class Email { if ($mimePart[1] instanceof IRecipientAwareMimePart) $mimePart[1]->setRecipient($recipient[1]); } - $data = [ 'mail' => $mail, 'recipient' => $recipient, 'skip' => false ]; + $data = ['mail' => $mail, 'recipient' => $recipient, 'skip' => false]; EventHandler::getInstance()->fireAction($this, 'getJobs', $data); // an event decided that this email should be skipped diff --git a/wcfsetup/install/files/lib/system/email/mime/AbstractMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/AbstractMimePart.class.php index e91c732377..6c88d89107 100644 --- a/wcfsetup/install/files/lib/system/email/mime/AbstractMimePart.class.php +++ b/wcfsetup/install/files/lib/system/email/mime/AbstractMimePart.class.php @@ -38,7 +38,7 @@ abstract class AbstractMimePart { * @return array */ public function getAdditionalHeaders() { - return [ ]; + return []; } /** diff --git a/wcfsetup/install/files/lib/system/email/mime/AttachmentMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/AttachmentMimePart.class.php index acae82d59a..ead796a40b 100644 --- a/wcfsetup/install/files/lib/system/email/mime/AttachmentMimePart.class.php +++ b/wcfsetup/install/files/lib/system/email/mime/AttachmentMimePart.class.php @@ -80,7 +80,7 @@ class AttachmentMimePart extends AbstractMimePart { */ public function getAdditionalHeaders() { return [ - [ 'Content-Disposition', 'attachment; filename='.EmailGrammar::encodeHeader($this->filename) ] + ['Content-Disposition', 'attachment; filename='.EmailGrammar::encodeHeader($this->filename)] ]; } diff --git a/wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php b/wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php index b31d245a8d..66c2560708 100644 --- a/wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php +++ b/wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php @@ -66,7 +66,7 @@ class SmtpEmailTransport implements EmailTransport { * ESMTP features advertised by the server * @var string[] */ - protected $features = [ ]; + protected $features = []; /** * if this property is an instance of \Exception email delivery will be locked @@ -158,7 +158,7 @@ class SmtpEmailTransport implements EmailTransport { } while (true); - return [ $code, $reply ]; + return [$code, $reply]; } /** @@ -177,11 +177,11 @@ class SmtpEmailTransport implements EmailTransport { */ protected function connect() { $this->connection = new RemoteFile($this->host, $this->port); - $this->read([ 220 ]); + $this->read([220]); try { $this->write('EHLO '.Email::getHost()); - $this->features = array_map('strtolower', explode("\n", StringUtil::unifyNewlines($this->read([ 250 ])[1]))); + $this->features = array_map('strtolower', explode("\n", StringUtil::unifyNewlines($this->read([250])[1]))); } catch (SystemException $e) { if ($this->starttls == 'encrypt') { @@ -189,7 +189,7 @@ class SmtpEmailTransport implements EmailTransport { } $this->write('HELO '.Email::getHost()); - $this->features = [ ]; + $this->features = []; } switch ($this->starttls) { @@ -201,7 +201,7 @@ class SmtpEmailTransport implements EmailTransport { $this->starttls(); $this->write('EHLO '.Email::getHost()); - $this->features = array_map('strtolower', explode("\n", StringUtil::unifyNewlines($this->read([ 250 ])[1]))); + $this->features = array_map('strtolower', explode("\n", StringUtil::unifyNewlines($this->read([250])[1]))); break; case 'may': if (in_array('starttls', $this->features)) { @@ -211,7 +211,7 @@ class SmtpEmailTransport implements EmailTransport { catch (SystemException $e) { } $this->write('EHLO '.Email::getHost()); - $this->features = array_map('strtolower', explode("\n", StringUtil::unifyNewlines($this->read([ 250 ])[1]))); + $this->features = array_map('strtolower', explode("\n", StringUtil::unifyNewlines($this->read([250])[1]))); } break; case 'none': @@ -224,7 +224,7 @@ class SmtpEmailTransport implements EmailTransport { */ protected function starttls() { $this->write("STARTTLS"); - $this->read([ 220 ]); + $this->read([220]); if (!$this->connection->setTLS(true)) { throw new TransientFailure('enabling TLS failed'); @@ -243,13 +243,13 @@ class SmtpEmailTransport implements EmailTransport { if ($parameters[0] == 'auth') { // try mechanisms in order of preference - foreach ([ 'login', 'plain' ] as $method) { + foreach (['login', 'plain'] as $method) { if (in_array($method, $parameters)) { switch ($method) { case 'login': try { $this->write('AUTH LOGIN'); - $this->read([ 334 ]); + $this->read([334]); } catch (SystemException $e) { // try next authentication method @@ -257,17 +257,17 @@ class SmtpEmailTransport implements EmailTransport { } $this->write(base64_encode($this->username)); $this->lastWrite = '*redacted*'; - $this->read([ 334 ]); + $this->read([334]); $this->write(base64_encode($this->password)); $this->lastWrite = '*redacted*'; - $this->read([ 235 ]); + $this->read([235]); return; break; case 'plain': // RFC 4616 try { $this->write('AUTH PLAIN'); - $this->read([ 334 ]); + $this->read([334]); } catch (SystemException $e) { // try next authentication method @@ -275,7 +275,7 @@ class SmtpEmailTransport implements EmailTransport { } $this->write(base64_encode("\0".$this->username."\0".$this->password)); $this->lastWrite = '*redacted*'; - $this->read([ 235 ]); + $this->read([235]); return; } } @@ -339,13 +339,13 @@ class SmtpEmailTransport implements EmailTransport { } $this->write('RSET'); - $this->read([ 250 ]); + $this->read([250]); $this->write('MAIL FROM:<'.$email->getSender()->getAddress().'>'); - $this->read([ 250 ]); + $this->read([250]); $this->write('RCPT TO:<'.$envelopeTo->getAddress().'>'); - $this->read([ 250, 251 ]); + $this->read([250, 251]); $this->write('DATA'); - $this->read([ 354 ]); + $this->read([354]); $this->connection->write(implode("\r\n", array_map(function ($item) { // 4.5.2 Transparency // o Before sending a line of mail text, the SMTP client checks the @@ -356,6 +356,6 @@ class SmtpEmailTransport implements EmailTransport { return $item; }, explode("\r\n", $email)))); $this->write("."); - $this->read([ 250 ]); + $this->read([250]); } } diff --git a/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php b/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php index 0083a84275..03e41e2b32 100644 --- a/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php +++ b/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php @@ -63,7 +63,7 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy { * @param array $data * @throws SystemException */ - public function __construct($actionClassName, array $options = [ ], array $data = [ ]) { + public function __construct($actionClassName, array $options = [], array $data = []) { $this->actionClassName = $actionClassName; $this->options = $options; $this->data = $data; @@ -72,13 +72,13 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy { throw new SystemException("'".$this->actionClassName."' does not extend '".AbstractDatabaseObjectAction::class."'"); } - $this->editorClassName = (new $this->actionClassName([ ], ''))->getClassName(); - $baseClass = call_user_func([ $this->editorClassName, 'getBaseClass' ]); + $this->editorClassName = (new $this->actionClassName([], ''))->getClassName(); + $baseClass = call_user_func([$this->editorClassName, 'getBaseClass']); if (!is_subclass_of($baseClass, IFile::class)) { throw new SystemException("'".$this->editorClassName."' does not implement '".IFile::class."'"); } if (is_subclass_of($baseClass, IThumbnailFile::class)) { - $this->options['thumbnailSizes'] = call_user_func([ $baseClass, 'getThumbnailSizes' ]); + $this->options['thumbnailSizes'] = call_user_func([$baseClass, 'getThumbnailSizes']); } } @@ -115,7 +115,7 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy { } } - $action = new $this->actionClassName([ ], 'create', [ + $action = new $this->actionClassName([], 'create', [ 'data' => $data ]); $object = $action->executeAction()['returnValues']; @@ -212,7 +212,7 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy { $adapter = ImageHandler::getInstance()->getAdapter(); $adapter->loadFile($file->getLocation()); - $updateData = [ ]; + $updateData = []; foreach ($this->options['thumbnailSizes'] as $type => $sizeData) { $prefix = 'thumbnail'; if (!empty($type)) { -- 2.20.1