NFC tidy up comments, remove unused variables in customfield classes
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sat, 29 Dec 2018 11:13:57 +0000 (11:13 +0000)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sat, 29 Dec 2018 11:13:57 +0000 (11:13 +0000)
CRM/Core/BAO/CustomField.php
CRM/Core/BAO/CustomGroup.php
api/v3/CustomValue.php

index 58e19ef54110d01e05254f4e5b310ab36dadeecd..d8c9642818708d12009f5b432d09c2dec1012deb 100644 (file)
@@ -1307,7 +1307,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
 
       case 'Text':
         if ($field['data_type'] == 'Money' && isset($value)) {
-          //$value can also be an array(while using IN operator from search builder or api).
+          // $value can also be an array(while using IN operator from search builder or api).
           foreach ((array) $value as $val) {
             $disp[] = CRM_Utils_Money::format($val, NULL, NULL, TRUE);
           }
index f78d23f27457a6ac8a91843a283b85c001916828..84c46f02c68faef0b33cddf0c576b26b900aa726 100644 (file)
@@ -52,6 +52,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
    *   (reference) an assoc array of name/value pairs.
    *
    * @return CRM_Core_DAO_CustomGroup
+   * @throws \Exception
    */
   public static function create(&$params) {
     // create custom group dao, populate fields and then save.
@@ -82,9 +83,9 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
       $group->extends_entity_column_id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $extendsEntity, 'value', 'name');
     }
 
-    //this is format when form get submit.
+    // this is format when form get submit.
     $extendsChildType = CRM_Utils_Array::value(1, $extends);
-    //lets allow user to pass direct child type value, CRM-6893
+    // lets allow user to pass direct child type value, CRM-6893
     if (!empty($params['extends_entity_column_value'])) {
       $extendsChildType = $params['extends_entity_column_value'];
     }
@@ -141,7 +142,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
       $group->id = $params['id'];
 
       if (isset($params['is_multiple'])) {
-        //check whether custom group was changed from single-valued to multiple-valued
+        // check whether custom group was changed from single-valued to multiple-valued
         $isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup',
           $params['id'],
           'is_multiple'
@@ -353,6 +354,8 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
    * @todo - review this  - It also returns an array called 'info' with tables, select, from, where keys
    *   The reason for the info array in unclear and it could be determined from parsing the group tree after creation
    *   With caching the performance impact would be small & the function would be cleaner
+   *
+   * @throws \CRM_Core_Exception
    */
   public static function getTree(
     $entityType,
@@ -386,7 +389,6 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
     }
 
     // create a new tree
-    $strWhere = $orderBy = '';
 
     // legacy hardcoded list of data to return
     $tableData = array(
@@ -553,7 +555,6 @@ ORDER BY civicrm_custom_group.weight,
     $cacheKey = "CRM_Core_DAO_CustomGroup_Query " . md5($cacheString);
     $multipleFieldGroupCacheKey = "CRM_Core_DAO_CustomGroup_QueryMultipleFields " . md5($cacheString);
     $cache = CRM_Utils_Cache::singleton();
-    $tablesWithEntityData = array();
     if ($fromCache) {
       $groupTree = $cache->get($cacheKey);
       $multipleFieldGroups = $cache->get($multipleFieldGroupCacheKey);
@@ -625,7 +626,7 @@ ORDER BY civicrm_custom_group.weight,
       $cache->set($cacheKey, $groupTree);
       $cache->set($multipleFieldGroupCacheKey, $multipleFieldGroups);
     }
-    //entitySelectClauses is an array of select clauses for custom value tables which are not multiple
+    // entitySelectClauses is an array of select clauses for custom value tables which are not multiple
     // and have data for the given entities. $entityMultipleSelectClauses is the same for ones with multiple
     $entitySingleSelectClauses = $entityMultipleSelectClauses = $groupTree['info']['select'] = array();
     $singleFieldTables = array();
@@ -683,7 +684,6 @@ ORDER BY civicrm_custom_group.weight,
    *
    * @return string
    * @throws \CRM_Core_Exception
-   * @throws \CiviCRM_API3_Exception
    */
   protected static function validateSubTypeByEntity($entityType, $subType) {
     $subType = trim($subType, CRM_Core_DAO::VALUE_SEPARATOR);
@@ -724,7 +724,6 @@ ORDER BY civicrm_custom_group.weight,
   /**
    * Check whether the custom group has any data for the given entity.
    *
-   *
    * @param int $entityID
    *   Id of entity for whom we are checking data for.
    * @param string $table
@@ -792,7 +791,7 @@ ORDER BY civicrm_custom_group.weight,
    *   Array of select clauses relevant to the entity.
    * @param array $multipleFieldTablesWithEntityData
    *   Array of tables in which this entity has data.
-   * @param varchar $singleRecord
+   * @param string|int $singleRecord
    *   holds 'new' or id if view/edit/copy form for a single record is being loaded.
    */
   static public function buildEntityTreeMultipleFields(&$groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData, $singleRecord = NULL) {
@@ -823,7 +822,7 @@ ORDER BY civicrm_custom_group.weight,
    * @param array $includedTables
    *   Tables to include - required because the function (for historical reasons).
    *   iterates through the group tree
-   * @param varchar $singleRecord
+   * @param string|int $singleRecord
    *   holds 'new' OR id if view/edit/copy form for a single record is being loaded.
    */
   static public function buildTreeEntityDataFromQuery(&$groupTree, $query, $includedTables, $singleRecord = NULL) {
@@ -860,7 +859,7 @@ ORDER BY civicrm_custom_group.weight,
    *   Custom group ID.
    * @param int $fieldID
    *   Custom field ID.
-   * @param varchar $singleRecord
+   * @param string|int $singleRecord
    *   holds 'new' or id if loading view/edit/copy for a single record.
    */
   static public function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID, $singleRecord = NULL) {
@@ -983,7 +982,7 @@ ORDER BY civicrm_custom_group.weight,
    * @param array $extends
    *   Which table does it extend if any.
    *
-   * @param null $inSelector
+   * @param bool $inSelector
    *
    * @return array
    *   array consisting of all group and field details
@@ -991,9 +990,6 @@ ORDER BY civicrm_custom_group.weight,
   public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$extends = NULL, $inSelector = NULL) {
     // create a new tree
     $groupTree = array();
-    $select = $from = $where = $orderBy = '';
-
-    $tableData = array();
 
     // using tableData to build the queryString
     $tableData = array(
@@ -1532,8 +1528,7 @@ ORDER BY civicrm_custom_group.weight,
 
         switch ($groupTree[$groupID]['fields'][$fieldId]['html_type']) {
 
-          //added for CheckBox
-
+          // added for CheckBox
           case 'CheckBox':
             if (!empty($v)) {
               $customValue = array_keys($v);
@@ -1567,7 +1562,7 @@ ORDER BY civicrm_custom_group.weight,
               break;
             }
 
-            //store the file in d/b
+            // store the file in d/b
             $entityId = explode('=', $groupTree['info']['where'][0]);
             $fileParams = array('upload_date' => date('YmdHis'));
 
@@ -1621,6 +1616,8 @@ ORDER BY civicrm_custom_group.weight,
    *   Return inactive custom groups.
    * @param string $prefix
    *   Prefix for custom grouptree assigned to template.
+   *
+   * @throws \CiviCRM_API3_Exception
    */
   public static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FALSE, $prefix = '') {
     $form->assign_by_ref("{$prefix}groupTree", $groupTree);
@@ -1655,6 +1652,8 @@ ORDER BY civicrm_custom_group.weight,
    *   The type of custom group we are using.
    *
    * @return array
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public static function extractGetParams(&$form, $type) {
     if (empty($_GET)) {
@@ -1839,6 +1838,8 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1,
 
   /**
    * @param $group
+   *
+   * @throws \Exception
    */
   public static function createTable($group) {
     $params = array(
@@ -1853,14 +1854,15 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1,
   }
 
   /**
-   * Function returns formatted groupTree, sothat form can be easily build in template
+   * Function returns formatted groupTree, so that form can be easily built in template
    *
    * @param array $groupTree
    * @param int $groupCount
-   *   Group count by default 1, but can varry for multiple value custom data.
-   * @param object $form
+   *   Group count by default 1, but can vary for multiple value custom data.
+   * @param \CRM_Core_Form $form
    *
    * @return array
+   * @throws \CRM_Core_Exception
    */
   public static function formatGroupTree(&$groupTree, $groupCount = 1, &$form = NULL) {
     $formattedGroupTree = array();
@@ -2021,8 +2023,8 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1,
     }
 
     if ($returnCount) {
-      //return a single value count if group id is passed to function
-      //else return a groupId and count mapped array
+      // return a single value count if group id is passed to function
+      // else return a groupId and count mapped array
       if (!empty($gID)) {
         return count($details[$gID]);
       }
@@ -2124,6 +2126,7 @@ SELECT  civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT
    *
    * @return array
    *   Array of types.
+   * @throws \Exception
    */
   public static function getExtendedObjectTypes(&$types = array()) {
     static $flag = FALSE, $objTypes = array();
@@ -2146,8 +2149,7 @@ SELECT  civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT
           }
 
           list($className) = explode('::', $callback);
-          require_once str_replace('_', DIRECTORY_SEPARATOR, $className) .
-            '.php';
+          require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
 
           $objTypes[$ovValues['value']] = call_user_func_array($callback, $args);
         }
@@ -2166,7 +2168,7 @@ SELECT  civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT
    * @return bool
    */
   public static function hasReachedMaxLimit($customGroupId, $entityId) {
-    //check whether the group is multiple
+    // check whether the group is multiple
     $isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'is_multiple');
     $isMultiple = ($isMultiple) ? TRUE : FALSE;
     $hasReachedMax = FALSE;
@@ -2178,7 +2180,7 @@ SELECT  civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT
       }
       else {
         $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name');
-        //count the number of entries for a entity
+        // count the number of entries for a entity
         $sql = "SELECT COUNT(id) FROM {$tableName} WHERE entity_id = %1";
         $params = array(1 => array($entityId, 'Integer'));
         $count = CRM_Core_DAO::singleValueQuery($sql, $params);
index bbaab27d237bf5ecccea23fef361bf19bd10d795..60005bdb19669dffa433b3c114fdfeef1e40153a 100644 (file)
@@ -246,7 +246,8 @@ function _civicrm_api3_custom_value_get_spec(&$params) {
  * CustomValue.gettree API specification
  *
  * @param array $spec description of fields supported by this API call
- * @return void
+ *
+ * @throws \CiviCRM_API3_Exception
  */
 function _civicrm_api3_custom_value_gettree_spec(&$spec) {
   $spec['entity_id'] = array(
@@ -294,8 +295,11 @@ function _civicrm_api3_custom_value_gettree_spec(&$spec) {
  * CustomValue.gettree API
  *
  * @param array $params
+ *
  * @return array API result
- * @throws API_Exception
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
  */
 function civicrm_api3_custom_value_gettree($params) {
   $ret = array();