diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index a7ba16237434..0c65ba6c7681 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -30,12 +30,10 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** - * This class is for activity functions - * + * This class is for activity functions.s */ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { @@ -54,7 +52,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { static $_importableFields = NULL; /** - * Check if there is absolute minimum of data to add the object + * Check if there is absolute minimum of data to add the object. * * @param array $params * (reference ) an assoc array of name/value pairs. @@ -69,7 +67,7 @@ public static function dataExists(&$params) { } /** - * Fetch object based on array of properties + * Fetch object based on array of properties. * * @param array $params * (reference ) an assoc array of name/value pairs. @@ -139,12 +137,12 @@ public static function retrieve(&$params, &$defaults) { } /** - * Delete the activity + * Delete the activity. * * @param array $params * @param bool $moveToTrash * - * @return void + * @return mixed */ public static function deleteActivity(&$params, $moveToTrash = FALSE) { // CRM-9137 @@ -245,7 +243,7 @@ public static function deleteActivity(&$params, $moveToTrash = FALSE) { } /** - * Delete activity assignment record + * Delete activity assignment record. * * @param int $activityId * @param int $recordTypeID @@ -260,7 +258,7 @@ public static function deleteActivityContact($activityId, $recordTypeID = NULL) } /** - * Process the activities + * Process the activities. * * @param array $params * Associated array of the submitted values. @@ -613,8 +611,12 @@ public static function create(&$params) { } /** - * @param $activity - * @param null $logMessage + * Create an activity. + * + * @todo elaborate on what this does. + * + * @param CRM_Core_DAO_Activity $activity + * @param string $logMessage * * @return bool */ @@ -638,7 +640,7 @@ public static function logActivityAction($activity, $logMessage = NULL) { } /** - * Get the list Activities + * Get the list Activities. * * @param array $input * Array of parameters. @@ -653,8 +655,7 @@ public static function logActivityAction($activity, $logMessage = NULL) { * - activity_type_id int|string the activitiy types we want to restrict by * * @return array - * (reference) $values the relevant data object values of open activities - * + * Relevant data object values of open activities */ public static function &getActivities($input) { //step 1: Get the basic activity data @@ -897,9 +898,12 @@ public static function &getActivities($input) { } /** - * Get the component id and name those are enabled and logged in - * user has permission. To decide whether we are going to include - * component related activities w/ core activity retrieve process. + * Get the component id and name if those are enabled and allowed. + * + * Checks whether logged in user has permission. + * To decide whether we are going to include + * component related activities with core activity retrieve process. + * (what did that just mean?) * * @return array * Array of component id and name. @@ -930,7 +934,7 @@ public static function activityComponents() { } /** - * Get the activity Count + * Get the activity Count. * * @param array $input * Array of parameters. @@ -943,7 +947,6 @@ public static function activityComponents() { * * @return int * count of activities - * */ public static function &getActivitiesCount($input) { $input['count'] = TRUE; @@ -966,7 +969,7 @@ public static function &getActivitiesCount($input) { } /** - * Get the activity sql clause to pick activities + * Get the activity sql clause to pick activities. * * @param array $input * Array of parameters. @@ -980,7 +983,6 @@ public static function &getActivitiesCount($input) { * * @return int * count of activities - * */ public static function getActivitySQLClause($input) { $params = array(); @@ -1145,8 +1147,9 @@ public static function getActivitySQLClause($input) { } /** - * Send the message to all the contacts and also insert a - * contact activity in each contacts record + * Send the message to all the contacts. + * + * Also insert a contact activity in each contacts record. * * @param array $contactDetails * The array of contact details to send the email. @@ -1357,6 +1360,8 @@ public static function sendEmail( } /** + * Send SMS. + * * @param array $contactDetails * @param array $activityParams * @param array $smsParams @@ -1494,7 +1499,6 @@ public static function sendSMS( * @param int $toID * The contact id of the recipient. * @param $tokenText - * @param $tokenHtml * @param array $smsParams * The params used for sending sms. * @param int $activityID @@ -1647,7 +1651,7 @@ public static function sendMessage( } /** - * Combine all the importable fields from the lower levels object + * Combine all the importable fields from the lower levels object. * * The ordering is important, since currently we do not have a weight * scheme. Adding weight is super important and should be done in the @@ -1704,7 +1708,7 @@ public static function &importableFields($status = FALSE) { } /** - * get the Activities of a target contact + * Get the Activities of a target contact. * * @param int $contactId * Id of the contact whose activities need to find. @@ -1777,7 +1781,7 @@ public static function getContactActivity($contactId) { } /** - * Add activity for Membership/Event/Contribution + * Add activity for Membership/Event/Contribution. * * @param object $activity * (reference) particular component object. @@ -1896,13 +1900,13 @@ public static function addActivity( } /** - * Get Parent activity for currently viewed activity + * Get Parent activity for currently viewed activity. * * @param int $activityId * Current activity id. * * @return int - * $parentId Id of parent activity otherwise false. + * Id of parent activity otherwise false. */ public static function getParentActivity($activityId) { static $parentActivities = array(); @@ -1924,7 +1928,7 @@ public static function getParentActivity($activityId) { } /** - * Get total count of prior revision of currently viewd activity + * Get total count of prior revision of currently viewed activity. * * @param $activityID * Current activity id. @@ -1962,7 +1966,7 @@ public static function getPriorCount($activityID) { } /** - * Get all prior activities of currently viewed activity + * Get all prior activities of currently viewed activity. * * @param $activityID * Current activity id. @@ -2013,7 +2017,7 @@ public static function getPriorAcitivities($activityID, $onlyPriorRevisions = FA } /** - * Find the latest revision of a given activity + * Find the latest revision of a given activity. * * @param int $activityID * Prior activity id. @@ -2046,7 +2050,7 @@ public static function getLatestActivityId($activityID) { } /** - * Create a follow up a given activity + * Create a follow up a given activity. * * @param int $activityId * activity id of parent activity. @@ -2120,11 +2124,11 @@ public static function getFileForActivityTypeId($activityTypeId, $crmDir = 'Acti } /** - * Restore the activity + * Restore the activity. * * @param array $params * - * @return void + * @return CRM_Activity_DAO_Activity */ public static function restoreActivity(&$params) { $activity = new CRM_Activity_DAO_Activity(); @@ -2137,7 +2141,7 @@ public static function restoreActivity(&$params) { } /** - * Get the exportable fields for Activities + * Get the exportable fields for Activities. * * @param string $name * If it is called by case $name = Case else $name = Activity. @@ -2435,13 +2439,13 @@ public static function checkPermission($activityId, $action) { } /** - * wrapper for ajax activity selector + * Wrapper for ajax activity selector. * * @param array $params * Associated array for params record id. * * @return array - * associated array of contact activities + * Associated array of contact activities */ public static function getContactActivitySelector(&$params) { // format the params diff --git a/CRM/Admin/Form/Setting.php b/CRM/Admin/Form/Setting.php index 35a60e44c8e3..6ab1d92e4646 100644 --- a/CRM/Admin/Form/Setting.php +++ b/CRM/Admin/Form/Setting.php @@ -30,12 +30,10 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** * This class generates form components generic to CiviCRM settings - * */ class CRM_Admin_Form_Setting extends CRM_Core_Form { @@ -44,10 +42,8 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { /** * Set default values for the form. - * default values are retrieved from the database - * * - * @return void + * Default values are retrieved from the database. */ public function setDefaultValues() { if (!$this->_defaults) { @@ -89,10 +85,10 @@ public function setDefaultValues() { //Set defaults for autocomplete and contact reference options $this->_defaults['autocompleteContactSearch'] = array( - '1' => 1 + '1' => 1, ) + $autoSearchFields; $this->_defaults['autocompleteContactReference'] = array( - '1' => 1 + '1' => 1, ) + $cRSearchFields; // we can handle all the ones defined in the metadata here. Others to be converted @@ -116,8 +112,6 @@ public function setDefaultValues() { /** * Build the form object - * - * @return void */ public function buildQuickForm() { $session = CRM_Core_Session::singleton(); @@ -169,10 +163,7 @@ public function buildQuickForm() { } /** - * Process the form submission - * - * - * @return void + * Process the form submission. */ public function postProcess() { // store the submitted values in an array diff --git a/CRM/Campaign/Form/Gotv.php b/CRM/Campaign/Form/Gotv.php index dd2fb7833b99..e1c563cbde9d 100755 --- a/CRM/Campaign/Form/Gotv.php +++ b/CRM/Campaign/Form/Gotv.php @@ -30,7 +30,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** @@ -50,11 +49,9 @@ class CRM_Campaign_Form_Gotv extends CRM_Core_Form { protected $_searchVoterFor; /** - * Processing needed for buildForm and later - * - * @return void + * Processing needed for buildForm and later. */ - function preProcess() { + public function preProcess() { $this->_search = CRM_Utils_Array::value('search', $_GET); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE); $this->_surveyId = CRM_Utils_Request::retrieve('sid', 'Positive', $this); diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index bc43f7c1b5f6..d49f64cd7e71 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -30,7 +30,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { @@ -64,14 +63,24 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { * * @var array */ - static $_commPrefs = array('do_not_phone', 'do_not_email', 'do_not_mail', 'do_not_sms', 'do_not_trade'); + static $_commPrefs = array( + 'do_not_phone', + 'do_not_email', + 'do_not_mail', + 'do_not_sms', + 'do_not_trade', + ); /** * Types of greetings * * @var array */ - static $_greetingTypes = array('addressee', 'email_greeting', 'postal_greeting'); + static $_greetingTypes = array( + 'addressee', + 'email_greeting', + 'postal_greeting', + ); /** * Static field for all the contact information that we can potentially import @@ -88,27 +97,25 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { static $_exportableFields = NULL; /** - * Class constructor - * - * @return \CRM_Contact_DAO_Contact - */ - /** + * Class constructor. */ public function __construct() { parent::__construct(); } /** - * Takes an associative array and creates a contact object + * Takes an associative array and creates a contact object. * - * the function extract all the params it needs to initialize the create a + * The function extracts all the params it needs to initialize the create a * contact object. the params array could contain additional unused name/value * pairs * * @param array $params - * (reference ) an assoc array of name/value pairs. + * (reference) an assoc array of name/value pairs. * - * @return CRM_Contact_BAO_Contact + * @return CRM_Contact_BAO_Contact|CRM_Core_Error + * Created or updated contact object or error object. + * (error objects are being phased out in favour of exceptions) */ public static function add(&$params) { $contact = new CRM_Contact_DAO_Contact(); @@ -117,7 +124,7 @@ public static function add(&$params) { return; } - //fix for validate contact sub type CRM-5143 + // Fix for validate contact sub type CRM-5143. if (isset($params['contact_sub_type'])) { if (empty($params['contact_sub_type'])) { $params['contact_sub_type'] = 'null'; @@ -140,17 +147,17 @@ public static function add(&$params) { } } else { - // reset the value - // CRM-101XX + // Reset the value. + // CRM-101XX. $params['contact_sub_type'] = 'null'; } - //fixed contact source + // Fixed contact source. if (isset($params['contact_source'])) { $params['source'] = $params['contact_source']; } - //fix for preferred communication method + // Fix for preferred communication method. $prefComm = CRM_Utils_Array::value('preferred_communication_method', $params); if ($prefComm && is_array($prefComm)) { unset($params['preferred_communication_method']); @@ -179,7 +186,7 @@ public static function add(&$params) { if ($contact->contact_type == 'Individual') { $allNull = FALSE; - //format individual fields + // Format individual fields. CRM_Contact_BAO_Individual::format($params, $contact); } elseif ($contact->contact_type == 'Household') { @@ -195,7 +202,6 @@ public static function add(&$params) { } } - // privacy block $privacy = CRM_Utils_Array::value('privacy', $params); if ($privacy && is_array($privacy) && @@ -207,9 +213,9 @@ public static function add(&$params) { } } - // since hash was required, make sure we have a 0 value for it, CRM-1063 - // fixed in 1.5 by making hash optional - // only do this in create mode, not update + // Since hash was required, make sure we have a 0 value for it (CRM-1063). + // @todo - does this mean we can remove this block? + // Fixed in 1.5 by making hash optional, only do this in create mode, not update. if ((!array_key_exists('hash', $contact) || !$contact->hash) && !$contact->id) { $allNull = FALSE; $contact->hash = md5(uniqid(rand(), TRUE)); @@ -230,7 +236,7 @@ public static function add(&$params) { } if ($contact->contact_type == 'Individual' && (isset($params['current_employer']) || isset($params['employer_id']))) { - // create current employer + // Create current employer. $newEmployer = !empty($params['employer_id']) ? $params['employer_id'] : CRM_Utils_Array::value('current_employer', $params); $newContact = FALSE; @@ -241,14 +247,13 @@ public static function add(&$params) { CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id, $newEmployer, $employerId, $newContact); } else { - //unset if employer id exits if ($employerId) { CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($contact->id, $employerId); } } } - //update cached employee name + // Update cached employer name. if ($contact->contact_type == 'Organization') { CRM_Contact_BAO_Contact_Utils::updateCurrentEmployer($contact->id); } @@ -257,7 +262,8 @@ public static function add(&$params) { } /** - * Create contact + * Create contact. + * * takes an associative array and creates a contact object and all the associated * derived objects (i.e. individual, location, email, phone etc) * @@ -271,9 +277,14 @@ public static function add(&$params) { * If we need to invoke hooks. * * @param bool $skipDelete + * Unclear parameter, passed to website create + * + * @todo explain this parameter * * @throws Exception - * @return CRM_Contact_BAO_Contact + * @return CRM_Contact_BAO_Contact|CRM_Core_Error + * Created or updated contribution object. We are deprecating returning an error in + * favour of exceptions */ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE, $skipDelete = FALSE) { $contact = NULL; @@ -294,17 +305,17 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE $config = CRM_Core_Config::singleton(); - // CRM-6942: set preferred language to the current language if it’s unset (and we’re creating a contact) + // CRM-6942: set preferred language to the current language if it’s unset (and we’re creating a contact). if (empty($params['contact_id']) && empty($params['preferred_language'])) { $params['preferred_language'] = $config->lcMessages; } - // CRM-9739: set greeting & addressee if unset and we’re creating a contact + // CRM-9739: set greeting & addressee if unset and we’re creating a contact. if (empty($params['contact_id'])) { foreach (self::$_greetingTypes as $greeting) { if (empty($params[$greeting . '_id'])) { - if ($defaultGreetingTypeId = - CRM_Contact_BAO_Contact_Utils::defaultGreeting($params['contact_type'], $greeting) + if ($defaultGreetingTypeId + = CRM_Contact_BAO_Contact_Utils::defaultGreeting($params['contact_type'], $greeting) ) { $params[$greeting . '_id'] = $defaultGreetingTypeId; } @@ -316,7 +327,7 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE $contact = self::add($params); if (!$contact) { - // not dying here is stupid, since we get into wierd situation and into a bug that + // Not dying here is stupid, since we get into wierd situation and into a bug that // is impossible to figure out for the user or for us // CRM-7925 CRM_Core_Error::fatal(); @@ -325,7 +336,7 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE $params['contact_id'] = $contact->id; if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled')) { - // Enabling multisite causes the contact to be added to the domain group + // Enabling multisite causes the contact to be added to the domain group. $domainGroupID = CRM_Core_BAO_Domain::getGroupId(); if (!empty($domainGroupID)) { if (!empty($params['group']) && is_array($params['group'])) { @@ -349,7 +360,7 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE } } - //add location Block data + // Add location Block data. $blocks = CRM_Core_BAO_Location::create($params, $fixAddress); foreach ($blocks as $name => $value) { $contact->$name = $value; @@ -405,7 +416,6 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE } } - // update the UF user_unique_id if that has changed CRM_Core_BAO_UFMatch::updateUFName($contact->id); @@ -459,17 +469,18 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE } /** - * Get the display name and image of a contact + * Get the display name and image of a contact. * * @param int $id * The contactId. * - * @param bool $type + * @param bool $includeTypeInReturnParameters + * Should type be part of the returned array? * * @return array * the displayName and contactImage for this contact */ - public static function getDisplayAndImage($id, $type = FALSE) { + public static function getDisplayAndImage($id, $includeTypeInReturnParameters = FALSE) { //CRM-14276 added the * on the civicrm_contact table so that we have all the contact info available $sql = " SELECT civicrm_contact.*, @@ -498,7 +509,7 @@ public static function getDisplayAndImage($id, $type = FALSE) { CRM_Utils_Hook::alterDisplayName($displayName, $id, $dao); - return $type ? array( + return $includeTypeInReturnParameters ? array( $displayName, $image, $dao->contact_type, @@ -510,11 +521,13 @@ public static function getDisplayAndImage($id, $type = FALSE) { } /** + * Create last viewed link to recently updated contact. + * * @param array $crudLinkSpec - * With keys:. - * - action: int, CRM_Core_Action::UPDATE or CRM_Core_Action::VIEW [default: VIEW] - * - entity_table: string, eg "civicrm_contact" - * - entity_id: int + * - action: int, CRM_Core_Action::UPDATE or CRM_Core_Action::VIEW [default: VIEW] + * - entity_table: string, eg "civicrm_contact" + * - entity_id: int + * * @return array|NULL * NULL if unavailable, or * [path: string, query: string, title: string] @@ -553,11 +566,9 @@ public function createDefaultCrudLink($crudLinkSpec) { * (reference) the default values, some of which need to be resolved. * @param bool $reverse * True if we want to resolve the values in the reverse direction (value -> name). - * - * @return void */ public static function resolveDefaults(&$defaults, $reverse = FALSE) { - // hack for birth_date + // Hack for birth_date. if (!empty($defaults['birth_date'])) { if (is_array($defaults['birth_date'])) { $defaults['birth_date'] = CRM_Utils_Date::format($defaults['birth_date'], '-'); @@ -671,14 +682,14 @@ public static function resolveDefaults(&$defaults, $reverse = FALSE) { ); } - //kill the reference. + // Kill the reference. unset($values); } } } /** - * Fetch object based on array of properties + * Fetch object based on array of properties. * * @param array $params * (reference ) an assoc array of name/value pairs. @@ -730,7 +741,7 @@ public static function &retrieve(&$params, &$defaults, $microformat = FALSE) { } /** - * Get the display name of a contact + * Get the display name of a contact. * * @param int $id * Id of the contact. @@ -748,7 +759,7 @@ public static function displayName($id) { } /** - * Delete a contact and all its associated records + * Delete a contact and all its associated records. * * @param int $id * Id of the contact to delete. @@ -757,8 +768,8 @@ public static function displayName($id) { * @param bool $skipUndelete * Whether to force contact delete or not. * - * @return boolean - * true if contact deleted, false otherwise + * @return bool + * Was contact deleted? */ public static function deleteContact($id, $restore = FALSE, $skipUndelete = FALSE) { @@ -808,7 +819,6 @@ public static function deleteContact($id, $restore = FALSE, $skipUndelete = FALS return TRUE; } - // currently we only clear employer cache. // we are not deleting inherited membership if any. if ($contact->contact_type == 'Organization') { @@ -885,13 +895,13 @@ public static function deleteContact($id, $restore = FALSE, $skipUndelete = FALS } /** - * Delete the image of a contact + * Delete the image of a contact. * * @param int $id * Id of the contact. * - * @return boolean - * true if contact image is deleted + * @return bool + * Was contact image deleted? */ public static function deleteContactImage($id) { if (!$id) { @@ -906,13 +916,14 @@ public static function deleteContactImage($id) { } /** - * Return relative path + * Return relative path. + * * @todo make this a method of $config->userSystem (i.e. UF classes) rather than a static function * * @param string $absolutePath * Absolute path. * - * @return String + * @return string * Relative url of uploaded image */ public static function getRelativePath($absolutePath) { @@ -946,7 +957,7 @@ public static function getRelativePath($absolutePath) { } /** - * Return proportional height and width of the image + * Return proportional height and width of the image. * * @param int $imageWidth * Width of image. @@ -954,8 +965,8 @@ public static function getRelativePath($absolutePath) { * @param int $imageHeight * Height of image. * - * @return Array - * thumb dimension of image + * @return array + * Thumb dimension of image */ public static function getThumbSize($imageWidth, $imageHeight) { $thumbWidth = 100; @@ -978,7 +989,7 @@ public static function getThumbSize($imageWidth, $imageHeight) { } /** - * Validate type of contact image + * Validate type of contact image. * * @param array $params * @param string $imageIndex @@ -988,7 +999,7 @@ public static function getThumbSize($imageWidth, $imageHeight) { * @param string $opType * Type of operation like fatal, bounce etc. * - * @return boolean + * @return bool * true if valid image extension */ public static function processImageParams( @@ -1026,7 +1037,7 @@ public static function processImageParams( } /** - * Extract contact id from url for deleting contact image + * Extract contact id from url for deleting contact image. */ public static function processImage() { @@ -1047,15 +1058,13 @@ public static function processImage() { } /** - * Function to set is_delete true or restore deleted contact + * Function to set is_delete true or restore deleted contact. * * @param int $contact * Contact DAO object. * @param bool $restore * True to set the is_delete = 1 else false to restore deleted contact, * i.e. is_delete = 0 - * - * @return void */ public static function contactTrashRestore($contact, $restore = FALSE) { $op = ($restore ? 'restore' : 'trash'); @@ -1086,8 +1095,6 @@ public static function contactTrashRestore($contact, $restore = FALSE) { * * @return string * contact_type if $id found else null "" - * - * */ public static function getContactType($id) { return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $id, 'contact_type'); @@ -1103,8 +1110,6 @@ public static function getContactType($id) { * * @return string * contact_sub_type if $id found else null "" - * - * */ public static function getContactSubType($id, $implodeDelimiter = NULL) { $subtype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $id, 'contact_sub_type'); @@ -1127,8 +1132,6 @@ public static function getContactSubType($id, $implodeDelimiter = NULL) { * Id of the contact whose contact sub/contact type is needed. * * @return array - * - * */ public static function getContactTypes($id) { $params = array('id' => $id); @@ -1141,8 +1144,9 @@ public static function getContactTypes($id) { if ($contact) { $contactTypes = array(); - if ($contact->contact_sub_type) + if ($contact->contact_sub_type) { $contactTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($contact->contact_sub_type, CRM_Core_DAO::VALUE_SEPARATOR)); + } array_unshift($contactTypes, $contact->contact_type); return $contactTypes; @@ -1153,7 +1157,7 @@ public static function getContactTypes($id) { } /** - * Combine all the importable fields from the lower levels object + * Combine all the importable fields from the lower levels object. * * The ordering is important, since currently we do not have a weight * scheme. Adding weight is super important @@ -1355,9 +1359,9 @@ static function importableFields( } /** - * Combine all the exportable fields from the lower levels object + * Combine all the exportable fields from the lower levels object. * - * currentlty we are using importable fields as exportable fields + * Currently we are using importable fields as exportable fields * * @param int|string $contactType contact Type * @param bool $status @@ -1450,7 +1454,6 @@ public static function &exportableFields($contactType = 'Individual', $status = CRM_Core_DAO_Worldregion::export() ); - $fields = array_merge($fields, CRM_Contact_DAO_Contact::export() ); @@ -1596,14 +1599,15 @@ public static function &exportableFields($contactType = 'Individual', $status = } /** - * Get the all contact details(Hierarchical) + * Get the all contact details (Hierarchical). * * @param int $contactId * Contact id. * @param array $fields * Fields array. * - * @return $values array contains the contact details + * @return array + * Contact details */ public static function getHierContactDetails($contactId, &$fields) { $params = array(array('contact_id', '=', $contactId, 0, 0)); @@ -1611,8 +1615,8 @@ public static function getHierContactDetails($contactId, &$fields) { $returnProperties = self::makeHierReturnProperties($fields, $contactId); - // we dont know the contents of return properties, but we need the lower level ids of the contact - // so add a few fields + // We don't know the contents of return properties, but we need the lower level ids of the contact + // so add a few fields. $returnProperties['first_name'] = $returnProperties['organization_name'] = $returnProperties['household_name'] = @@ -1622,15 +1626,16 @@ public static function getHierContactDetails($contactId, &$fields) { } /** - * Given a set of flat profile style field names, create a hierarchy - * for query to use and crete the right sql + * Given a set of flat profile style field names, create a hierarchy. + * + * This is for the query to use, create the right sql. * * @param $fields * @param int $contactId * Contact id. * * @return array - * a hierarchical property tree if appropriate + * A hierarchical property tree if appropriate */ public static function &makeHierReturnProperties($fields, $contactId = NULL) { $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); @@ -1694,7 +1699,7 @@ public static function &makeHierReturnProperties($fields, $contactId = NULL) { } /** - * Return the primary location type of a contact + * Return the primary location type of a contact. * * $params int $contactId contact_id * $params boolean $isPrimaryExist if true, return primary contact location type otherwise null @@ -1762,7 +1767,7 @@ public static function getPrimaryLocationType($contactId, $skipDefaultPriamry = } /** - * Get the display name, primary email and location type of a contact + * Get the display name, primary email and location type of a contact. * * @param int $id * Id of the contact. @@ -1818,7 +1823,7 @@ public static function getContactDetails($id) { * Specifies the default group to which contact is added. * @param int $ufGroupId * Uf group id (profile id). - * @param ctype + * @param string $ctype * @param bool $visibility * Basically lets us know where this request is coming from. * if via a profile from web, we restrict what groups are changed @@ -1826,7 +1831,7 @@ public static function getContactDetails($id) { * @return int * contact id created/edited */ - static function createProfileContact( + public static function createProfileContact( &$params, &$fields, $contactID = NULL, @@ -1918,6 +1923,8 @@ static function createProfileContact( } /** + * Format profile contact parameters. + * * @param array $params * @param $fields * @param int $contactID @@ -1927,7 +1934,7 @@ static function createProfileContact( * * @return array */ - static function formatProfileContactParams( + public static function formatProfileContactParams( &$params, &$fields, $contactID = NULL, @@ -2288,9 +2295,10 @@ static function formatProfileContactParams( } /** - * Find the get contact details - * does not respect ACLs for now, which might need to be rectified at some - * stage based on how its used + * Find the get contact details. + * + * This function does not respect ACLs for now, which might need to be rectified at some + * stage based on how its used. * * @param string $mail * Primary email address of the contact. @@ -2311,7 +2319,6 @@ public static function &matchContactOnEmail($mail, $ctype = NULL) { FROM civicrm_contact INNER JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_id )"; - if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'uniq_email_per_site')) { // try to find a match within a site (multisite). $groups = CRM_Core_BAO_Domain::getChildGroupIds(); @@ -2342,7 +2349,7 @@ public static function &matchContactOnEmail($mail, $ctype = NULL) { } /** - * Find the contact details associated with an OpenID + * Find the contact details associated with an OpenID. * * @param string $openId * OpenId of the contact. @@ -2381,13 +2388,13 @@ public static function &matchContactOnOpenId($openId, $ctype = NULL) { } /** - * Funtion to get primary email of the contact + * Get primary email of the contact. * * @param int $contactID * Contact id. * * @return string - * >email email address if present else null + * Email address if present else null */ public static function getPrimaryEmail($contactID) { // fetch the primary email @@ -2409,7 +2416,7 @@ public static function getPrimaryEmail($contactID) { } /** - * Funtion to get primary OpenID of the contact + * Function to get primary OpenID of the contact. * * @param int $contactID * Contact id. @@ -2437,15 +2444,15 @@ public static function getPrimaryOpenId($contactID) { } /** - * Given the list of params in the params array, fetch the object - * and store the values in the values array + * Fetch the object and store the values in the values array. * * @param array $params * Input parameters to find object. * @param array $values * Output values of the object. * - * @return CRM_Contact_BAO_Contact|null the found object or null + * @return CRM_Contact_BAO_Contact|null + * The found object or null */ public static function getValues(&$params, &$values) { $contact = new CRM_Contact_BAO_Contact(); @@ -2523,8 +2530,7 @@ public static function getValues(&$params, &$values) { } /** - * Given the component name and returns - * the count of participation of contact + * Given the component name and returns the count of participation of contact. * * @param string $component * Input component name. @@ -2610,8 +2616,6 @@ public static function getCountComponent($component, $contactId, $tableName = NU * Contact object after save. * @param bool $useDefaults * Use default greeting values. - * - * @return void */ public static function processGreetings(&$contact, $useDefaults = FALSE) { if ($useDefaults) { @@ -3185,7 +3189,7 @@ public static function generateTimestampTriggers(&$info, $reqTableName, $related } /** - * Get a list of triggers for the contact table + * Get a list of triggers for the contact table. * * @see hook_civicrm_triggerInfo * @see CRM_Core_DAO::triggerRebuild @@ -3249,8 +3253,7 @@ public static function triggerInfo(&$info, $tableName = NULL) { } /** - * Check if contact is being used in civicrm_domain - * based on $contactId + * Check if contact is being used in civicrm_domain based on $contactId. * * @param int $contactId * Contact id. @@ -3259,8 +3262,9 @@ public static function triggerInfo(&$info, $tableName = NULL) { * true if present else false. */ public static function checkDomainContact($contactId) { - if (!$contactId) + if (!$contactId) { return FALSE; + } $domainId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', $contactId, 'id', 'contact_id'); if ($domainId) { @@ -3273,6 +3277,7 @@ public static function checkDomainContact($contactId) { /** * Get options for a given contact field. + * * @see CRM_Core_DAO::buildOptions * * TODO: Should we always assume chainselect? What fn should be responsible for controlling that flow? @@ -3308,12 +3313,13 @@ public static function buildOptions($fieldName, $context = NULL, $props = array( } /** - * Delete a contact-related object that has an 'is_primary' field + * Delete a contact-related object that has an 'is_primary' field. + * * Ensures that is_primary gets assigned to another object if available * Also calls pre/post hooks * - * @var $type : object type - * @var $id : object id + * @var object $type + * @var int $id * @return bool */ public static function deleteObjectWithPrimary($type, $id) { diff --git a/CRM/Contact/Form/Edit/Phone.php b/CRM/Contact/Form/Edit/Phone.php index 71c48d2b27c5..dd50d6c221cd 100644 --- a/CRM/Contact/Form/Edit/Phone.php +++ b/CRM/Contact/Form/Edit/Phone.php @@ -30,7 +30,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** @@ -39,7 +38,7 @@ class CRM_Contact_Form_Edit_Phone { /** - * Build the form object elements for a phone object + * Build the form object elements for a phone object. * * @param CRM_Core_Form $form * Reference to the form object. @@ -47,8 +46,6 @@ class CRM_Contact_Form_Edit_Phone { * Block number to build. * @param bool $blockEdit * Is it block edit. - * - * @return void */ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockEdit = FALSE) { // passing this via the session is AWFUL. we need to fix this @@ -65,7 +62,7 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockE $form->addSelect("phone[$blockId][phone_type_id]", array( 'entity' => 'phone', 'class' => 'eight', - 'placeholder' => NULL + 'placeholder' => NULL, )); //main phone number with crm_phone class @@ -78,7 +75,7 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockE $form->addSelect("phone[$blockId][location_type_id]", array( 'entity' => 'phone', 'class' => 'eight', - 'placeholder' => NULL + 'placeholder' => NULL, )); //is_Primary radio diff --git a/CRM/Contact/Form/RelatedContact.php b/CRM/Contact/Form/RelatedContact.php index 5ef9d24927f5..3ba4ceee78da 100644 --- a/CRM/Contact/Form/RelatedContact.php +++ b/CRM/Contact/Form/RelatedContact.php @@ -30,7 +30,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** @@ -39,7 +38,6 @@ * It delegates the work to lower level subclasses and integrates the changes * back in. It also uses a lot of functionality with the CRM API's, so any change * made here could potentially affect the API etc. Be careful, be aware, use unit tests. - * */ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { @@ -65,9 +63,7 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { protected $_defaults = array(); /** - * Build all the data structures needed to build the form - * - * @return void + * Build all the data structures needed to build the form. */ public function preProcess() { // reset action from the session @@ -114,9 +110,7 @@ public function setDefaultValues() { } /** - * Build the form object - * - * @return void + * Build the form object. */ public function buildQuickForm() { $params = array(); @@ -155,9 +149,6 @@ public function buildQuickForm() { /** * Form submission of new/edit contact is processed. - * - * - * @return void */ public function postProcess() { // store the submitted values in an array @@ -167,7 +158,7 @@ public function postProcess() { foreach (array( 'phone', 'email', - 'address' + 'address', ) as $locFld) { if (!empty($this->_defaults[$locFld]) && $this->_defaults[$locFld][1]['location_type_id']) { $params[$locFld][1]['is_primary'] = $this->_defaults[$locFld][1]['is_primary']; diff --git a/CRM/Contact/Form/Task.php b/CRM/Contact/Form/Task.php index 134c6965207b..7bce1b4c08a7 100644 --- a/CRM/Contact/Form/Task.php +++ b/CRM/Contact/Form/Task.php @@ -30,12 +30,10 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** * This class generates form components for search-result tasks - * */ class CRM_Contact_Form_Task extends CRM_Core_Form { @@ -87,17 +85,15 @@ class CRM_Contact_Form_Task extends CRM_Core_Form { static protected $_searchFormValues; /** - * Build all the data structures needed to build the form - * - * @param - * - * @return void + * Build all the data structures needed to build the form. */ public function preProcess() { self::preProcessCommon($this); } /** + * Common pre-processing function. + * * @param CRM_Core_Form $form * @param bool $useTable */ @@ -258,7 +254,6 @@ public static function preProcessCommon(&$form, $useTable = FALSE) { } } - if (CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_sel' && ($form->_action != CRM_Core_Action::COPY) ) { @@ -277,8 +272,9 @@ public static function preProcessCommon(&$form, $useTable = FALSE) { } /** - * Get the contact id for custom search - * we are not using prev/next table incase of custom search + * Get the contact id for custom search. + * + * we are not using prev/next table in case of custom search */ public function getContactIds() { // need to perform action on all contacts @@ -326,9 +322,9 @@ public function getContactIds() { /** - * Set default values for the form. Relationship that in edit/view action - * the default values are retrieved from the database + * Set default values for the form. Relationship that in edit/view action. * + * The default values are retrieved from the database. * * @return array */ @@ -338,34 +334,28 @@ public function setDefaultValues() { } /** - * add the rules for form. - * - * @return void + * Add the rules for form. */ public function addRules() { } /** * Build the form object - * - * @return void */ public function buildQuickForm() { $this->addDefaultButtons(ts('Confirm Action')); } /** - * Process the form after the input has been submitted and validated - * - * - * @return void + * Process the form after the input has been submitted and validated. */ public function postProcess() { } /** - * Simple shell that derived classes can call to add buttons to - * the form with a customized title for the main Submit + * Simple shell that derived classes can call to add form buttons. + * + * Allows customized title for the main Submit * * @param string $title * Title of the main button. @@ -373,8 +363,6 @@ public function postProcess() { * Button type for the form after processing. * @param string $backType * @param bool $submitOnce - * - * @return void */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { $this->addButtons(array( diff --git a/CRM/Contact/Selector/Custom.php b/CRM/Contact/Selector/Custom.php index b0a8cf111e93..54a0f1132a8c 100644 --- a/CRM/Contact/Selector/Custom.php +++ b/CRM/Contact/Selector/Custom.php @@ -30,14 +30,12 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id: Selector.php 11510 2007-09-18 09:21:34Z lobo $ - * */ /** * This class is used to retrieve and display a range of * contacts that match the given criteria (specifically for * results of advanced search options. - * */ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { @@ -117,7 +115,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { * * @return \CRM_Contact_Selector_Custom */ - function __construct( + public function __construct( $customSearchClass, $formValues = NULL, $params = NULL, @@ -154,8 +152,8 @@ function __construct( /** * This method returns the links that are given for each search row. - * currently the links added for each row are * + * Currently the links added for each row are * - View * - Edit * @@ -214,8 +212,9 @@ public function getPagerParams($action, &$params) { } /** - * Returns the column headers as an array of tuples: - * (name, sortName (key to the sort array)) + * Returns the column headers as an array of tuples. + * + * Keys are name, sortName, key to the sort array. * * @param string $action * The action being performed. @@ -251,7 +250,7 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { /** * Returns total number of rows for the query. * - * @param + * @param null $action * * @return int * Total number of rows @@ -261,7 +260,7 @@ public function getTotalCount($action) { } /** - * Returns all the rows in the given offset and rowCount + * Returns all the rows in the given offset and rowCount. * * @param string $action * The action being performed. @@ -371,11 +370,9 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } /** - * Given the current formValues, gets the query in local - * language + * Given the current formValues, gets the query in local language. * - * @param array ( - * reference) $formValues submitted formValues + * @param array $formValues submitted formValues * * @return array * which contains an array of strings @@ -412,6 +409,8 @@ public function alphabetQuery() { } /** + * Generate contact ID query. + * * @param array $params * @param $action * @param int $sortID @@ -420,7 +419,7 @@ public function alphabetQuery() { * * @return Object */ - public function &contactIDQuery($params, $action, $sortID, $displayRelationshipType = NULL, $queryOperator = 'AND') { + public function contactIDQuery($params, $action, $sortID, $displayRelationshipType = NULL, $queryOperator = 'AND') { $params = array(); $sql = $this->_search->contactIDs($params); @@ -428,7 +427,9 @@ public function &contactIDQuery($params, $action, $sortID, $displayRelationshipT } /** - * @param $rows + * Add actions. + * + * @param array $rows */ public function addActions(&$rows) { $links = self::links($this->_key); @@ -453,7 +454,9 @@ public function addActions(&$rows) { } /** - * @param $rows + * Remove actions. + * + * @param array $rows */ public function removeActions(&$rows) { foreach ($rows as $rid => & $rValue) { diff --git a/CRM/Contribute/Controller/ContributionPage.php b/CRM/Contribute/Controller/ContributionPage.php index 821173bde7c7..d93223655314 100644 --- a/CRM/Contribute/Controller/ContributionPage.php +++ b/CRM/Contribute/Controller/ContributionPage.php @@ -30,7 +30,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** @@ -42,24 +41,22 @@ * Typically the first form will display the search criteria and it's results * * The second form is used to process search results with the asscociated actions - * */ class CRM_Contribute_Controller_ContributionPage extends CRM_Core_Controller { /** - * Class constructor + * Class constructor. + * + * @param string $title + * @param bool|int $action + * @param bool $modal */ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE) { parent::__construct($title, $modal); - - $this->_stateMachine = new CRM_Contribute_StateMachine_ContributionPage($this, $action); - - // create and instantiate the pages + // Create and instantiate the pages. $this->addPages($this->_stateMachine, $action); - - // add all the actions $this->addActions(); } } diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index f78231f25877..591be45904d0 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -669,7 +669,6 @@ public static function paperIconAttachment($entityTable, $entityID) { foreach ($currentAttachmentInfo as $fileKey => $fileValue) { $fileID = $fileValue['fileID']; $fileType = $fileValue['mime_type']; - $eid = $entityID; if ($fileID) { if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg' || diff --git a/CRM/Core/Controller.php b/CRM/Core/Controller.php index 1cb6fceffabd..cd62a31fe7f1 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -172,8 +172,6 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * Should we add a unique sequence number to the end of the key. * @param bool $ignoreKey * Should we not set a qfKey for this controller (for standalone forms). - * - * @internal param bool $whether controller is modal */ function __construct( $title = NULL, diff --git a/CRM/Core/Controller/Simple.php b/CRM/Core/Controller/Simple.php index 0c7a4addfbce..f27d31c05ce3 100644 --- a/CRM/Core/Controller/Simple.php +++ b/CRM/Core/Controller/Simple.php @@ -34,16 +34,16 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ class CRM_Core_Controller_Simple extends CRM_Core_Controller { /** - * Constructor + * Constructor. * * @param null $path + * The class Path of the form being implemented * @param bool $title - * @param string path the class Path of the form being implemented + * @param string $mode * @param bool $imageUpload * @param bool $addSequence * Should we add a unique sequence number to the end of the key. @@ -51,10 +51,9 @@ class CRM_Core_Controller_Simple extends CRM_Core_Controller { * Should we not set a qfKey for this controller (for standalone forms). * @param bool $attachUpload * - * * @return \CRM_Core_Controller_Simple */ - function __construct( + public function __construct( $path, $title, $mode = NULL, @@ -108,6 +107,8 @@ function __construct( } /** + * Set parent. + * * @param $parent */ public function setParent($parent) { @@ -126,8 +127,10 @@ public function getTemplateFileName() { } /** - * A wrapper for getTemplateFileName that includes calling the hook to - * prevent us from having to copy & paste the logic of calling the hook + * A wrapper for getTemplateFileName. + * + * This includes calling the hook to prevent us from having to copy & paste + * the logic of calling the hook */ public function getHookedTemplateFileName() { $pageTemplateFile = $this->getTemplateFileName(); diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index ed999153f093..6edc424c0733 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1124,8 +1124,10 @@ public static function deleteEntityContact($daoName, $contactId) { * @param bool $i18nRewrite * @param bool $trapException * - * @return CRM_Core_DAO + * @return CRM_Core_DAO|object * object that holds the results of the query + * NB - if this is defined as just returning a DAO phpstorm keeps pointing + * out all the properties that are not part of the DAO */ public static function &executeQuery( $query, @@ -1158,7 +1160,7 @@ public static function &executeQuery( if ($freeDAO || preg_match('/^(insert|update|delete|create|drop|replace)/i', $queryStr) ) { - // we typically do this for insert/update/delete stataments OR if explicitly asked to + // we typically do this for insert/update/delete statements OR if explicitly asked to // free the dao $dao->free(); } diff --git a/CRM/Core/Page.php b/CRM/Core/Page.php index 521cd824d9f2..d35d792434ad 100644 --- a/CRM/Core/Page.php +++ b/CRM/Core/Page.php @@ -164,9 +164,6 @@ public function __construct($title = NULL, $mode = NULL) { * This function takes care of all the things common to all * pages. This typically involves assigning the appropriate * smarty variable :) - * - * @return string - * The content generated by running this page */ public function run() { if ($this->_embedded) { @@ -242,7 +239,6 @@ public function run() { CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); echo CRM_Utils_System::theme($content, $this->_print); - return; } /** diff --git a/CRM/Core/QuickForm/Action/Upload.php b/CRM/Core/QuickForm/Action/Upload.php index a4fea83a62c4..e36492ab3171 100644 --- a/CRM/Core/QuickForm/Action/Upload.php +++ b/CRM/Core/QuickForm/Action/Upload.php @@ -31,7 +31,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ class CRM_Core_QuickForm_Action_Upload extends CRM_Core_QuickForm_Action { @@ -67,7 +66,7 @@ public function __construct(&$stateMachine, $uploadDir, $uploadNames) { } /** - * Upload and move the file if valid to the uploaded directory + * Upload and move the file if valid to the uploaded directory. * * @param CRM_Core_Form $page * The CRM_Core_Form object. @@ -77,8 +76,6 @@ public function __construct(&$stateMachine, $uploadDir, $uploadNames) { * The name of the page which index the data container with. * @param string $uploadName * The name of the uploaded file. - * - * @return void */ public function upload(&$page, &$data, $pageName, $uploadName) { // make sure uploadName exists in the QF array @@ -101,7 +98,7 @@ public function upload(&$page, &$data, $pageName, $uploadName) { if (!$status) { CRM_Core_Error::statusBounce(ts('We could not move the uploaded file %1 to the upload directory %2. Please verify that the \'Temporary Files\' setting points to a valid path which is writable by your web server.', array( 1 => $value['name'], - 2 => $this->_uploadDir + 2 => $this->_uploadDir, ))); } if (!empty($data['values'][$pageName][$uploadName]['name'])) { @@ -123,8 +120,6 @@ public function upload(&$page, &$data, $pageName, $uploadName) { * CRM_Core_Form the current form-page. * @param string $actionName * Current action name, as one Action object can serve multiple actions. - * - * @return void */ public function perform(&$page, $actionName) { // like in Action_Next @@ -134,11 +129,13 @@ public function perform(&$page, $actionName) { // the above buildForm potentially changes the action function with different args // so basically the rug might have been pulled from us, so we actually just check // and potentially call the right one - // this allows standalong form uploads to work nicely + // this allows standalone form uploads to work nicely $page->controller->_actions['upload']->realPerform($page, $actionName); } /** + * @todo document what I do. + * * @param CRM_Core_Form $page * @param string $actionName * diff --git a/CRM/Dedupe/BAO/QueryBuilder/IndividualSupervised.php b/CRM/Dedupe/BAO/QueryBuilder/IndividualSupervised.php index 973242b41fcf..fe878ad5b43d 100644 --- a/CRM/Dedupe/BAO/QueryBuilder/IndividualSupervised.php +++ b/CRM/Dedupe/BAO/QueryBuilder/IndividualSupervised.php @@ -7,7 +7,9 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualSupervised extends CRM_Dedupe_BAO_QueryBuilder { /** - * @param $rg + * Record - what do I do. + * + * @param object $rg * * @return array */ @@ -17,9 +19,18 @@ public static function record($rg) { $civicrm_email = CRM_Utils_Array::value('civicrm_email', $rg->params, array()); $params = array( - 1 => array(CRM_Utils_Array::value('first_name', $civicrm_contact, ''), 'String'), - 2 => array(CRM_Utils_Array::value('last_name', $civicrm_contact, ''), 'String'), - 3 => array(CRM_Utils_Array::value('email', $civicrm_email, ''), 'String'), + 1 => array( + CRM_Utils_Array::value('first_name', $civicrm_contact, ''), + 'String', + ), + 2 => array( + CRM_Utils_Array::value('last_name', $civicrm_contact, ''), + 'String', + ), + 3 => array( + CRM_Utils_Array::value('email', $civicrm_email, ''), + 'String', + ), ); return array( @@ -35,7 +46,9 @@ public static function record($rg) { } /** - * @param $rg + * Internal - what do I do. + * + * @param object $rg * * @return array */ @@ -52,7 +65,9 @@ public static function internal($rg) { email1.email=email2.email WHERE contact1.contact_type = 'Individual' AND " . self::internalFilters($rg); - return array("civicrm_contact.{$rg->name}.{$rg->threshold}" => $query); + return array( + "civicrm_contact.{$rg->name}.{$rg->threshold}" => $query + ); } } diff --git a/CRM/Event/Form/Task/Email.php b/CRM/Event/Form/Task/Email.php index 37f62567b1ce..d2ab1df0476d 100644 --- a/CRM/Event/Form/Task/Email.php +++ b/CRM/Event/Form/Task/Email.php @@ -30,7 +30,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id: Email.php 45499 2013-02-08 12:31:05Z kurund $ - * */ /** @@ -64,10 +63,8 @@ class CRM_Event_Form_Task_Email extends CRM_Event_Form_Task { /** * Build all the data structures needed to build the form - * - * @return void */ - function preProcess() { + public function preProcess() { CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this); parent::preProcess(); @@ -78,10 +75,7 @@ function preProcess() { } /** - * Build the form object - * - * - * @return void + * Build the form object. */ public function buildQuickForm() { //enable form element @@ -91,10 +85,7 @@ public function buildQuickForm() { } /** - * Process the form after the input has been submitted and validated - * - * - * @return void + * Process the form after the input has been submitted and validated. */ public function postProcess() { CRM_Contact_Form_Task_EmailCommon::postProcess($this); diff --git a/CRM/Mailing/Page/Tab.php b/CRM/Mailing/Page/Tab.php index c2352b187015..fb97b7de0936 100644 --- a/CRM/Mailing/Page/Tab.php +++ b/CRM/Mailing/Page/Tab.php @@ -30,12 +30,10 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** * This class handle mailing and contact related functions - * */ class CRM_Mailing_Page_Tab extends CRM_Contact_Page_View { /** @@ -48,17 +46,13 @@ class CRM_Mailing_Page_Tab extends CRM_Contact_Page_View { public $_contactId = NULL; /** - * called when action is browse - * - * @return null + * Called when action is browse. */ public function browse() { } /** - * Build all the data structures needed to build the form - * - * @return void + * Build all the data structures needed to build the form. */ public function preProcess() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); @@ -70,23 +64,20 @@ public function preProcess() { $this->assign('contactId', $this->_contactId); $this->assign('displayName', $displayName); - // check logged in url permission + // Check logged in url permission. CRM_Contact_Page_View::checkUserPermission($this); - // set page title CRM_Utils_System::setTitle(ts('Mailings sent to %1', array(1 => $displayName))); } /** - * the main function that is called when the page loads, - * it decides the which action has to be taken for the page. + * The main function that is called when the page loads. * - * @return null + * It decides the which action has to be taken for the page. */ public function run() { $this->preProcess(); $this->browse(); - - return parent::run(); + parent::run(); } } diff --git a/CRM/Pledge/Selector/Search.php b/CRM/Pledge/Selector/Search.php index d1407fe50ad3..d940e01e60f9 100644 --- a/CRM/Pledge/Selector/Search.php +++ b/CRM/Pledge/Selector/Search.php @@ -30,14 +30,12 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** * This class is used to retrieve and display a range of * contacts that match the given criteria (specifically for * results of advanced search options. - * */ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { @@ -130,7 +128,7 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { protected $_query; /** - * Class constructor + * Class constructor. * * @param array $queryParams * Array of parameters for query. @@ -146,7 +144,7 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { * * @return \CRM_Pledge_Selector_Search */ - function __construct( + public function __construct( &$queryParams, $action = CRM_Core_Action::NONE, $additionalClause = NULL, @@ -176,8 +174,8 @@ function __construct( /** * This method returns the links that are given for each search row. - * currently the links added for each row are * + * Currently the links added for each row are: * - View * - Edit * @@ -249,7 +247,7 @@ public function getPagerParams($action, &$params) { /** * Returns total number of rows for the query. * - * @param + * @param int $action * * @return int * Total number of rows @@ -264,7 +262,7 @@ public function getTotalCount($action) { } /** - * Returns all the rows in the given offset and rowCount + * Returns all the rows in the given offset and rowCount. * * @param string $action * The action being performed. @@ -362,6 +360,8 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } /** + * Get qill (display what was searched on). + * * @inheritDoc */ public function getQILL() { @@ -369,8 +369,9 @@ public function getQILL() { } /** - * Returns the column headers as an array of tuples: - * (name, sortName (key to the sort array)) + * Returns the column headers as an array of tuples. + * + * Keys are name, sortName, key to the sort array * * @param string $action * The action being performed. @@ -441,6 +442,8 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { } /** + * Get sql query string. + * * @return string */ public function &getQuery() { diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 70e7485da973..b519e19181cb 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -74,7 +74,7 @@ class CRM_Report_Form extends CRM_Core_Form { /** * The set of all columns in the report. An associative array - * with column name as the key and attribues as the value + * with column name as the key and attributes as the value * * @var array */ @@ -147,9 +147,6 @@ class CRM_Report_Form extends CRM_Core_Form { protected $_tagFilter = FALSE; /** - * <<<<<<< HEAD - * Build groups filter - * ======= * specify entity table for tags filter * */ @@ -158,7 +155,7 @@ class CRM_Report_Form extends CRM_Core_Form { /** * build groups filter * - * >>>>>>> 098a61330d0fe12153370741ec98cb1172ece849 + * @var bool */ protected $_groupFilter = FALSE; @@ -207,6 +204,21 @@ class CRM_Report_Form extends CRM_Core_Form { protected $_selectAliases = array(); protected $_rollup = NULL; + /** + * @var array + */ + protected $_aliases = array(); + + /** + * @var string + */ + protected $_where; + + /** + * @var string + */ + protected $_from; + /** * SQL Limit clause * @var string @@ -228,6 +240,9 @@ class CRM_Report_Form extends CRM_Core_Form { * @var integer */ protected $_offsetValue = NULL; + /** + * @var null + */ protected $_sections = NULL; protected $_autoIncludeIndexedFieldsAsOrderBys = 0; protected $_absoluteUrl = FALSE; @@ -272,7 +287,7 @@ class CRM_Report_Form extends CRM_Core_Form { protected $_selectedTables; /** - * Outputmode e.g 'print', 'csv', 'pdf' + * Output mode e.g 'print', 'csv', 'pdf' * @var string */ protected $_outputMode; @@ -306,6 +321,57 @@ class CRM_Report_Form extends CRM_Core_Form { */ protected $_currencyColumn = NULL; + /** + * @var string + */ + protected $_interval; + + /** + * @var bool + */ + protected $_sendmail; + + /** + * @var int + */ + protected $_chartId; + + /** + * @var int + */ + public $_section; + + /** + * @var string Report description. + */ + public $_description; + + /** + * @var bool Is an address field selected. + * This was intended to determine if the address table should be joined in + * The isTableSelected function is now preferred for this purpose + */ + protected $_addressField; + + /** + * @var bool Is an email field selected. + * This was intended to determine if the email table should be joined in + * The isTableSelected function is now preferred for this purpose + */ + protected $_emailField; + + /** + * @var bool Is a phone field selected. + * This was intended to determine if the phone table should be joined in + * The isTableSelected function is now preferred for this purpose + */ + protected $_phoneField; + + /** + * @var bool Create new report instance? (or update existing) on save. + */ + protected $_createNew; + /** */ public function __construct() { @@ -809,7 +875,7 @@ public function setDefaultValues($freeze = TRUE) { } /** - * @param $group + * @param string $group * @param string $grpFieldName * * @return bool @@ -836,10 +902,10 @@ public function setParams($params) { /** * Setter for $_id * - * @param int $instanceid + * @param int $instanceID */ - public function setID($instanceid) { - $this->_id = $instanceid; + public function setID($instanceID) { + $this->_id = $instanceID; } /** @@ -1212,10 +1278,10 @@ public function buildQuickForm() { } /** - * a formrule function to ensure that fields selected in group_by + * A form rule function to ensure that fields selected in group_by * (if any) should only be the ones present in display/select fields criteria; * note: works if and only if any custom field selected in group_by. - * @param $fields + * @param array $fields * @param array $ignoreFields * * @return array @@ -1256,7 +1322,7 @@ public function customDataFormRule($fields, $ignoreFields = array()) { * Note: $fieldName param allows inheriting class to build operationPairs * specific to a field. * @param string $type - * @param null $fieldName + * @param string $fieldName * * @return array */ @@ -1340,7 +1406,7 @@ public function buildTagFilter() { } /** - * Adds group filters to _columns (called from _Constuct + * Adds group filters to _columns (called from _Construct */ public function buildGroupFilter() { $this->_columns['civicrm_group']['filters'] = array( @@ -1408,18 +1474,18 @@ public function getSQLOperator($operator = "like") { } /** - * @param $field - * @param $op - * @param $value - * @param $min - * @param $max + * Generate where clause. + * This can be overridden in reports for special treatment of a field + * + * @param array $field Field specifications + * @param string $op Query operator (not an exact match to sql) + * @param mixed $value + * @param float $min + * @param float $max * * @return null|string */ - public function whereClause( - &$field, $op, - $value, $min, $max - ) { + public function whereClause(&$field, $op, $value, $min, $max) { $type = CRM_Utils_Type::typeToString(CRM_Utils_Array::value('type', $field)); $clause = NULL; @@ -1486,7 +1552,7 @@ public function whereClause( if (CRM_Utils_Array::value('type', $field) == CRM_Utils_Type::T_STRING ) { - //cycle through selections and esacape values + //cycle through selections and escape values foreach ($value as $key => $selection) { $value[$key] = CRM_Utils_Type::escape($selection, $type); } @@ -1583,10 +1649,10 @@ public function whereClause( $clause = $this->whereTagClause($field, $value, $op); } elseif (!empty($field['membership_org']) && $clause) { - $clause = $this->whereMembershipOrgClause($field, $value, $op); + $clause = $this->whereMembershipOrgClause($value, $op); } elseif (!empty($field['membership_type']) && $clause) { - $clause = $this->whereMembershipTypeClause($field, $value, $op); + $clause = $this->whereMembershipTypeClause($value, $op); } return $clause; } @@ -1594,8 +1660,8 @@ public function whereClause( /** * @param string $fieldName * @param $relative - * @param $from - * @param $to + * @param string $from + * @param string $to * @param null $type * @param null $fromTime * @param null $toTime @@ -1634,7 +1700,7 @@ public function dateClause( /** * @todo - could not find any instances where this is called * - * @param unknown_type $relative + * @param bool $relative * @param string $from * @param string_type $to * @@ -1665,17 +1731,17 @@ public function dateDisplay($relative, $from, $to) { } /** - * @param $relative - * @param $from - * @param $to - * @param null $fromtime - * @param null $totime + * @param bool $relative + * @param string $from + * @param string $to + * @param string $fromTime + * @param string $toTime * * @return array */ - public function getFromTo($relative, $from, $to, $fromtime = NULL, $totime = NULL) { - if (empty($totime)) { - $totime = '235959'; + public function getFromTo($relative, $from, $to, $fromTime = NULL, $toTime = NULL) { + if (empty($toTime)) { + $toTime = '235959'; } //FIX ME not working for relative if ($relative) { @@ -1685,8 +1751,8 @@ public function getFromTo($relative, $from, $to, $fromtime = NULL, $totime = NUL //Take only Date Part, Sometime Time part is also present in 'to' $to = substr($dateRange['to'], 0, 8); } - $from = CRM_Utils_Date::processDate($from, $fromtime); - $to = CRM_Utils_Date::processDate($to, $totime); + $from = CRM_Utils_Date::processDate($from, $fromTime); + $to = CRM_Utils_Date::processDate($to, $toTime); return array($from, $to); } @@ -1918,7 +1984,6 @@ public function removeDuplicates(&$rows) { public function fixSubTotalDisplay(&$row, $fields, $subtotal = TRUE) { foreach ($row as $colName => $colVal) { if (in_array($colName, $fields)) { - $row[$colName] = $row[$colName]; } elseif (isset($this->_columnHeaders[$colName])) { if ($subtotal) { @@ -2460,7 +2525,7 @@ public function storeOrderByArray() { !empty($this->_params['order_bys']) ) { - // Proces order_bys in user-specified order + // Process order_bys in user-specified order foreach ($this->_params['order_bys'] as $orderBy) { $orderByField = array(); foreach ($this->_columns as $tableName => $table) { @@ -2900,7 +2965,7 @@ public function endPostProcess(&$rows = NULL) { 'openFlashChart/' . $chartImg; //Load the image $chart = imagecreatefrompng($uploadUrl); - //convert it into formattd png + //convert it into formatted png header('Content-type: image/png'); //overwrite with same image imagepng($chart, $uploadImg); @@ -2929,6 +2994,10 @@ public function endPostProcess(&$rows = NULL) { } } + /** + * Set store result set indicator to TRUE + * @todo explain what this does + */ public function storeResultSet() { $this->_storeResultSet = TRUE; } @@ -3007,12 +3076,14 @@ public function limit($rowCount = self::ROW_COUNT_LIMIT) { $pageId = CRM_Utils_Request::retrieve('crmPID', 'Integer', CRM_Core_DAO::$_nullObject); + // @todo all http vars should be extracted in the preProcess + // - not randomly in the class if (!$pageId && !empty($_POST)) { if (isset($_POST['PagerBottomButton']) && isset($_POST['crmPID_B'])) { - $pageId = max((int) @$_POST['crmPID_B'], 1); + $pageId = max((int) $_POST['crmPID_B'], 1); } elseif (isset($_POST['PagerTopButton']) && isset($_POST['crmPID'])) { - $pageId = max((int) @$_POST['crmPID'], 1); + $pageId = max((int) $_POST['crmPID'], 1); } unset($_POST['crmPID_B'], $_POST['crmPID']); } @@ -3135,7 +3206,15 @@ public function whereTagClause($field, $value, $op) { WHERE entity_table = '$entity_table' AND {$clause} ) "; } - public function whereMembershipOrgClause($field, $value, $op) { + /** + * Generate membership organization clause. + * + * @param mixed $value + * @param string $op SQL Operator + * + * @return string + */ + public function whereMembershipOrgClause($value, $op) { $sqlOp = $this->getSQLOperator($op); if (!is_array($value)) { $value = array($value); @@ -3154,7 +3233,15 @@ public function whereMembershipOrgClause($field, $value, $op) { AND mem_status.is_active = '1' ) "; } - public function whereMembershipTypeClause($field, $value, $op) { + /** + * Generate Membership Type SQL Clause + * @param mixed $value + * @param string $op + * + * @return string + * SQL query string + */ + public function whereMembershipTypeClause($value, $op) { $sqlOp = $this->getSQLOperator($op); if (!is_array($value)) { $value = array($value); @@ -3493,6 +3580,8 @@ public function isFieldSelected($prop) { /** * Check for empty order_by configurations and remove them; also set * template to hide them. + * + * @param array $formValues */ public function preProcessOrderBy(&$formValues) { // Object to show/hide form elements diff --git a/CRM/Report/Form/Contact/Summary.php b/CRM/Report/Form/Contact/Summary.php index 279ad17deeb7..6a3ae459ccc4 100644 --- a/CRM/Report/Form/Contact/Summary.php +++ b/CRM/Report/Form/Contact/Summary.php @@ -34,7 +34,7 @@ */ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form { - protected $_summary = NULL; + public $_summary = NULL; protected $_emailField = FALSE; diff --git a/CRM/Report/Form/Membership/Summary.php b/CRM/Report/Form/Membership/Summary.php index 4e8746bdd573..387abf456675 100644 --- a/CRM/Report/Form/Membership/Summary.php +++ b/CRM/Report/Form/Membership/Summary.php @@ -30,7 +30,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { @@ -43,12 +42,11 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { ); /** - */ - /** + * Constructor function. */ public function __construct() { // UI for selecting columns to appear in the report list - // array conatining the columns, group_bys and filters build and provided to Form + // array containing the columns, group_bys and filters build and provided to Form $this->_columns = array( 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', @@ -139,18 +137,27 @@ public function __construct() { parent::__construct(); } + /** + * Pre-process function. + */ public function preProcess() { $this->assign('reportTitle', ts('Membership Summary Report')); parent::preProcess(); } /** + * Set default values. + * * @return array + * Default values. */ public function setDefaultValues() { return parent::setDefaultValues(); } + /** + * Generate select clause. + */ public function select() { $select = array(); $this->_columnHeaders = array(); @@ -179,6 +186,8 @@ public function select() { } /** + * Set form rules. + * * @param $fields * @param $files * @param $self @@ -205,12 +214,12 @@ public function from() { LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} ON {$this->_aliases['civicrm_membership']}.contact_id = {$this->_aliases['civicrm_contribution']}.contact_id "; - // include address field if address column is to be included + // Include address table if address column is to be included. if ($this->_addressField) { $this->_from .= "LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']} ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND {$this->_aliases['civicrm_address']}.is_primary = 1\n"; } - // include email field if email column is to be included + // Include email table if email column is to be included. if ($this->_emailField) { $this->_from .= "LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']} ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND {$this->_aliases['civicrm_email']}.is_primary = 1\n"; } @@ -259,7 +268,9 @@ public function where() { } /** - * @param $rows + * Generate statistics (bottom section of the report). + * + * @param array $rows * * @return array */ @@ -363,7 +374,9 @@ public function postProcess() { } /** - * @param $rows + * Make changes to how data is displayed. + * + * @param array $rows */ public function alterDisplay(&$rows) { // custom code to alter rows @@ -418,12 +431,13 @@ public function alterDisplay(&$rows) { if (array_key_exists('civicrm_contact_sort_name', $row) && array_key_exists('civicrm_contact_id', $row) ) { - $url = CRM_Utils_System::url('civicrm/report/member/detail', + $url = CRM_Utils_System::url( + 'civicrm/report/member/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'], $this->_absoluteUrl ); - $rows[$rowNum]['civicrm_contact_sort_name'] = - "" . $row["civicrm_contact_sort_name"] . ''; + $rows[$rowNum]['civicrm_contact_sort_name'] + = "" . $row["civicrm_contact_sort_name"] . ''; $entryFound = TRUE; } diff --git a/CRM/SMS/Controller/Send.php b/CRM/SMS/Controller/Send.php index 68a2ed858a51..48037399b7b6 100644 --- a/CRM/SMS/Controller/Send.php +++ b/CRM/SMS/Controller/Send.php @@ -36,6 +36,10 @@ class CRM_SMS_Controller_Send extends CRM_Core_Controller { /** * Class constructor + * + * @param string $title + * @param bool|int $action + * @param bool $modal */ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE) { parent::__construct($title, $modal, NULL, FALSE, TRUE); @@ -64,8 +68,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod CRM_Core_BAO_File::uploadNames() ); - $config = CRM_Core_Config::singleton(); - $this->addActions($config->uploadDir, + $this->addActions(CRM_Core_Config::singleton()->uploadDir, $uploadNames ); } diff --git a/CRM/SMS/Form/Provider.php b/CRM/SMS/Form/Provider.php index c6e532a617e7..91a15f19491a 100644 --- a/CRM/SMS/Form/Provider.php +++ b/CRM/SMS/Form/Provider.php @@ -30,11 +30,10 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2014 * $Id: $ - * */ /** - * + * SMS Form. */ class CRM_SMS_Form_Provider extends CRM_Core_Form { protected $_id = NULL; @@ -62,9 +61,7 @@ public function preProcess() { } /** - * Build the form object - * - * @return void + * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); @@ -124,15 +121,8 @@ public function buildQuickForm() { } /** - * This virtual function is used to set the default values of - * various form elements - * - * access public + * Set the default values of various form elements. * - * @return array - * reference to the array of default values - */ - /** * @return array */ public function setDefaultValues() { @@ -153,8 +143,9 @@ public function setDefaultValues() { $dao = new CRM_SMS_DAO_Provider(); $dao->id = $this->_id; - if ($name) + if ($name) { $dao->name = $name; + } if (!$dao->find(TRUE)) { return $defaults; @@ -166,10 +157,7 @@ public function setDefaultValues() { } /** - * Process the form submission - * - * - * @return void + * Process the form submission. */ public function postProcess() { diff --git a/CRM/SMS/StateMachine/Send.php b/CRM/SMS/StateMachine/Send.php index 57f724a371e6..c51f4dee7bfd 100644 --- a/CRM/SMS/StateMachine/Send.php +++ b/CRM/SMS/StateMachine/Send.php @@ -45,7 +45,6 @@ class CRM_SMS_StateMachine_Send extends CRM_Core_StateMachine { * @param object $controller * @param \const|int $action * - * @internal param \CRM_SMS_Controller $object * @return \CRM_SMS_StateMachine_Send CRM_SMS_StateMachine */ public function __construct($controller, $action = CRM_Core_Action::NONE) { diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 49d571c73bdf..ab2ffe6e5ce4 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -250,7 +250,9 @@ public static function escape($data, $type, $abort = TRUE) { break; default: - CRM_Core_Error::fatal("Cannot recognize $type for $data"); + CRM_Core_Error::fatal( + $type . " is not a recognised (camel cased) data type." + ); break; } diff --git a/api/v3/EntityTag.php b/api/v3/EntityTag.php index 249515640d38..a39ded5c2dac 100644 --- a/api/v3/EntityTag.php +++ b/api/v3/EntityTag.php @@ -40,8 +40,7 @@ */ /** - * {@getfields EntityTag_get} - * @example EntityTagGet.php + * Get entity tags. * * @param array $params * @@ -64,9 +63,10 @@ function civicrm_api3_entity_tag_get($params) { } /** - * Adjust Metadata for Get action + * Adjust Metadata for Get action. + * + * The metadata is used for setting defaults, documentation & validation. * - * The metadata is used for setting defaults, documentation & validation * @param array $params * Array or parameters determined by getfields. */ @@ -76,20 +76,18 @@ function _civicrm_api3_entity_tag_get_spec(&$params) { } /** + * Create an entity tag. * * @param array $params * * @return array - * {@getfields EntityTag_create} - * @example EntityTagCreate.php */ function civicrm_api3_entity_tag_create($params) { return _civicrm_api3_entity_tag_common($params, 'add'); } /** - * {@getfields EntityTag_delete} - * @example EntityTagGet.php + * Mark entity tag as removed. * * @param array $params * @@ -101,7 +99,8 @@ function civicrm_api3_entity_tag_delete($params) { } /** - * modify metadata + * Modify metadata. + * * @param array $params */ function _civicrm_api3_entity_tag_delete_spec(&$params) { @@ -110,12 +109,12 @@ function _civicrm_api3_entity_tag_delete_spec(&$params) { } /** + * Helper function for formatting tags (part of api v2 legacy). * * @param array $params * @param string $op * * @return array - * */ function _civicrm_api3_entity_tag_common($params, $op = 'add') { diff --git a/api/v3/Im.php b/api/v3/Im.php index f117aec3004e..39dcb176af27 100644 --- a/api/v3/Im.php +++ b/api/v3/Im.php @@ -64,7 +64,6 @@ function _civicrm_api3_im_create_spec(&$params) { * Deletes an existing IM * * @param array $params - * {@getfields im_delete} * * @return array * API result Array diff --git a/api/v3/MailingEventConfirm.php b/api/v3/MailingEventConfirm.php index eca1e3403247..60a34522e4c2 100644 --- a/api/v3/MailingEventConfirm.php +++ b/api/v3/MailingEventConfirm.php @@ -33,11 +33,10 @@ * @subpackage API_MailerGroup * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** - * Handle a confirm event + * Handle a confirm event. * * @param array $params * Associative array of property. @@ -46,7 +45,6 @@ * @throws Exception * @return array * api result array - * {@getfields mailing_event_confirm_create} */ function civicrm_api3_mailing_event_confirm_create($params) { @@ -63,9 +61,10 @@ function civicrm_api3_mailing_event_confirm_create($params) { } /** - * Adjust Metadata for Create action + * Adjust Metadata for Create action. + * + * The metadata is used for setting defaults, documentation & validation. * - * The metadata is used for setting defaults, documentation & validation * @param array $params * Array or parameters determined by getfields. */ diff --git a/api/v3/MailingEventResubscribe.php b/api/v3/MailingEventResubscribe.php index aa3bdf7d897d..d0db0ed9773a 100644 --- a/api/v3/MailingEventResubscribe.php +++ b/api/v3/MailingEventResubscribe.php @@ -33,19 +33,15 @@ * @subpackage API_MailerGroup * @copyright CiviCRM LLC (c) 2004-2014 * $Id$ - * */ /** - * Subscribe from mailing group + * Subscribe from mailing group. * * @param array $params - * Associative array of property. - * name/value pairs to insert in new 'survey' * * @return array * api result array - * {@getfields mailing_event_subscribe_create} */ function civicrm_api3_mailing_event_resubscribe_create($params) { @@ -67,9 +63,10 @@ function civicrm_api3_mailing_event_resubscribe_create($params) { } /** - * Adjust Metadata for Create action + * Adjust Metadata for Create action. + * + * The metadata is used for setting defaults, documentation & validation. * - * The metadata is used for setting defaults, documentation & validation * @param array $params * Array or parameters determined by getfields. */ diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index 192482f65cb6..eeec7c878ab6 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -7,26 +7,31 @@ * Class CRM_Contact_BAO_ContactTest */ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { + + /** + * Set up function. + */ public function setUp() { parent::setUp(); } /** - * Test case for add( ) + * Test case for add( ). + * * test with empty params. */ public function testAddWithEmptyParams() { $params = array(); $contact = CRM_Contact_BAO_Contact::add($params); - //Now check Contact object + // Now check Contact object. $this->assertNull($contact); } /** - * Test case for add( ) - * test with names - * (create and update modes) + * Test case for add( ). + * + * Test with names (create and update modes) */ public function testAddWithNames() { $firstName = 'Shane'; @@ -39,14 +44,14 @@ public function testAddWithNames() { $contact = CRM_Contact_BAO_Contact::add($params); - //Now check $contact is object of contact DAO.. + // Now check $contact is object of contact DAO. $this->assertInstanceOf('CRM_Contact_DAO_Contact', $contact, 'Check for created object'); $this->assertEquals($firstName, $contact->first_name, 'Check for first name creation.'); $this->assertEquals($lastName, $contact->last_name, 'Check for last name creation.'); $contactId = $contact->id; - //update and change first name and last name, using add( ) + // Update and change first name and last name, using add( ). $firstName = 'Jane'; $params = array( 'first_name' => $firstName, @@ -56,7 +61,7 @@ public function testAddWithNames() { $contact = CRM_Contact_BAO_Contact::add($params); - //Now check $contact is object of contact DAO.. + // Now check $contact is object of contact DAO. $this->assertInstanceOf('CRM_Contact_DAO_Contact', $contact, 'Check for created object'); $this->assertEquals($firstName, $contact->first_name, 'Check for updated first name.'); @@ -65,25 +70,22 @@ public function testAddWithNames() { } /** - * Test case for add( ) - * test with all contact params - * (creat and update modes) + * Test case for add. + * + * Test with all contact params + * (create and update modes) */ public function testAddWithAll() { - //take the common contact params + // Take the common contact params. $params = $this->contactParams(); unset($params['location']); $prefComm = $params['preferred_communication_method']; - - //create the contact using add() $contact = CRM_Contact_BAO_Contact::add($params); $contactId = $contact->id; - //Now check $contact is object of contact DAO.. $this->assertInstanceOf('CRM_Contact_DAO_Contact', $contact, 'Check for created object'); - //Now check values of object with params. $this->assertEquals($params['first_name'], $contact->first_name, 'Check for first name creation.'); $this->assertEquals($params['last_name'], $contact->last_name, 'Check for last name creation.'); $this->assertEquals($params['middle_name'], $contact->middle_name, 'Check for middle name creation.'); @@ -121,7 +123,6 @@ public function testAddWithAll() { } $this->assertAttributesEquals($checkPrefComm, $prefComm); - //now update the contact using add( ) $updateParams = array( 'contact_type' => 'Individual', 'first_name' => 'Jane', @@ -162,14 +163,11 @@ public function testAddWithAll() { $prefComm = $updateParams['preferred_communication_method']; $updateParams['contact_id'] = $contactId; - //create the contact using add() $contact = CRM_Contact_BAO_Contact::create($updateParams); $contactId = $contact->id; - //Now check $contact is object of contact DAO.. $this->assertInstanceOf('CRM_Contact_DAO_Contact', $contact, 'Check for created object'); - //Now check values of object with params. $this->assertEquals($updateParams['first_name'], $contact->first_name, 'Check for first name creation.'); $this->assertEquals($updateParams['last_name'], $contact->last_name, 'Check for last name creation.'); $this->assertEquals($updateParams['middle_name'], $contact->middle_name, 'Check for middle name creation.'); @@ -211,13 +209,11 @@ public function testAddWithAll() { } $this->assertAttributesEquals($checkPrefComm, $prefComm); - //cleanup DB by deleting the contact Contact::delete($contactId); } /** - * Test case for add( ) - * test with All contact types. + * Test case for add( ) with All contact types. */ public function testAddWithAllContactTypes() { $firstName = 'Bill'; @@ -484,23 +480,24 @@ public function testCreateWithAll() { ); $compareParams = array('phone' => '9766323895'); $this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams); - //As we are not updating note - //Now check DB for New Note - $noteId = $this->assertDBNotNull('CRM_Core_DAO_Note', $updateParams['note'], 'id', 'note', + // As we are not updating note. + // Now check DB for New Note. + $this->assertDBNotNull('CRM_Core_DAO_Note', $updateParams['note'], 'id', 'note', 'Database check for New created note ' ); - //delete all notes related to contact + // Delete all notes related to contact. CRM_Core_BAO_Note::cleanContactNotes($contactId); - //cleanup DB by deleting the contact + // Cleanup DB by deleting the contact. Contact::delete($contactId); $this->quickCleanup(array('civicrm_contact', 'civicrm_note')); } /** - * Test case for resolveDefaults( ) - * test all pseudoConstant, stateProvince, country. + * Test case for resolveDefaults( ). + * + * Test all pseudoConstant, stateProvince, country. */ public function testResolveDefaults() { $params = array( @@ -719,9 +716,7 @@ public function testDeleteContact() { } /** - * Test case for createProfileContac( ) - * test with all params. - * ( create and update modes ) + * Test case for createProfileContact. */ public function testCreateProfileContact() { $fields = CRM_Contact_BAO_Contact::exportableFields('Individual'); @@ -1112,7 +1107,7 @@ public function testCreateProfileContact() { } /** - * Test case for getContactDetails( ) + * Test case for getContactDetails( ). */ public function testGetContactDetails() { //get the contact params @@ -1138,8 +1133,7 @@ public function testGetContactDetails() { } /** - * Test case for - * importableFields( ) and exportableFields( ) + * Test case for importableFields( ) and exportableFields( ). */ public function testFields() { $allImpFileds = CRM_Contact_BAO_Contact::importableFields('All'); @@ -1306,23 +1300,6 @@ public function testGetDisplayAndImage() { Contact::delete($contactId); } - // /** - // * test logged in user has permissions for - // * various operation types - // */ - // function testPermissionedContact() - // { - // $contactId = Contact::createIndividual(); - // require_once 'CRM/Contact/BAO/Contact/Permission.php'; - // $userViewPermission = CRM_Contact_BAO_Contact_Permission::allow($contactId); - // $this->assertEquals( $userViewPermission, true, 'Check user for view contact permission.' ); - // - // $userEditPermission = CRM_Contact_BAO_Contact_Permission::allow($contactId, CRM_Core_Permission::EDIT); - // $this->assertEquals( $userEditPermission, true, 'Check user for edit contact permission.' ); - // - // Contact::delete($contactId); - // } - /** * Build common params */ @@ -1422,9 +1399,9 @@ private function contactParams() { } /** - * Ensure that created_date and modified_date are set + * Ensure that created_date and modified_date are set. */ - public function testTimestamps_contact() { + public function testTimestampContact() { $test = $this; $this->_testTimestamps(array( 'UPDATE' => function ($contactId) use ($test) { @@ -1433,16 +1410,16 @@ public function testTimestamps_contact() { 'contact_type' => 'Individual', 'contact_id' => $contactId, ); - $contact = CRM_Contact_BAO_Contact::add($params); - $test->assertInstanceOf('CRM_Contact_DAO_Contact', $contact, 'Check for created object'); + $contact = CRM_Contact_BAO_Contact::add($params); + $test->assertInstanceOf('CRM_Contact_DAO_Contact', $contact, 'Check for created object'); }, )); } /** - * Ensure that civicrm_contact.modified_date is updated when manipulating a phone record + * Ensure that civicrm_contact.modified_date is updated when manipulating a phone record. */ - public function testTimestamps_email() { + public function testTimestampsEmail() { $test = $this; $this->_testTimestamps(array( 'INSERT' => function ($contactId) use ($test) { diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index 76f4a7bd5f21..00218f5a6e11 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -43,7 +43,7 @@ public function setUp() { require_once 'CiviTest/CiviMailUtils.php'; $this->mut = new CiviMailUtils($this, TRUE); - $this->fixtures['rolling_membership'] = array(// createTestObject + $this->fixtures['rolling_membership'] = array( 'membership_type_id' => array( 'period_type' => 'rolling', 'duration_unit' => 'month', @@ -69,25 +69,25 @@ public function setUp() { 'is_override' => 'NULL', ); - $this->fixtures['phonecall'] = array(// createTestObject + $this->fixtures['phonecall'] = array( 'status_id' => 1, 'activity_type_id' => 2, 'activity_date_time' => '20120615100000', 'is_current_revision' => 1, 'is_deleted' => 0, ); - $this->fixtures['contact'] = array(// API + $this->fixtures['contact'] = array( 'is_deceased' => 0, 'contact_type' => 'Individual', 'email' => 'test-member@example.com', ); - $this->fixtures['contact_birthdate'] = array(// API + $this->fixtures['contact_birthdate'] = array( 'is_deceased' => 0, 'contact_type' => 'Individual', 'email' => 'test-bday@example.com', 'birth_date' => '20050707', ); - $this->fixtures['sched_activity_1day'] = array(// create() + $this->fixtures['sched_activity_1day'] = array( 'name' => 'One_Day_Phone_Call_Notice', 'title' => 'One Day Phone Call Notice', 'limit_to' => '1', diff --git a/tests/phpunit/CRM/Extension/Container/AllTests.php b/tests/phpunit/CRM/Extension/Container/AllTests.php index 2eee6875bf63..f4db10030f6a 100644 --- a/tests/phpunit/CRM/Extension/Container/AllTests.php +++ b/tests/phpunit/CRM/Extension/Container/AllTests.php @@ -44,24 +44,23 @@ class CRM_Extension_Container_AllTests extends CiviTestSuite { private static $instance = NULL; /** + * Get instance. */ private static function getInstance() { if (is_null(self::$instance)) { - self::$instance = new self; + self::$instance = new self(); } return self::$instance; } /** - * Build test suite dynamically + * Build test suite dynamically. */ public static function suite() { $inst = self::getInstance(); return $inst->implSuite(__FILE__); } } -// class CRM_Core_AllTests - // -- set Emacs parameters -- // Local variables: // mode: php; diff --git a/tests/phpunit/CRM/Utils/QueryFormatterTest.php b/tests/phpunit/CRM/Utils/QueryFormatterTest.php index 574dd79f0a7d..fb8c9af05441 100644 --- a/tests/phpunit/CRM/Utils/QueryFormatterTest.php +++ b/tests/phpunit/CRM/Utils/QueryFormatterTest.php @@ -8,87 +8,88 @@ class CRM_Utils_QueryFormatterTest extends CiviUnitTestCase { public function dataProvider() { - $cases = array(); // array(0=>$inputText, 1=>$language, 2=>$options, 3=>$expectedText) + // Array(0=>$inputText, 1=>$language, 2=>$options, 3=>$expectedText). + $cases = array(); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_NONE, - '%first second%' + '%first second%', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_PHRASE, - '%first second%' + '%first second%', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, - '%first second%' + '%first second%', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_WILDWORDS, - '%first%second%' + '%first%second%', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, - '%first%second%' + '%first%second%', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_NONE, - 'first second' + 'first second', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_PHRASE, - '"first second"' + '"first second"', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, - '"*first second*"' + '"*first second*"', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_WILDWORDS, - '*first* *second*' + '*first* *second*', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, - 'first* second*' + 'first* second*', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, CRM_Utils_QueryFormatter::MODE_NONE, - '+first +second' + '+first +second', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, CRM_Utils_QueryFormatter::MODE_PHRASE, - '+"first second"' + '+"first second"', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, - '+"*first second*"' + '+"*first second*"', ); $cases[] = array( 'first second', @@ -125,13 +126,13 @@ public function dataProvider() { 'first second', CRM_Utils_QueryFormatter::LANG_SOLR, CRM_Utils_QueryFormatter::MODE_WILDWORDS, - '*first* *second*' + '*first* *second*', ); $cases[] = array( 'first second', CRM_Utils_QueryFormatter::LANG_SOLR, CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, - 'first* second*' + 'first* second*', ); // if user supplies wildcards, then ignore mode @@ -139,7 +140,7 @@ public function dataProvider() { CRM_Utils_QueryFormatter::MODE_NONE, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, CRM_Utils_QueryFormatter::MODE_WILDWORDS, - CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX + CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, ) as $mode) { $cases[] = array('first% second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, $mode, 'first% second'); $cases[] = array('first% second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, $mode, 'first* second'); diff --git a/tests/phpunit/WebTest/Event/MultiprofileEventTest.php b/tests/phpunit/WebTest/Event/MultiprofileEventTest.php index ee2a2babad01..7ec493e19b60 100644 --- a/tests/phpunit/WebTest/Event/MultiprofileEventTest.php +++ b/tests/phpunit/WebTest/Event/MultiprofileEventTest.php @@ -410,14 +410,16 @@ public function _testGetProfileId($customId) { } /** - * @param $profilefield + * Test profile creation. + * +*@param $profileField * @param int $location * @param $type * * @return null */ - public function _testCreateProfile($profilefield, $location = 0, $type) { - $locationfields = array( + public function _testCreateProfile($profileField, $location = 0, $type) { + $locationFields = array( 'supplemental_address_1', 'supplemental_address_2', 'city', @@ -429,22 +431,22 @@ public function _testCreateProfile($profilefield, $location = 0, $type) { ); // Add new profile. - $profilename = "Profile_" . substr(sha1(rand()), 0, 7); + $profileName = "Profile_" . substr(sha1(rand()), 0, 7); $this->openCiviPage("admin/uf/group", "reset=1"); $this->click('newCiviCRMProfile-top'); $this->waitForElementPresent('_qf_Group_next-top'); //Name of profile - $this->type('title', $profilename); + $this->type('title', $profileName); $this->click('uf_group_type_Profile'); $this->click('_qf_Group_next-top'); $this->waitForPageToLoad($this->getTimeoutMsec()); $profileId = $this->urlArg('gid'); //Add field to profile_testCreateProfile - foreach ($profilefield as $key => $value) { + foreach ($profileField as $key => $value) { $this->openCiviPage("admin/uf/group/field/add", "reset=1&action=add&gid=$profileId"); - if (in_array($value, $locationfields)) { + if (in_array($value, $locationFields)) { $this->select("field_name[0]", "value={$type}"); $this->select("field_name[1]", "value={$value}"); $this->select("field_name[2]", "value={$location}"); diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 5fecd0634bd2..d81c7a952c17 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -50,6 +50,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { protected $_ids = array(); protected $_pageParams = array(); + /** + * Setup function. + */ public function setUp() { parent::setUp(); @@ -91,10 +94,16 @@ public function setUp() { ); } + /** + * Clean up after each test. + */ public function tearDown() { $this->quickCleanUpFinancialEntities(); } + /** + * Test Get. + */ public function testGetContribution() { $p = array( 'contact_id' => $this->_individualId, @@ -122,8 +131,9 @@ public function testGetContribution() { $this->assertEquals(1, $contribution['count']); $this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId); - // note there was an assertion converting financial_type_id to 'Donation' which wasn't working. - // passing back a string rather than an id seems like an error / cruft - & if it is to be introduced we should discuss + // Note there was an assertion converting financial_type_id to 'Donation' which wasn't working. + // Passing back a string rather than an id seems like an error/cruft. + // If it is to be introduced we should discuss. $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1); $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00); $this->assertEquals($contribution['values'][$contribution['id']]['non_deductible_amount'], 10.00); @@ -133,34 +143,34 @@ public function testGetContribution() { $this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 78910); $this->assertEquals($contribution['values'][$contribution['id']]['contribution_source'], 'SSF'); $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed'); - //create a second contribution - we are testing that 'id' gets the right contribution id (not the contact id) + // Create a second contribution - we are testing that 'id' gets the right contribution id (not the contact id). $p['trxn_id'] = '3847'; $p['invoice_id'] = '3847'; $contribution2 = $this->callAPISuccess('contribution', 'create', $p); - // now we have 2 - test getcount + // Now we have 2 - test getcount. $contribution = $this->callAPISuccess('contribution', 'getcount', array()); $this->assertEquals(2, $contribution); - //test id only format + // Test id only format. $contribution = $this->callAPISuccess('contribution', 'get', array( 'id' => $this->_contribution['id'], 'format.only_id' => 1, )); - $this->assertEquals($this->_contribution['id'], $contribution, print_r($contribution, TRUE) . " in line " . __LINE__); - //test id only format + $this->assertEquals($this->_contribution['id'], $contribution, print_r($contribution, TRUE)); + // Test id only format. $contribution = $this->callAPISuccess('contribution', 'get', array( 'id' => $contribution2['id'], 'format.only_id' => 1, )); $this->assertEquals($contribution2['id'], $contribution); - //test id as field + // Test id as field. $contribution = $this->callAPISuccess('contribution', 'get', array( 'id' => $this->_contribution['id'], )); $this->assertEquals(1, $contribution['count']); - //test get by contact id works + // Test get by contact id works. $contribution = $this->callAPISuccess('contribution', 'get', array('contact_id' => $this->_individualId)); $this->assertEquals(2, $contribution['count']); @@ -173,7 +183,7 @@ public function testGetContribution() { } /** - * We need to ensure previous tested behaviour still works as part of the api contract + * We need to ensure previous tested behaviour still works as part of the api contract. */ public function testGetContributionLegacyBehaviour() { $p = array( @@ -211,7 +221,8 @@ public function testGetContributionLegacyBehaviour() { $this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 78910); $this->assertEquals($contribution['values'][$contribution['id']]['contribution_source'], 'SSF'); $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed'); - //create a second contribution - we are testing that 'id' gets the right contribution id (not the contact id) + + // Create a second contribution - we are testing that 'id' gets the right contribution id (not the contact id). $p['trxn_id'] = '3847'; $p['invoice_id'] = '3847'; @@ -225,7 +236,7 @@ public function testGetContributionLegacyBehaviour() { 'id' => $this->_contribution['id'], 'format.only_id' => 1, )); - $this->assertEquals($this->_contribution['id'], $contribution, print_r($contribution, TRUE) . " in line " . __LINE__); + $this->assertEquals($this->_contribution['id'], $contribution, print_r($contribution, TRUE)); //test id only format $contribution = $this->callAPISuccess('contribution', 'get', array( 'id' => $contribution2['id'], @@ -299,7 +310,7 @@ public function testCreateWithCustom() { )); $this->customFieldDelete($ids['custom_field_id']); $this->customGroupDelete($ids['custom_group_id']); - $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); + $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']]); } /** @@ -532,9 +543,9 @@ public function testCreateDefaultNow() { } /** - * Create test with unique field name on source + * Create test with unique field name on source. */ - public function testCreateContributionSourceInvalidContac() { + public function testCreateContributionSourceInvalidContact() { $params = array( 'contact_id' => 999, @@ -634,29 +645,28 @@ public function testCreateContributionWithNoteUniqueNameAliases() { } /** - * This is the test for creating soft credits - however a 'get' is not yet possible via API - * as the current BAO functions are contact-centric (from what I can find) + * This is the test for creating soft credits. */ - public function testCreateContributionWithSoftCredt() { + public function testCreateContributionWithSoftCredit() { $description = "Demonstrates creating contribution with SoftCredit"; $subfile = "ContributionCreateWithSoftCredit"; $contact2 = $this->callAPISuccess('Contact', 'create', array( 'display_name' => 'superman', 'contact_type' => 'Individual', )); - $softparams = array( + $softParams = array( 'contact_id' => $contact2['id'], 'amount' => 50, 'soft_credit_type_id' => 3, ); - $params = $this->_params + array('soft_credit' => array(1 => $softparams)); + $params = $this->_params + array('soft_credit' => array(1 => $softParams)); $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile); $result = $this->callAPISuccess('contribution', 'get', array('return' => 'soft_credit', 'sequential' => 1)); - $this->assertEquals($softparams['contact_id'], $result['values'][0]['soft_credit'][1]['contact_id']); - $this->assertEquals($softparams['amount'], $result['values'][0]['soft_credit'][1]['amount']); - $this->assertEquals($softparams['soft_credit_type_id'], $result['values'][0]['soft_credit'][1]['soft_credit_type']); + $this->assertEquals($softParams['contact_id'], $result['values'][0]['soft_credit'][1]['contact_id']); + $this->assertEquals($softParams['amount'], $result['values'][0]['soft_credit'][1]['amount']); + $this->assertEquals($softParams['soft_credit_type_id'], $result['values'][0]['soft_credit'][1]['soft_credit_type']); $this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id'])); $this->callAPISuccess('contact', 'delete', array('id' => $contact2['id'])); @@ -1168,7 +1178,7 @@ public function testCreateUpdateContribution() { ); $result = $this->callAPISuccess('contribution', 'delete', $params); - $this->assertAPISuccess($result, 'in line' . __LINE__); + $this->assertAPISuccess($result); } ///////////////// civicrm_contribution_delete methods @@ -1587,7 +1597,7 @@ public function contributionGetnCheck($params, $id, $delete = 1) { $params['contribution_source'] = $params['source']; unset($params['source']); foreach ($params as $key => $value) { - $this->assertEquals($value, $values[$key], $key . " value: $value doesn't match " . print_r($values, TRUE) . 'in line' . __LINE__); + $this->assertEquals($value, $values[$key], $key . " value: $value doesn't match " . print_r($values, TRUE)); } } diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 30213f51bf6c..d956242fa920 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -66,8 +66,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { ); /* they are two types of missing APIs: - - Those that are to be implemented - (in some future version when someone steps in -hint hint-). List the entities in toBeImplemented[ {$action} ] + - Those that are to be implemented + (in some future version when someone steps in -hint hint-). List the entities in toBeImplemented[ {$action} ] Those that don't exist and that will never exist (eg an obsoleted Entity they need to be returned by the function toBeSkipped_{$action} (because it has to be a static method and therefore couldn't access a this->toBeSkipped) @@ -83,7 +83,7 @@ public function setUp() { 'Extension', 'ReportTemplate', 'System', - 'Setting' + 'Setting', ); $this->toBeImplemented['create'] = array( 'SurveyRespondant', @@ -94,7 +94,7 @@ public function setUp() { 'CustomSearch', 'Extension', 'ReportTemplate', - 'System' + 'System', ); $this->toBeImplemented['delete'] = array( 'MembershipPayment', @@ -104,7 +104,7 @@ public function setUp() { 'UFMatch', 'Extension', 'LocationType', - 'System' + 'System', ); $this->onlyIDNonZeroCount['get'] = array('ActivityType', 'Entity', 'Domain', 'Setting'); $this->deprecatedAPI = array('Location', 'ActivityType', 'SurveyRespondant'); @@ -120,11 +120,14 @@ public function tearDown() { } /** - * @param null $skip + * Generate list of all entities. + * + * @param array $skip + * Entities to skip. * * @return array */ - public static function entities($skip = NULL) { + public static function entities($skip = array()) { // The order of operations in here is screwy. In the case where SYNTAX_CONFORMANCE_ENTITIES is // defined, we should be able to parse+return it immediately. However, some weird dependency // crept into the system where civicrm_api('Entity','get') must be called as part of entities() @@ -149,6 +152,8 @@ public static function entities($skip = NULL) { } /** + * Get list of entities for get test. + * * @return array */ public static function entities_get() { diff --git a/tests/templates/documentFunction.tpl b/tests/templates/documentFunction.tpl index 217bb6ff279d..2cb738bf5cae 100644 --- a/tests/templates/documentFunction.tpl +++ b/tests/templates/documentFunction.tpl @@ -1,41 +1,59 @@ {literal}getMessage(); - $errorCode = $e->getErrorCode(); - $errorData = $e->getExtraParams(); - return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); -}{/literal} + try{{/literal} + $result = civicrm_api3('{$fnPrefix}', '{$action}', $params); +{literal} } + catch (CiviCRM_API3_Exception $e) { + // Handle error here. + $errorMessage = $e->getMessage(); + $errorCode = $e->getErrorCode(); + $errorData = $e->getExtraParams(); + return array( + 'error' => $errorMessage, + 'error_code' => $errorCode, + 'error_data' => $errorData, + ); + }{/literal} -return $result; + return $result; {literal}}{/literal} /** - * Function returns array of result expected from previous function + * Function returns array of result expected from previous function. + * + * @return array + * API result array */ -function {$function}_expectedresult(){literal}{{/literal} +function {$function}_expectedresult() {literal}{{/literal} $expectedResult = {$result|@print_array}; return $expectedResult; {literal}}{/literal} - -/* -* This example has been generated from the API test suite. The test that created it is called -* -* {$testfunction} and can be found in +/** +* This example has been generated from the API test suite. +* The test that created it is called +* {$testfunction} +* and can be found in * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/{$filename} * * You can see the outcome of the API tests at