[REF] Replace coalesce pattern with coalesce operator
authoreileen <emcnaughton@wikimedia.org>
Tue, 17 Mar 2020 03:26:24 +0000 (16:26 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 17 Mar 2020 03:26:24 +0000 (16:26 +1300)
This replaces the innstances in the test folder.

tests/extensions/test.extension.manager.paymenttest/main.php
tests/phpunit/Civi/Core/ThemesTest.php
tests/phpunit/api/v3/SyntaxConformanceTest.php
tests/phpunit/api/v4/Traits/TestDataLoaderTrait.php

index e6affe4bc9e2ab838baad925f8c7b674eb2c6ef0..313db799b1f437471eebdf78bc1fb40edd49aee1 100644 (file)
@@ -8,22 +8,22 @@ class test_extension_manager_paymenttest extends CRM_Core_Payment {
   public static $counts = array();
 
   public function install() {
-    self::$counts['install'] = isset(self::$counts['install']) ? self::$counts['install'] : 0;
+    self::$counts['install'] = self::$counts['install'] ?? 0;
     self::$counts['install'] = 1 + (int) self::$counts['install'];
   }
 
   public function uninstall() {
-    self::$counts['uninstall'] = isset(self::$counts['uninstall']) ? self::$counts['uninstall'] : 0;
+    self::$counts['uninstall'] = self::$counts['uninstall'] ?? 0;
     self::$counts['uninstall'] = 1 + (int) self::$counts['uninstall'];
   }
 
   public function disable() {
-    self::$counts['disable'] = isset(self::$counts['disable']) ? self::$counts['disable'] : 0;
+    self::$counts['disable'] = self::$counts['disable'] ?? 0;
     self::$counts['disable'] = 1 + (int) self::$counts['disable'];
   }
 
   public function enable() {
-    self::$counts['enable'] = isset(self::$counts['enable']) ? self::$counts['enable'] : 0;
+    self::$counts['enable'] = self::$counts['enable'] ?? 0;
     self::$counts['enable'] = 1 + (int) self::$counts['enable'];
   }
 
@@ -38,7 +38,7 @@ class test_extension_manager_paymenttest extends CRM_Core_Payment {
    * @return int
    */
   public static function getCount($type) {
-    return isset(self::$counts[$type]) ? self::$counts[$type] : 0;
+    return self::$counts[$type] ?? 0;
   }
 
 }
index 6278f60674f6c0b59cee524565c11a7c637b0ebe..f252078921a9abd28e3dfb78b840482d1e8ec105 100644 (file)
@@ -192,7 +192,7 @@ class ThemesTest extends \CiviUnitTestCase {
     $map['bluemarine']['civicrm']['css/civicrm.css'] = ['http://example.com/blue/civicrm.css'];
     $map['bluemarine']['test.extension.uitest']['files/foo.css'] = ['http://example.com/blue/foobar/foo.css'];
     $map['aquamarine']['civicrm']['css/civicrm.css'] = ['http://example.com/aqua/civicrm.css'];
-    return isset($map[$themeKey][$cssExt][$cssFile]) ? $map[$themeKey][$cssExt][$cssFile] : Themes::PASSTHRU;
+    return $map[$themeKey][$cssExt][$cssFile] ?? Themes::PASSTHRU;
   }
 
   public function testGetAll() {
index e4b0f35b91795b6749187b407269b9dfc68e1036..364baf768144498476ed376e643373efae322049 100644 (file)
@@ -1465,7 +1465,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
       }
       $updateParams = [
         'id' => $entity['id'],
-        $field => isset($entity[$field]) ? $entity[$field] : NULL,
+        $field => $entity[$field] ?? NULL,
       ];
       if (isset($updateParams['financial_type_id']) && in_array($entityName, ['Grant'])) {
         //api has special handling on these 2 fields for backward compatibility reasons
index 875a017f4b95d228b608bf9d812c59d14e55a489..d440f30a4b4ba212d3024f2edb7930e28c5696c8 100644 (file)
@@ -63,7 +63,7 @@ trait TestDataLoaderTrait {
    * @return null|mixed
    */
   protected function getReference($name) {
-    return isset($this->references[$name]) ? $this->references[$name] : NULL;
+    return $this->references[$name] ?? NULL;
   }
 
   /**