Merge pull request #14358 from samuelsov/billingblockts
[civicrm-core.git] / CRM / Utils / HttpClient.php
index f9e115686c45d5c4e086015fe7fda04cc1151f3b..776adafcaff3d80f3ccb6b7eb9de3fef212566f5 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -34,7 +34,7 @@
  * want to deal with that so late in the 4.3 dev cycle.
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 class CRM_Utils_HttpClient {
 
@@ -48,7 +48,7 @@ class CRM_Utils_HttpClient {
   protected static $singleton;
 
   /**
-   * @var int|NULL
+   * @var int|null
    *   seconds; or NULL to use system default
    */
   protected $connectionTimeout;
@@ -125,26 +125,26 @@ class CRM_Utils_HttpClient {
         ts('As a result, actions like retrieving the CiviCRM news feed will fail. Talk to your server administrator or hosting company to rectify this.'),
         ts('Curl is not installed')
       );
-      return array(self::STATUS_DL_ERROR, NULL);
+      return [self::STATUS_DL_ERROR, NULL];
     }
 
     list($ch, $caConfig) = $this->createCurl($remoteFile);
 
     if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) {
       // CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
-      return array(self::STATUS_DL_ERROR, NULL);
+      return [self::STATUS_DL_ERROR, NULL];
     }
 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $data = curl_exec($ch);
     if (curl_errno($ch)) {
-      return array(self::STATUS_DL_ERROR, $data);
+      return [self::STATUS_DL_ERROR, $data];
     }
     else {
       curl_close($ch);
     }
 
-    return array(self::STATUS_OK, $data);
+    return [self::STATUS_OK, $data];
   }
 
   /**
@@ -161,14 +161,14 @@ class CRM_Utils_HttpClient {
     // Download extension zip file ...
     if (!function_exists('curl_init')) {
       //CRM_Core_Error::fatal('Cannot install this extension - curl is not installed!');
-      return array(self::STATUS_DL_ERROR, NULL);
+      return [self::STATUS_DL_ERROR, NULL];
     }
 
     list($ch, $caConfig) = $this->createCurl($remoteFile);
 
     if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) {
       // CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
-      return array(self::STATUS_DL_ERROR, NULL);
+      return [self::STATUS_DL_ERROR, NULL];
     }
 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -177,13 +177,13 @@ class CRM_Utils_HttpClient {
     curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
     $data = curl_exec($ch);
     if (curl_errno($ch)) {
-      return array(self::STATUS_DL_ERROR, $data);
+      return [self::STATUS_DL_ERROR, $data];
     }
     else {
       curl_close($ch);
     }
 
-    return array(self::STATUS_OK, $data);
+    return [self::STATUS_OK, $data];
   }
 
   /**
@@ -192,9 +192,9 @@ class CRM_Utils_HttpClient {
    *   (0 => resource, 1 => CA_Config_Curl)
    */
   protected function createCurl($remoteFile) {
-    $caConfig = CA_Config_Curl::probe(array(
+    $caConfig = CA_Config_Curl::probe([
       'verify_peer' => (bool) Civi::settings()->get('verifySSL'),
-    ));
+    ]);
 
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $remoteFile);
@@ -211,7 +211,7 @@ class CRM_Utils_HttpClient {
       curl_setopt_array($ch, $caConfig->toCurlOptions());
     }
 
-    return array($ch, $caConfig);
+    return [$ch, $caConfig];
   }
 
   /**