(NFC) Civi - Autoformat `list()` statements
authorTim Otten <totten@civicrm.org>
Fri, 26 Aug 2022 21:46:37 +0000 (14:46 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 26 Aug 2022 21:50:36 +0000 (14:50 -0700)
Civi/API/Api3SelectQuery.php
Civi/API/Kernel.php
Civi/API/Subscriber/DynamicFKAuthorization.php
Civi/Api4/Provider/ActionObjectProvider.php
Civi/Api4/Query/Api4SelectQuery.php
Civi/Core/SettingsStack.php
Civi/Crypto/CryptoRegistry.php
Civi/Test/Api3TestTrait.php
Civi/Test/HttpTestTrait.php

index 7411d4909ba3c00ff9b3d7343e04b2d240096d6c..3bd6708ffa75f8914a4027bd52139729521b3117 100644 (file)
@@ -76,12 +76,12 @@ class Api3SelectQuery extends SelectQuery {
         // If we check a custom field on 'IS NULL', it should also work when there is no
         // record in the custom value table, see CRM-20740.
         $side = empty($value['IS NULL']) ? 'INNER' : 'LEFT OUTER';
-        list($table_name, $column_name) = $this->addCustomField($this->apiFieldSpec['custom_' . $cf_id], $side);
+        [$table_name, $column_name] = $this->addCustomField($this->apiFieldSpec['custom_' . $cf_id], $side);
       }
       elseif (strpos($key, '.')) {
         $fkInfo = $this->addFkField($key, 'INNER');
         if ($fkInfo) {
-          list($table_name, $column_name) = $fkInfo;
+          [$table_name, $column_name] = $fkInfo;
           $this->validateNestedInput($key, $value);
         }
       }
index 96cc6120fc5f025bd31ba85dc70a032e61eff04d..8dae508a790b552d918d849347e68a7e5a3b4e64 100644 (file)
@@ -120,7 +120,7 @@ class Kernel {
 
     try {
       $this->boot($apiRequest);
-      list($apiProvider, $apiRequest) = $this->resolve($apiRequest);
+      [$apiProvider, $apiRequest] = $this->resolve($apiRequest);
       $this->authorize($apiProvider, $apiRequest);
       return TRUE;
     }
@@ -143,9 +143,9 @@ class Kernel {
   public function runRequest($apiRequest) {
     $this->boot($apiRequest);
 
-    list($apiProvider, $apiRequest) = $this->resolve($apiRequest);
+    [$apiProvider, $apiRequest] = $this->resolve($apiRequest);
     $this->authorize($apiProvider, $apiRequest);
-    list ($apiProvider, $apiRequest) = $this->prepare($apiProvider, $apiRequest);
+    [$apiProvider, $apiRequest] = $this->prepare($apiProvider, $apiRequest);
     $result = $apiProvider->invoke($apiRequest);
 
     return $this->respond($apiProvider, $apiRequest, $result);
index 225a00b402c7505df179750c61807041606f8e7c..ec5a50ac131d1d5d12783d67f3d46cf48d240992 100644 (file)
@@ -156,7 +156,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
       }
 
       if (isset($apiRequest['params']['id'])) {
-        list($isValidId, $entityTable, $entityId) = $this->getDelegate($apiRequest['params']['id']);
+        [$isValidId, $entityTable, $entityId] = $this->getDelegate($apiRequest['params']['id']);
         if ($isValidId && $entityTable && $entityId) {
           $this->authorizeDelegate($apiRequest['action'], $entityTable, $entityId, $apiRequest);
           $this->preventReassignment($apiRequest['params']['id'], $entityTable, $entityId, $apiRequest);
index 2b1b845bb18c7d17f62c18e5be1f99d840074144..8bfa560507170ebbbc0b72d760b69cb0bfc28e69 100644 (file)
@@ -96,7 +96,7 @@ class ActionObjectProvider implements EventSubscriberInterface, ProviderInterfac
    * @throws \API_Exception
    */
   protected function runChain($request, $row) {
-    list($entity, $action, $params, $index) = $request;
+    [$entity, $action, $params, $index] = $request;
     // Swap out variables in $entity, $action & $params
     $this->resolveChainLinks($entity, $row);
     $this->resolveChainLinks($action, $row);
index 0ccce5e8b8d67c9ac9f8f7c52e338613bb7756e4..de08cff0b058039c2504c95c3e813ef761f7670b 100644 (file)
@@ -484,9 +484,9 @@ class Api4SelectQuery {
       }
       // If either the having or select field contains a pseudoconstant suffix, match and perform substitution
       else {
-        list($fieldName) = explode(':', $expr);
+        [$fieldName] = explode(':', $expr);
         foreach ($this->selectAliases as $selectAlias => $selectExpr) {
-          list($selectField) = explode(':', $selectAlias);
+          [$selectField] = explode(':', $selectAlias);
           if ($selectAlias === $selectExpr && $fieldName === $selectField && isset($this->apiFieldSpec[$fieldName])) {
             $field = $this->getField($fieldName);
             FormattingUtil::formatInputValue($value, $expr, $field, $operator);
@@ -712,7 +712,7 @@ class Api4SelectQuery {
       // First item in the array is the entity name
       $entity = array_shift($join);
       // Which might contain an alias. Split on the keyword "AS"
-      list($entity, $alias) = array_pad(explode(' AS ', $entity), 2, NULL);
+      [$entity, $alias] = array_pad(explode(' AS ', $entity), 2, NULL);
       // Ensure permissions
       if (!$this->checkEntityAccess($entity)) {
         continue;
@@ -785,7 +785,7 @@ class Api4SelectQuery {
     $stack = [NULL, NULL];
     // See if the ON clause already contains an FK reference to joinEntity
     $explicitFK = array_filter($joinTree, function($clause) use ($alias, $joinEntityFields) {
-      list($sideA, $op, $sideB) = array_pad((array) $clause, 3, NULL);
+      [$sideA, $op, $sideB] = array_pad((array) $clause, 3, NULL);
       if ($op !== '=' || !$sideB) {
         return FALSE;
       }
@@ -987,7 +987,7 @@ class Api4SelectQuery {
     $bridgeAlias = $side === 'INNER' ? $bridgeAlias : $alias;
     // Find explicit bridge join conditions and move them out of the joinTree
     $joinTree = array_filter($joinTree, function ($clause) use ($baseRef, $alias, $bridgeAlias, &$bridgeConditions) {
-      list($sideA, $op, $sideB) = array_pad((array) $clause, 3, NULL);
+      [$sideA, $op, $sideB] = array_pad((array) $clause, 3, NULL);
       // Skip AND/OR/NOT branches
       if (!$sideB) {
         return TRUE;
index 9183857d5cb6a28e433a2f7363ae3774c2c0c344..5c0e64d3010e1c100e5ea4ab85436aafeb563088 100644 (file)
@@ -43,7 +43,7 @@ class SettingsStack {
    */
   public function popAll() {
     while ($frame = array_pop($this->stack)) {
-      list($setting, $value) = $frame;
+      [$setting, $value] = $frame;
       if ($value === NULL) {
         unset($GLOBALS['civicrm_setting']['domain'][$setting]);
       }
index 5c6fd958da83b7142c91d2207af531359607fde0..0ae3d1afd20b0ccddc24827ac3d26d38c8bb0e7c 100644 (file)
@@ -287,7 +287,7 @@ class CryptoRegistry {
    * @throws CryptoException
    */
   public function parseKey($keyExpr) {
-    list($suite, $keyFunc, $keyVal) = explode(':', $keyExpr);
+    [$suite, $keyFunc, $keyVal] = explode(':', $keyExpr);
     if ($suite === '') {
       $suite = self::DEFAULT_SUITE;
     }
index dafe7e70a63ad275eb59c093ab2f181335f5d8dd..59eb25c063a049e98b821519889167585cae903e 100644 (file)
@@ -639,7 +639,7 @@ trait Api3TestTrait {
     }
 
     // Handle single api call
-    list(, $chainEntity, $chainAction) = explode('.', $key);
+    [, $chainEntity, $chainAction] = explode('.', $key);
     $lcChainEntity = \CRM_Core_DAO_AllCoreTables::convertEntityNameToLower($chainEntity);
     $chainEntity = \CRM_Core_DAO_AllCoreTables::convertEntityNameToCamel($chainEntity);
     $lcMainEntity = \CRM_Core_DAO_AllCoreTables::convertEntityNameToLower($mainEntity);
index 0f6637a58c116422d8de3d260736a64fad377e5a..e3384ecbec2a3d763a84710695ed95aaf4705a3a 100644 (file)
@@ -139,7 +139,7 @@ trait HttpTestTrait {
    */
   protected function assertContentType($expectType, $response = NULL) {
     $response = $this->resolveResponse($response);
-    list($actualType) = explode(';', $response->getHeader('Content-Type')[0]);
+    [$actualType] = explode(';', $response->getHeader('Content-Type')[0]);
     $fmt = $actualType === $expectType ? '' : $this->formatFailure($response);
     $this->assertEquals($expectType, $actualType, "Expected content-type $expectType. Received content-type $actualType.\n$fmt");
     return $this;