From: colemanw Date: Mon, 2 Oct 2023 19:02:09 +0000 (-0400) Subject: Ext - Convert arrays to short syntax X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a60c8498190d2a3a53dd35ab57248534c1ed3d4e;p=civicrm-core.git Ext - Convert arrays to short syntax --- diff --git a/ext/afform/core/tests/phpunit/bootstrap.php b/ext/afform/core/tests/phpunit/bootstrap.php index 5133778c81..63c9148e8e 100644 --- a/ext/afform/core/tests/phpunit/bootstrap.php +++ b/ext/afform/core/tests/phpunit/bootstrap.php @@ -26,7 +26,7 @@ $loader->register(); */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); diff --git a/ext/afform/mock/tests/phpunit/bootstrap.php b/ext/afform/mock/tests/phpunit/bootstrap.php index bac7c1f297..5fd2c5bf3f 100644 --- a/ext/afform/mock/tests/phpunit/bootstrap.php +++ b/ext/afform/mock/tests/phpunit/bootstrap.php @@ -29,7 +29,7 @@ foreach ([__DIR__] as $dir) { */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); diff --git a/ext/authx/tests/phpunit/bootstrap.php b/ext/authx/tests/phpunit/bootstrap.php index 5133778c81..63c9148e8e 100644 --- a/ext/authx/tests/phpunit/bootstrap.php +++ b/ext/authx/tests/phpunit/bootstrap.php @@ -26,7 +26,7 @@ $loader->register(); */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); diff --git a/ext/contributioncancelactions/tests/phpunit/bootstrap.php b/ext/contributioncancelactions/tests/phpunit/bootstrap.php index 5133778c81..63c9148e8e 100644 --- a/ext/contributioncancelactions/tests/phpunit/bootstrap.php +++ b/ext/contributioncancelactions/tests/phpunit/bootstrap.php @@ -26,7 +26,7 @@ $loader->register(); */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); diff --git a/ext/ewaysingle/tests/phpunit/bootstrap.php b/ext/ewaysingle/tests/phpunit/bootstrap.php index 5133778c81..63c9148e8e 100644 --- a/ext/ewaysingle/tests/phpunit/bootstrap.php +++ b/ext/ewaysingle/tests/phpunit/bootstrap.php @@ -26,7 +26,7 @@ $loader->register(); */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); diff --git a/ext/financialacls/tests/phpunit/bootstrap.php b/ext/financialacls/tests/phpunit/bootstrap.php index 5133778c81..63c9148e8e 100644 --- a/ext/financialacls/tests/phpunit/bootstrap.php +++ b/ext/financialacls/tests/phpunit/bootstrap.php @@ -26,7 +26,7 @@ $loader->register(); */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); diff --git a/ext/flexmailer/src/API/MailingPreview.php b/ext/flexmailer/src/API/MailingPreview.php index 4d3810c4ff..3d6f1f40f1 100644 --- a/ext/flexmailer/src/API/MailingPreview.php +++ b/ext/flexmailer/src/API/MailingPreview.php @@ -59,13 +59,13 @@ class MailingPreview { $job->mailing_id = $mailing->id ?: NULL; $job->status = 'Complete'; - $flexMailer = new FlexMailer(array( + $flexMailer = new FlexMailer([ 'is_preview' => TRUE, 'mailing' => $mailing, 'job' => $job, 'attachments' => \CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id), - )); + ]); if (count($flexMailer->validate()) > 0) { throw new \CRM_Core_Exception("FlexMailer cannot execute: invalid context"); @@ -74,9 +74,9 @@ class MailingPreview { $task = new FlexMailerTask($job->id, $contactID, 'fakehash', 'placeholder@example.com'); - $flexMailer->fireComposeBatch(array($task)); + $flexMailer->fireComposeBatch([$task]); - return civicrm_api3_create_success(array( + return civicrm_api3_create_success([ 'id' => isset($params['id']) ? $params['id'] : NULL, 'contact_id' => $contactID, 'subject' => $task->getMailParam('Subject'), @@ -84,7 +84,7 @@ class MailingPreview { 'body_text' => $task->getMailParam('text'), // Flag our role in processing this - to support tests. '_rendered_by_' => 'flexmailer', - )); + ]); } } diff --git a/ext/flexmailer/src/Event/CheckSendableEvent.php b/ext/flexmailer/src/Event/CheckSendableEvent.php index 3a36f5adbc..8016d658d9 100644 --- a/ext/flexmailer/src/Event/CheckSendableEvent.php +++ b/ext/flexmailer/src/Event/CheckSendableEvent.php @@ -30,7 +30,7 @@ class CheckSendableEvent extends \Civi\Core\Event\GenericHookEvent { * Ex: array('subject' => 'The Subject field is blank'). * Example keys: 'subject', 'name', 'from_name', 'from_email', 'body', 'body_html:unsubscribeUrl'. */ - protected $errors = array(); + protected $errors = []; /** * CheckSendableEvent constructor. diff --git a/ext/flexmailer/src/FlexMailer.php b/ext/flexmailer/src/FlexMailer.php index 844ee66659..194590dc55 100644 --- a/ext/flexmailer/src/FlexMailer.php +++ b/ext/flexmailer/src/FlexMailer.php @@ -77,12 +77,12 @@ class FlexMailer { * Array(string $event => string $class). */ public static function getEventTypes() { - return array( + return [ self::EVENT_RUN => 'Civi\\FlexMailer\\Event\\RunEvent', self::EVENT_WALK => 'Civi\\FlexMailer\\Event\\WalkBatchesEvent', self::EVENT_COMPOSE => 'Civi\\FlexMailer\\Event\\ComposeBatchEvent', self::EVENT_SEND => 'Civi\\FlexMailer\\Event\\SendBatchEvent', - ); + ]; } /** @@ -112,13 +112,13 @@ class FlexMailer { * TRUE if delivery completed. */ public static function createAndRun($job, $deprecatedMessageMailer, $deprecatedTestParams) { - $flexMailer = new \Civi\FlexMailer\FlexMailer(array( + $flexMailer = new \Civi\FlexMailer\FlexMailer([ 'mailing' => \CRM_Mailing_BAO_Mailing::findById($job->mailing_id), 'job' => $job, 'attachments' => \CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $job->mailing_id), 'deprecatedMessageMailer' => $deprecatedMessageMailer, 'deprecatedTestParams' => $deprecatedTestParams, - )); + ]); return $flexMailer->run(); } @@ -131,7 +131,7 @@ class FlexMailer { * - attachments: array * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */ - public function __construct($context = array(), EventDispatcherInterface $dispatcher = NULL) { + public function __construct($context = [], EventDispatcherInterface $dispatcher = NULL) { $this->context = $context; $this->dispatcher = $dispatcher ?: \Civi::service('dispatcher'); } @@ -168,7 +168,7 @@ class FlexMailer { * List of error messages */ public function validate() { - $errors = array(); + $errors = []; if (empty($this->context['mailing'])) { $errors['mailing'] = 'Missing \"mailing\"'; } diff --git a/ext/flexmailer/src/FlexMailerTask.php b/ext/flexmailer/src/FlexMailerTask.php index 5b17485784..738fff80d7 100644 --- a/ext/flexmailer/src/FlexMailerTask.php +++ b/ext/flexmailer/src/FlexMailerTask.php @@ -59,7 +59,7 @@ class FlexMailerTask { * @see MailParams * @see \CRM_Utils_Hook::alterMailParams() */ - private $mailParams = array(); + private $mailParams = []; /** * FlexMailerTask constructor. diff --git a/ext/flexmailer/src/Listener/BasicHeaders.php b/ext/flexmailer/src/Listener/BasicHeaders.php index 025a165e4e..5926ada44c 100644 --- a/ext/flexmailer/src/Listener/BasicHeaders.php +++ b/ext/flexmailer/src/Listener/BasicHeaders.php @@ -37,7 +37,7 @@ class BasicHeaders extends BaseListener { $e->getJob()->id, $task->getEventQueueId(), $task->getHash(), $task->getAddress()); - $mailParams = array(); + $mailParams = []; $mailParams['List-Unsubscribe'] = ""; \CRM_Mailing_BAO_Mailing::addMessageIdHeader($mailParams, 'm', $e->getJob()->id, $task->getEventQueueId(), $task->getHash()); $mailParams['Precedence'] = 'bulk'; diff --git a/ext/flexmailer/src/Listener/DefaultBatcher.php b/ext/flexmailer/src/Listener/DefaultBatcher.php index 028f593c89..56f834ebf0 100644 --- a/ext/flexmailer/src/Listener/DefaultBatcher.php +++ b/ext/flexmailer/src/Listener/DefaultBatcher.php @@ -39,7 +39,7 @@ class DefaultBatcher extends BaseListener { $mailerBatchLimit = \CRM_Core_Config::singleton()->mailerBatchLimit; $eq = \CRM_Mailing_BAO_MailingJob::findPendingTasks($job->id, 'email'); - $tasks = array(); + $tasks = []; while ($eq->fetch()) { if ($mailerBatchLimit > 0 && \CRM_Mailing_BAO_MailingJob::$mailsProcessed >= $mailerBatchLimit) { if (!empty($tasks)) { @@ -61,7 +61,7 @@ class DefaultBatcher extends BaseListener { $e->setCompleted($isDelivered); return; } - $tasks = array(); + $tasks = []; } } diff --git a/ext/flexmailer/src/Listener/DefaultComposer.php b/ext/flexmailer/src/Listener/DefaultComposer.php index 93559b8a1a..25b2e69b5d 100644 --- a/ext/flexmailer/src/Listener/DefaultComposer.php +++ b/ext/flexmailer/src/Listener/DefaultComposer.php @@ -96,13 +96,13 @@ class DefaultComposer extends BaseListener { * @return array */ public function createTokenProcessorContext(ComposeBatchEvent $e) { - $context = array( + $context = [ 'controller' => get_class($this), // FIXME: Use template_type, template_options 'smarty' => defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY ? TRUE : FALSE, 'mailing' => $e->getMailing(), 'mailingId' => $e->getMailing()->id, - ); + ]; return $context; } @@ -119,16 +119,16 @@ class DefaultComposer extends BaseListener { ComposeBatchEvent $e, FlexMailerTask $task ) { - return array( + return [ 'contactId' => $task->getContactId(), 'mailingJobId' => $e->getJob()->id, - 'mailingActionTarget' => array( + 'mailingActionTarget' => [ 'id' => $task->getEventQueueId(), 'hash' => $task->getHash(), 'email' => $task->getAddress(), - ), + ], 'flexMailerTask' => $task, - ); + ]; } /** @@ -146,11 +146,11 @@ class DefaultComposer extends BaseListener { FlexMailerTask $task, TokenRow $row ) { - return array( + return [ 'Subject' => $row->render('subject'), 'text' => $row->render('body_text'), 'html' => $row->render('body_html'), - ); + ]; } /** diff --git a/ext/flexmailer/src/Listener/DefaultSender.php b/ext/flexmailer/src/Listener/DefaultSender.php index d2e0d7b09d..d09386ff11 100644 --- a/ext/flexmailer/src/Listener/DefaultSender.php +++ b/ext/flexmailer/src/Listener/DefaultSender.php @@ -29,7 +29,7 @@ class DefaultSender extends BaseListener { $job_date = \CRM_Utils_Date::isoToMysql($job->scheduled_date); $mailer = \Civi::service('pear_mail'); - $targetParams = $deliveredParams = array(); + $targetParams = $deliveredParams = []; $count = 0; $retryBatch = FALSE; @@ -188,11 +188,11 @@ class DefaultSender extends BaseListener { * @param string $errorMessage */ protected function recordBounce($job, $task, $errorMessage) { - $params = array( + $params = [ 'event_queue_id' => $task->getEventQueueId(), 'job_id' => $job->id, 'hash' => $task->getHash(), - ); + ]; $params = array_merge($params, \CRM_Mailing_BAO_BouncePattern::match($errorMessage) ); diff --git a/ext/flexmailer/src/Listener/RequiredFields.php b/ext/flexmailer/src/Listener/RequiredFields.php index a109b26728..4eaa02d750 100644 --- a/ext/flexmailer/src/Listener/RequiredFields.php +++ b/ext/flexmailer/src/Listener/RequiredFields.php @@ -60,9 +60,9 @@ class RequiredFields extends BaseListener { } if (!$found) { - $e->setError($field, E::ts('Field %1 is required.', array( + $e->setError($field, E::ts('Field %1 is required.', [ 1 => $fieldTitle, - ))); + ])); } unset($found); } diff --git a/ext/flexmailer/src/Listener/RequiredTokens.php b/ext/flexmailer/src/Listener/RequiredTokens.php index e627243c97..1d6a87af65 100644 --- a/ext/flexmailer/src/Listener/RequiredTokens.php +++ b/ext/flexmailer/src/Listener/RequiredTokens.php @@ -66,21 +66,21 @@ class RequiredTokens extends BaseListener { return; } - foreach (array('body_html', 'body_text') as $field) { + foreach (['body_html', 'body_text'] as $field) { $str = $e->getFullBody($field); if (empty($str)) { continue; } foreach ($this->findMissingTokens($str) as $token => $desc) { $e->setError("{$field}:{$token}", E::ts('This message is missing a required token - {%1}: %2', - array(1 => $token, 2 => $desc) + [1 => $token, 2 => $desc] )); } } } public function findMissingTokens($str) { - $missing = array(); + $missing = []; foreach ($this->getRequiredTokens() as $token => $value) { if (!is_array($value)) { if (!preg_match('/(^|[^\{])' . preg_quote('{' . $token . '}') . '/', $str)) { diff --git a/ext/flexmailer/src/Listener/SimpleFilter.php b/ext/flexmailer/src/Listener/SimpleFilter.php index 4d0f1a5571..291be3be95 100644 --- a/ext/flexmailer/src/Listener/SimpleFilter.php +++ b/ext/flexmailer/src/Listener/SimpleFilter.php @@ -65,7 +65,7 @@ class SimpleFilter { */ public static function byColumn(ComposeBatchEvent $e, $field, $filter) { $tasks = $e->getTasks(); - $values = array(); + $values = []; foreach ($tasks as $k => $task) { /** @var \Civi\FlexMailer\FlexMailerTask $task */ @@ -75,7 +75,7 @@ class SimpleFilter { } } - $values = call_user_func_array($filter, array($values, $e)); + $values = call_user_func_array($filter, [$values, $e]); foreach ($values as $k => $value) { $tasks[$k]->setMailParam($field, $value); diff --git a/ext/flexmailer/src/Listener/ToHeader.php b/ext/flexmailer/src/Listener/ToHeader.php index a85a36139b..855cf85ca0 100644 --- a/ext/flexmailer/src/Listener/ToHeader.php +++ b/ext/flexmailer/src/Listener/ToHeader.php @@ -47,7 +47,7 @@ class ToHeader extends BaseListener { * Array(int $contactId => string $displayName). */ protected function getContactNames($tasks) { - $ids = array(); + $ids = []; foreach ($tasks as $task) { /** @var \Civi\FlexMailer\FlexMailerTask $task */ $ids[$task->getContactId()] = $task->getContactId(); @@ -55,14 +55,14 @@ class ToHeader extends BaseListener { $ids = array_filter($ids, 'is_numeric'); if (empty($ids)) { - return array(); + return []; } $idString = implode(',', $ids); $query = \CRM_Core_DAO::executeQuery( "SELECT id, display_name FROM civicrm_contact WHERE id in ($idString)"); - $names = array(); + $names = []; while ($query->fetch()) { $names[$query->id] = $query->display_name; } diff --git a/ext/flexmailer/src/MailParams.php b/ext/flexmailer/src/MailParams.php index b7880e32d7..60e7dde105 100644 --- a/ext/flexmailer/src/MailParams.php +++ b/ext/flexmailer/src/MailParams.php @@ -89,7 +89,7 @@ class MailParams { break; default: - $message->headers(array($key => $value), TRUE); + $message->headers([$key => $value], TRUE); } } diff --git a/ext/flexmailer/src/Services.php b/ext/flexmailer/src/Services.php index 9be823e167..899041e4c9 100644 --- a/ext/flexmailer/src/Services.php +++ b/ext/flexmailer/src/Services.php @@ -29,27 +29,27 @@ class Services { $apiOverrides = $container->setDefinition('civi_flexmailer_api_overrides', new Definition('Civi\API\Provider\ProviderInterface'))->setPublic(TRUE); self::applyStaticFactory($apiOverrides, __CLASS__, 'createApiOverrides'); - $container->setDefinition('civi_flexmailer_required_fields', new Definition('Civi\FlexMailer\Listener\RequiredFields', array( - array( + $container->setDefinition('civi_flexmailer_required_fields', new Definition('Civi\FlexMailer\Listener\RequiredFields', [ + [ 'subject', 'name', 'from_name', 'from_email', '(body_html|body_text)', - ), - )))->setPublic(TRUE); - $container->setDefinition('civi_flexmailer_required_tokens', new Definition('Civi\FlexMailer\Listener\RequiredTokens', array( - array('traditional'), - array( + ], + ]))->setPublic(TRUE); + $container->setDefinition('civi_flexmailer_required_tokens', new Definition('Civi\FlexMailer\Listener\RequiredTokens', [ + ['traditional'], + [ 'domain.address' => ts("Domain address - displays your organization's postal address."), - 'action.optOutUrl or action.unsubscribeUrl' => array( + 'action.optOutUrl or action.unsubscribeUrl' => [ 'action.optOut' => ts("'Opt out via email' - displays an email address for recipients to opt out of receiving emails from your organization."), 'action.optOutUrl' => ts("'Opt out via web page' - creates a link for recipients to click if they want to opt out of receiving emails from your organization. Alternatively, you can include the 'Opt out via email' token."), 'action.unsubscribe' => ts("'Unsubscribe via email' - displays an email address for recipients to unsubscribe from the specific mailing list used to send this message."), 'action.unsubscribeUrl' => ts("'Unsubscribe via web page' - creates a link for recipients to unsubscribe from the specific mailing list used to send this message. Alternatively, you can include the 'Unsubscribe via email' token or one of the Opt-out tokens."), - ), - ), - )))->setPublic(TRUE); + ], + ], + ]))->setPublic(TRUE); $container->setDefinition('civi_flexmailer_abdicator', new Definition('Civi\FlexMailer\Listener\Abdicator'))->setPublic(TRUE); $container->setDefinition('civi_flexmailer_default_batcher', new Definition('Civi\FlexMailer\Listener\DefaultBatcher'))->setPublic(TRUE); @@ -70,7 +70,7 @@ class Services { $container->findDefinition('dispatcher')->addMethodCall('addListenerService', $listenerSpec); } - $container->findDefinition('civi_api_kernel')->addMethodCall('registerApiProvider', array(new Reference('civi_flexmailer_api_overrides'))); + $container->findDefinition('civi_api_kernel')->addMethodCall('registerApiProvider', [new Reference('civi_flexmailer_api_overrides')]); } /** @@ -84,27 +84,27 @@ class Services { * Arguments to pass to addListenerService($eventName, $callbackSvc, $priority). */ protected static function getListenerSpecs() { - $listenerSpecs = array(); + $listenerSpecs = []; - $listenerSpecs[] = array(Validator::EVENT_CHECK_SENDABLE, array('civi_flexmailer_abdicator', 'onCheckSendable'), FM::WEIGHT_START); - $listenerSpecs[] = array(Validator::EVENT_CHECK_SENDABLE, array('civi_flexmailer_required_fields', 'onCheckSendable'), FM::WEIGHT_MAIN); - $listenerSpecs[] = array(Validator::EVENT_CHECK_SENDABLE, array('civi_flexmailer_required_tokens', 'onCheckSendable'), FM::WEIGHT_MAIN); + $listenerSpecs[] = [Validator::EVENT_CHECK_SENDABLE, ['civi_flexmailer_abdicator', 'onCheckSendable'], FM::WEIGHT_START]; + $listenerSpecs[] = [Validator::EVENT_CHECK_SENDABLE, ['civi_flexmailer_required_fields', 'onCheckSendable'], FM::WEIGHT_MAIN]; + $listenerSpecs[] = [Validator::EVENT_CHECK_SENDABLE, ['civi_flexmailer_required_tokens', 'onCheckSendable'], FM::WEIGHT_MAIN]; - $listenerSpecs[] = array(FM::EVENT_RUN, array('civi_flexmailer_default_composer', 'onRun'), FM::WEIGHT_MAIN); - $listenerSpecs[] = array(FM::EVENT_RUN, array('civi_flexmailer_abdicator', 'onRun'), FM::WEIGHT_END); + $listenerSpecs[] = [FM::EVENT_RUN, ['civi_flexmailer_default_composer', 'onRun'], FM::WEIGHT_MAIN]; + $listenerSpecs[] = [FM::EVENT_RUN, ['civi_flexmailer_abdicator', 'onRun'], FM::WEIGHT_END]; - $listenerSpecs[] = array(FM::EVENT_WALK, array('civi_flexmailer_default_batcher', 'onWalk'), FM::WEIGHT_END); + $listenerSpecs[] = [FM::EVENT_WALK, ['civi_flexmailer_default_batcher', 'onWalk'], FM::WEIGHT_END]; - $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_basic_headers', 'onCompose'), FM::WEIGHT_PREPARE); - $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_to_header', 'onCompose'), FM::WEIGHT_PREPARE); - $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_bounce_tracker', 'onCompose'), FM::WEIGHT_PREPARE); - $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_default_composer', 'onCompose'), FM::WEIGHT_MAIN - 100); - $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_attachments', 'onCompose'), FM::WEIGHT_ALTER); - $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_open_tracker', 'onCompose'), FM::WEIGHT_ALTER); - $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_test_prefix', 'onCompose'), FM::WEIGHT_ALTER); - $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_hooks', 'onCompose'), FM::WEIGHT_ALTER - 100); + $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_basic_headers', 'onCompose'], FM::WEIGHT_PREPARE]; + $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_to_header', 'onCompose'], FM::WEIGHT_PREPARE]; + $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_bounce_tracker', 'onCompose'], FM::WEIGHT_PREPARE]; + $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_default_composer', 'onCompose'], FM::WEIGHT_MAIN - 100]; + $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_attachments', 'onCompose'], FM::WEIGHT_ALTER]; + $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_open_tracker', 'onCompose'], FM::WEIGHT_ALTER]; + $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_test_prefix', 'onCompose'], FM::WEIGHT_ALTER]; + $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_hooks', 'onCompose'], FM::WEIGHT_ALTER - 100]; - $listenerSpecs[] = array(FM::EVENT_SEND, array('civi_flexmailer_default_sender', 'onSend'), FM::WEIGHT_END); + $listenerSpecs[] = [FM::EVENT_SEND, ['civi_flexmailer_default_sender', 'onSend'], FM::WEIGHT_END]; return $listenerSpecs; } @@ -132,7 +132,7 @@ class Services { */ protected static function applyStaticFactory($def, $factoryClass, $factoryMethod) { if (method_exists($def, 'setFactory')) { - $def->setFactory(array($factoryClass, $factoryMethod)); + $def->setFactory([$factoryClass, $factoryMethod]); } else { $def->setFactoryClass($factoryClass)->setFactoryMethod($factoryMethod); diff --git a/ext/flexmailer/src/Validator.php b/ext/flexmailer/src/Validator.php index 549d028e3c..91ce47b25c 100644 --- a/ext/flexmailer/src/Validator.php +++ b/ext/flexmailer/src/Validator.php @@ -38,10 +38,10 @@ class Validator { } $mailing->copyValues($params); - return (new Validator())->run(array( + return (new Validator())->run([ 'mailing' => $mailing, 'attachments' => \CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id), - )); + ]); } /** diff --git a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/HtmlClickTrackerTest.php b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/HtmlClickTrackerTest.php index 4533fdaecd..687ca67bbd 100644 --- a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/HtmlClickTrackerTest.php +++ b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/HtmlClickTrackerTest.php @@ -23,7 +23,7 @@ class HtmlClickTrackerTest extends \CiviUnitTestCase { // Activate before transactions are setup. $manager = \CRM_Extension_System::singleton()->getManager(); if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) { - $manager->install(array('org.civicrm.flexmailer')); + $manager->install(['org.civicrm.flexmailer']); } parent::setUp(); diff --git a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/TextClickTrackerTest.php b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/TextClickTrackerTest.php index 14da23dd78..a007001c3b 100644 --- a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/TextClickTrackerTest.php +++ b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/TextClickTrackerTest.php @@ -23,7 +23,7 @@ class TextClickTrackerTest extends \CiviUnitTestCase { // Activate before transactions are setup. $manager = \CRM_Extension_System::singleton()->getManager(); if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) { - $manager->install(array('org.civicrm.flexmailer')); + $manager->install(['org.civicrm.flexmailer']); } parent::setUp(); diff --git a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ConcurrentDeliveryTest.php b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ConcurrentDeliveryTest.php index f9f6061b3f..ae1e216beb 100644 --- a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ConcurrentDeliveryTest.php +++ b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ConcurrentDeliveryTest.php @@ -37,7 +37,7 @@ class ConcurrentDeliveryTest extends \api_v3_JobProcessMailingTest { // Activate before transactions are setup. $manager = \CRM_Extension_System::singleton()->getManager(); if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) { - $manager->install(array('org.civicrm.flexmailer')); + $manager->install(['org.civicrm.flexmailer']); } parent::setUp(); diff --git a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/FlexMailerSystemTest.php b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/FlexMailerSystemTest.php index dbba1d7ab5..d91e6ec490 100644 --- a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/FlexMailerSystemTest.php +++ b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/FlexMailerSystemTest.php @@ -43,20 +43,20 @@ class FlexMailerSystemTest extends \CRM_Mailing_BaseMailingSystemTest { // Activate before transactions are setup. $manager = \CRM_Extension_System::singleton()->getManager(); if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) { - $manager->install(array('org.civicrm.flexmailer')); + $manager->install(['org.civicrm.flexmailer']); } parent::setUp(); $dispatcher = \Civi::service('dispatcher'); foreach (FlexMailer::getEventTypes() as $event => $class) { - $dispatcher->addListener($event, array($this, 'handleEvent')); + $dispatcher->addListener($event, [$this, 'handleEvent']); } $hooks = \CRM_Utils_Hook::singleton(); $hooks->setHook('civicrm_alterMailParams', - array($this, 'hook_alterMailParams')); - $this->counts = array(); + [$this, 'hook_alterMailParams']); + $this->counts = []; } public function handleEvent(GenericHookEvent $e) { diff --git a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/Listener/SimpleFilterTest.php b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/Listener/SimpleFilterTest.php index b7d4d7904f..7ae2774f42 100644 --- a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/Listener/SimpleFilterTest.php +++ b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/Listener/SimpleFilterTest.php @@ -33,7 +33,7 @@ class SimpleFilterTest extends \CiviUnitTestCase { // Activate before transactions are setup. $manager = \CRM_Extension_System::singleton()->getManager(); if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) { - $manager->install(array('org.civicrm.flexmailer')); + $manager->install(['org.civicrm.flexmailer']); } parent::setUp(); @@ -49,10 +49,10 @@ class SimpleFilterTest extends \CiviUnitTestCase { SimpleFilter::byValue($e, 'text', function ($value, $t, $e) use ($test) { $test->assertInstanceOf('Civi\FlexMailer\FlexMailerTask', $t); $test->assertInstanceOf('Civi\FlexMailer\Event\ComposeBatchEvent', $e); - $test->assertTrue(in_array($value, array( + $test->assertTrue(in_array($value, [ 'eat more cheese', 'eat more ice cream', - ))); + ])); return preg_replace('/more/', 'thoughtfully considered quantities of', $value); }); @@ -83,15 +83,15 @@ class SimpleFilterTest extends \CiviUnitTestCase { * @return array */ protected function createExampleBatch() { - $tasks = array(); + $tasks = []; $tasks[0] = new FlexMailerTask(1000, 2000, 'asdf', 'foo@example.org'); $tasks[1] = new FlexMailerTask(1001, 2001, 'fdsa', 'bar@example.org'); - $e = new ComposeBatchEvent(array(), $tasks); + $e = new ComposeBatchEvent([], $tasks); $tasks[0]->setMailParam('text', 'eat more cheese'); $tasks[1]->setMailParam('text', 'eat more ice cream'); - return array($tasks, $e); + return [$tasks, $e]; } } diff --git a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/MailingPreviewTest.php b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/MailingPreviewTest.php index d6c72e15c9..ecfe524a73 100644 --- a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/MailingPreviewTest.php +++ b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/MailingPreviewTest.php @@ -24,7 +24,7 @@ class MailingPreviewTest extends \CiviUnitTestCase { // Activate before transactions are setup. $manager = \CRM_Extension_System::singleton()->getManager(); if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) { - $manager->install(array('org.civicrm.flexmailer')); + $manager->install(['org.civicrm.flexmailer']); } parent::setUp(); @@ -35,7 +35,7 @@ class MailingPreviewTest extends \CiviUnitTestCase { $this->_contactID = $this->individualCreate(); $this->_groupID = $this->groupCreate(); $this->_email = 'test@test.test'; - $this->_params = array( + $this->_params = [ 'subject' => 'Hello {contact.display_name}', 'body_text' => "This is {contact.display_name}.\nhttps://civicrm.org\nda=({domain.address}) optout=({action.optOutUrl}) subj=({mailing.subject})", 'body_html' => "

This is {contact.display_name}.

CiviCRM.org

da=({domain.address}) optout=({action.optOutUrl}) subj=({mailing.subject})

", @@ -43,14 +43,14 @@ class MailingPreviewTest extends \CiviUnitTestCase { 'created_id' => $this->_contactID, 'header_id' => '', 'footer_id' => '', - ); + ]; - $this->footer = civicrm_api3('MailingComponent', 'create', array( + $this->footer = civicrm_api3('MailingComponent', 'create', [ 'name' => 'test domain footer', 'component_type' => 'footer', 'body_html' => '

From {domain.address}. To opt out, go to {action.optOutUrl}.

', 'body_text' => 'From {domain.address}. To opt out, go to {action.optOutUrl}.', - )); + ]); } public function tearDown(): void { @@ -63,15 +63,15 @@ class MailingPreviewTest extends \CiviUnitTestCase { // BEGIN SAMPLE DATA $contactID = $this->individualCreate(); $displayName = $this->callAPISuccess('contact', 'get', - array('id' => $contactID)); + ['id' => $contactID]); $displayName = $displayName['values'][$contactID]['display_name']; $this->assertTrue(!empty($displayName)); $params = $this->_params; - $params['api.Mailing.preview'] = array( + $params['api.Mailing.preview'] = [ 'id' => '$value.id', 'contact_id' => $contactID, - ); + ]; $params['options']['force_rollback'] = 1; // END SAMPLE DATA @@ -130,12 +130,12 @@ class MailingPreviewTest extends \CiviUnitTestCase { * Array(string $table => int $maxID). */ protected function getMaxIds() { - return array( + return [ 'civicrm_mailing' => \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing'), 'civicrm_mailing_job' => \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_job'), 'civicrm_mailing_group' => \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_group'), 'civicrm_mailing_recipients' => \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_recipients'), - ); + ]; } /** diff --git a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ValidatorTest.php b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ValidatorTest.php index a0bd66b3d4..08c2592f29 100644 --- a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ValidatorTest.php +++ b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ValidatorTest.php @@ -21,14 +21,14 @@ class ValidatorTest extends \CiviUnitTestCase { // Activate before transactions are setup. $manager = \CRM_Extension_System::singleton()->getManager(); if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) { - $manager->install(array('org.civicrm.flexmailer')); + $manager->install(['org.civicrm.flexmailer']); } parent::setUp(); } public function getExamples() { - $defaults = array( + $defaults = [ 'id' => 123, 'subject' => 'Default subject', 'name' => 'Default name', @@ -37,44 +37,44 @@ class ValidatorTest extends \CiviUnitTestCase { 'body_html' => 'Default HTML body {action.unsubscribeUrl} {domain.address}', 'body_text' => 'Default text body {action.unsubscribeUrl} {domain.address}', 'template_type' => 'traditional', - 'template_options' => array(), - ); + 'template_options' => [], + ]; - $es = array(); - $es[] = array( - array_merge($defaults, array('subject' => NULL)), - array('subject' => '/Field "subject" is required./'), - ); - $es[] = array( - array_merge($defaults, array('subject' => NULL, 'from_name' => NULL)), - array( + $es = []; + $es[] = [ + array_merge($defaults, ['subject' => NULL]), + ['subject' => '/Field "subject" is required./'], + ]; + $es[] = [ + array_merge($defaults, ['subject' => NULL, 'from_name' => NULL]), + [ 'subject' => '/Field "subject" is required./', 'from_name' => '/Field "from_name" is required./', - ), - ); - $es[] = array( - array_merge($defaults, array('body_text' => NULL)), - array(), - ); - $es[] = array( - array_merge($defaults, array('body_html' => NULL)), - array(), - ); - $es[] = array( - array_merge($defaults, array('body_html' => NULL, 'body_text' => NULL)), - array('(body_html|body_text)' => '/Field "body_html" or "body_text" is required./'), - ); - $es[] = array( - array_merge($defaults, array('body_html' => 'Muahaha. I omit the mandatory tokens!')), - array( + ], + ]; + $es[] = [ + array_merge($defaults, ['body_text' => NULL]), + [], + ]; + $es[] = [ + array_merge($defaults, ['body_html' => NULL]), + [], + ]; + $es[] = [ + array_merge($defaults, ['body_html' => NULL, 'body_text' => NULL]), + ['(body_html|body_text)' => '/Field "body_html" or "body_text" is required./'], + ]; + $es[] = [ + array_merge($defaults, ['body_html' => 'Muahaha. I omit the mandatory tokens!']), + [ 'body_html:domain.address' => '/This message is missing.*postal address/', 'body_html:action.optOutUrl or action.unsubscribeUrl' => '/This message is missing.*Unsubscribe via web page/', - ), - ); - $es[] = array( - array_merge($defaults, array('body_html' => 'I omit the mandatory tokens, but checking them is someone else\'s job!', 'template_type' => 'esperanto')), - array(), - ); + ], + ]; + $es[] = [ + array_merge($defaults, ['body_html' => 'I omit the mandatory tokens, but checking them is someone else\'s job!', 'template_type' => 'esperanto']), + [], + ]; return $es; } diff --git a/ext/flexmailer/tests/phpunit/bootstrap.php b/ext/flexmailer/tests/phpunit/bootstrap.php index ed4f208fec..75b1128e99 100644 --- a/ext/flexmailer/tests/phpunit/bootstrap.php +++ b/ext/flexmailer/tests/phpunit/bootstrap.php @@ -32,7 +32,7 @@ if (CIVICRM_UF === 'UnitTests') { */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); $process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__); diff --git a/ext/message_admin/CRM/MessageAdmin/Page/MsgtplBasePage.php b/ext/message_admin/CRM/MessageAdmin/Page/MsgtplBasePage.php index 32a72afe5b..390b1a3cc2 100644 --- a/ext/message_admin/CRM/MessageAdmin/Page/MsgtplBasePage.php +++ b/ext/message_admin/CRM/MessageAdmin/Page/MsgtplBasePage.php @@ -25,9 +25,9 @@ class CRM_MessageAdmin_Page_MsgtplBasePage extends CRM_Core_Page { /** @var \Civi\Angular\AngularLoader $loader */ $loader = \Civi::service('angularjs.loader'); $loader->addModules(['crmMsgadm']); - $loader->useApp(array( + $loader->useApp([ 'defaultRoute' => '/user', - )); + ]); parent::run(); } diff --git a/ext/oauth-client/tests/phpunit/bootstrap.php b/ext/oauth-client/tests/phpunit/bootstrap.php index 4d64ac46f2..a6f64881db 100644 --- a/ext/oauth-client/tests/phpunit/bootstrap.php +++ b/ext/oauth-client/tests/phpunit/bootstrap.php @@ -27,7 +27,7 @@ $loader->register(); */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); diff --git a/ext/payflowpro/tests/phpunit/bootstrap.php b/ext/payflowpro/tests/phpunit/bootstrap.php index 5133778c81..63c9148e8e 100644 --- a/ext/payflowpro/tests/phpunit/bootstrap.php +++ b/ext/payflowpro/tests/phpunit/bootstrap.php @@ -26,7 +26,7 @@ $loader->register(); */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json"); diff --git a/ext/search_kit/tests/phpunit/bootstrap.php b/ext/search_kit/tests/phpunit/bootstrap.php index 5133778c81..63c9148e8e 100644 --- a/ext/search_kit/tests/phpunit/bootstrap.php +++ b/ext/search_kit/tests/phpunit/bootstrap.php @@ -26,7 +26,7 @@ $loader->register(); */ function cv($cmd, $decode = 'json') { $cmd = 'cv ' . $cmd; - $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR]; $oldOutput = getenv('CV_OUTPUT'); putenv("CV_OUTPUT=json");