From 5bc392e6ce2d040b662ca9abf8a88abf2b0fada4 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 24 May 2014 13:05:05 +1200 Subject: [PATCH] CRM/Utils add comments --- CRM/Utils/API/AbstractFieldCoder.php | 9 ++ CRM/Utils/API/HTMLInputCoder.php | 4 + CRM/Utils/API/MatchOption.php | 4 + CRM/Utils/API/NullOutputCoder.php | 17 +++ CRM/Utils/API/ReloadOption.php | 4 + CRM/Utils/Address.php | 5 + CRM/Utils/Address/BatchUpdate.php | 17 +++ CRM/Utils/Address/USPS.php | 5 + CRM/Utils/Api.php | 3 + CRM/Utils/Array.php | 7 ++ CRM/Utils/Cache/APCcache.php | 16 +++ CRM/Utils/Cache/ArrayCache.php | 16 +++ CRM/Utils/Cache/Memcache.php | 19 +++ CRM/Utils/Cache/Memcached.php | 22 ++++ CRM/Utils/Cache/NoCache.php | 19 +++ CRM/Utils/Cache/SerializeCache.php | 23 ++++ CRM/Utils/Cache/SqlGroup.php | 18 +++ CRM/Utils/Check/Env.php | 8 +- CRM/Utils/Check/Message.php | 5 + CRM/Utils/Check/Security.php | 5 + CRM/Utils/Constant.php | 5 +- CRM/Utils/Date.php | 27 +++++ CRM/Utils/DeprecatedUtils.php | 9 ++ CRM/Utils/FakeObject.php | 11 +- CRM/Utils/File.php | 37 ++++++ CRM/Utils/GlobalStack.php | 6 + CRM/Utils/Hook.php | 35 ++++++ CRM/Utils/Hook/Joomla.php | 26 +++++ CRM/Utils/Hook/Soap.php | 26 +++++ CRM/Utils/Hook/UnitTests.php | 26 +++++ CRM/Utils/Hook/WordPress.php | 26 +++++ CRM/Utils/HttpClient.php | 9 ++ CRM/Utils/Mail.php | 24 ++++ CRM/Utils/Mail/EmailProcessor.php | 10 ++ CRM/Utils/Mail/Incoming.php | 99 ++++++++++++++++ CRM/Utils/Migrate/Export.php | 8 ++ CRM/Utils/Migrate/ExportJSON.php | 88 ++++++++++++++ CRM/Utils/Migrate/Import.php | 51 ++++++++ CRM/Utils/Migrate/ImportJSON.php | 45 +++++++ CRM/Utils/Number.php | 4 + CRM/Utils/OpenFlashChart.php | 21 ++++ CRM/Utils/OptionBag.php | 13 ++- CRM/Utils/PDF/Label.php | 24 ++++ CRM/Utils/PDF/Utils.php | 44 +++++++ CRM/Utils/Pager.php | 19 +++ CRM/Utils/REST.php | 41 +++++++ CRM/Utils/ReCAPTCHA.php | 9 ++ CRM/Utils/Rule.php | 168 +++++++++++++++++++++++++++ CRM/Utils/Signer.php | 3 + CRM/Utils/SoapServer.php | 75 ++++++++++++ CRM/Utils/String.php | 15 +++ CRM/Utils/Sunlight.php | 39 +++++++ CRM/Utils/System.php | 28 ++++- CRM/Utils/System/Drupal6.php | 3 + CRM/Utils/SystemLogger.php | 15 +++ CRM/Utils/Token.php | 16 ++- CRM/Utils/Weight.php | 14 +++ CRM/Utils/XML.php | 5 + 58 files changed, 1344 insertions(+), 6 deletions(-) diff --git a/CRM/Utils/API/AbstractFieldCoder.php b/CRM/Utils/API/AbstractFieldCoder.php index fa679d3d38..8846c6bd85 100644 --- a/CRM/Utils/API/AbstractFieldCoder.php +++ b/CRM/Utils/API/AbstractFieldCoder.php @@ -36,6 +36,10 @@ */ require_once 'api/Wrapper.php'; + +/** + * Class CRM_Utils_API_AbstractFieldCoder + */ abstract class CRM_Utils_API_AbstractFieldCoder implements API_Wrapper { /** @@ -81,6 +85,11 @@ abstract class CRM_Utils_API_AbstractFieldCoder implements API_Wrapper { */ public abstract function encodeInput(&$values); + /** + * @param $values + * + * @return mixed + */ public abstract function decodeOutput(&$values); /** diff --git a/CRM/Utils/API/HTMLInputCoder.php b/CRM/Utils/API/HTMLInputCoder.php index c07f81f6df..86bd44b4b3 100644 --- a/CRM/Utils/API/HTMLInputCoder.php +++ b/CRM/Utils/API/HTMLInputCoder.php @@ -130,6 +130,10 @@ class CRM_Utils_API_HTMLInputCoder extends CRM_Utils_API_AbstractFieldCoder { } } + /** + * @param $values + * @param bool $castToString + */ public function decodeOutput(&$values, $castToString = FALSE) { if (is_array($values)) { foreach ($values as &$value) { diff --git a/CRM/Utils/API/MatchOption.php b/CRM/Utils/API/MatchOption.php index 4dde9ba5e4..a8068c8771 100644 --- a/CRM/Utils/API/MatchOption.php +++ b/CRM/Utils/API/MatchOption.php @@ -54,6 +54,10 @@ */ require_once 'api/Wrapper.php'; + +/** + * Class CRM_Utils_API_MatchOption + */ class CRM_Utils_API_MatchOption implements API_Wrapper { /** diff --git a/CRM/Utils/API/NullOutputCoder.php b/CRM/Utils/API/NullOutputCoder.php index 03d1131ce2..d67ad222b7 100644 --- a/CRM/Utils/API/NullOutputCoder.php +++ b/CRM/Utils/API/NullOutputCoder.php @@ -35,6 +35,10 @@ */ require_once 'api/Wrapper.php'; + +/** + * Class CRM_Utils_API_NullOutputCoder + */ class CRM_Utils_API_NullOutputCoder extends CRM_Utils_API_AbstractFieldCoder { /** @@ -64,6 +68,10 @@ class CRM_Utils_API_NullOutputCoder extends CRM_Utils_API_AbstractFieldCoder { public function encodeInput(&$values) { } + /** + * @param $values + * @param bool $castToString + */ public function decodeOutput(&$values, $castToString = FALSE) { if (is_array($values)) { foreach ($values as &$value) { @@ -77,6 +85,15 @@ class CRM_Utils_API_NullOutputCoder extends CRM_Utils_API_AbstractFieldCoder { } } + /** + * {@inheritDoc} + */ + /** + * @param $apiRequest + * @param $result + * + * @return modified + */ public function toApiOutput($apiRequest, $result) { $lowerAction = strtolower($apiRequest['action']); if ($lowerAction === 'create') { diff --git a/CRM/Utils/API/ReloadOption.php b/CRM/Utils/API/ReloadOption.php index 6a2f977226..c1fa5583ae 100644 --- a/CRM/Utils/API/ReloadOption.php +++ b/CRM/Utils/API/ReloadOption.php @@ -43,6 +43,10 @@ */ require_once 'api/Wrapper.php'; + +/** + * Class CRM_Utils_API_ReloadOption + */ class CRM_Utils_API_ReloadOption implements API_Wrapper { /** diff --git a/CRM/Utils/Address.php b/CRM/Utils/Address.php index 53255eb364..66587ccda0 100644 --- a/CRM/Utils/Address.php +++ b/CRM/Utils/Address.php @@ -269,6 +269,11 @@ class CRM_Utils_Address { return $finalFormatted; } + /** + * @param $format + * + * @return array + */ static function sequence($format) { // also compute and store the address sequence $addressSequence = array( diff --git a/CRM/Utils/Address/BatchUpdate.php b/CRM/Utils/Address/BatchUpdate.php index 49a8903c18..adde5a61bb 100644 --- a/CRM/Utils/Address/BatchUpdate.php +++ b/CRM/Utils/Address/BatchUpdate.php @@ -43,6 +43,9 @@ class CRM_Utils_Address_BatchUpdate { var $returnMessages = array(); var $returnError = 0; + /** + * @param $params + */ public function __construct($params) { foreach ($params as $name => $value) { @@ -52,6 +55,9 @@ class CRM_Utils_Address_BatchUpdate { // fixme: more params verification } + /** + * @return array + */ public function run() { $config = &CRM_Core_Config::singleton(); @@ -108,6 +114,14 @@ class CRM_Utils_Address_BatchUpdate { return $this->processContacts($config, $processGeocode, $parseStreetAddress); } + /** + * @param $config + * @param $processGeocode + * @param $parseStreetAddress + * + * @return array + * @throws Exception + */ function processContacts(&$config, $processGeocode, $parseStreetAddress) { // build where clause. $clause = array('( c.id = a.contact_id )'); @@ -262,6 +276,9 @@ class CRM_Utils_Address_BatchUpdate { return $this->returnResult(); } + /** + * @return array + */ function returnResult() { $result = array(); $result['is_error'] = $this->returnError; diff --git a/CRM/Utils/Address/USPS.php b/CRM/Utils/Address/USPS.php index f954c41b82..5e85a0d576 100644 --- a/CRM/Utils/Address/USPS.php +++ b/CRM/Utils/Address/USPS.php @@ -38,6 +38,11 @@ */ class CRM_Utils_Address_USPS { + /** + * @param $values + * + * @return bool + */ static function checkAddress(&$values) { if (!isset($values['street_address']) || (!isset($values['city']) && diff --git a/CRM/Utils/Api.php b/CRM/Utils/Api.php index 97143abdd0..3c1b145684 100644 --- a/CRM/Utils/Api.php +++ b/CRM/Utils/Api.php @@ -25,6 +25,9 @@ +--------------------------------------------------------------------+ */ +/** + * Class CRM_Utils_Api + */ class CRM_Utils_Api { /** * Attempts to retrieve the API entity name from any calling class. diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index b90d217050..af0900da1e 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -878,6 +878,13 @@ class CRM_Utils_Array { * @return mixed * The value found. */ + /** + * @param $regexKey + * @param $list + * @param null $default + * + * @return null + */ static function valueByRegexKey($regexKey, $list, $default = NULL) { if (is_array($list) && $regexKey) { $matches = preg_grep($regexKey, array_keys($list)); diff --git a/CRM/Utils/Cache/APCcache.php b/CRM/Utils/Cache/APCcache.php index 042c4600d4..9ac77b3b48 100644 --- a/CRM/Utils/Cache/APCcache.php +++ b/CRM/Utils/Cache/APCcache.php @@ -70,6 +70,12 @@ class CRM_Utils_Cache_APCcache { } } + /** + * @param $key + * @param $value + * + * @return bool + */ function set($key, &$value) { if (!apc_store($this->_prefix . $key, $value, $this->_timeout)) { return FALSE; @@ -77,10 +83,20 @@ class CRM_Utils_Cache_APCcache { return TRUE; } + /** + * @param $key + * + * @return mixed + */ function &get($key) { return apc_fetch($this->_prefix . $key); } + /** + * @param $key + * + * @return bool|string[] + */ function delete($key) { return apc_delete($this->_prefix . $key); } diff --git a/CRM/Utils/Cache/ArrayCache.php b/CRM/Utils/Cache/ArrayCache.php index a7745a82fe..a0df84b33b 100644 --- a/CRM/Utils/Cache/ArrayCache.php +++ b/CRM/Utils/Cache/ArrayCache.php @@ -1,4 +1,8 @@ _cache = array(); } + /** + * @param string $key + * @param mixed $value + */ function set($key, &$value) { $this->_cache[$key] = $value; } + /** + * @param string $key + * + * @return mixed + */ function get($key) { return CRM_Utils_Array::value($key, $this->_cache); } + /** + * @param string $key + */ function delete($key) { unset($this->_cache[$key]); } diff --git a/CRM/Utils/Cache/Memcache.php b/CRM/Utils/Cache/Memcache.php index c84f5cc34d..142ea03593 100644 --- a/CRM/Utils/Cache/Memcache.php +++ b/CRM/Utils/Cache/Memcache.php @@ -107,6 +107,12 @@ class CRM_Utils_Cache_Memcache { } } + /** + * @param $key + * @param $value + * + * @return bool + */ function set($key, &$value) { if (!$this->_cache->set($this->_prefix . $key, $value, FALSE, $this->_timeout)) { return FALSE; @@ -114,15 +120,28 @@ class CRM_Utils_Cache_Memcache { return TRUE; } + /** + * @param $key + * + * @return mixed + */ function &get($key) { $result = $this->_cache->get($this->_prefix . $key); return $result; } + /** + * @param $key + * + * @return mixed + */ function delete($key) { return $this->_cache->delete($this->_prefix . $key); } + /** + * @return mixed + */ function flush() { return $this->_cache->flush(); } diff --git a/CRM/Utils/Cache/Memcached.php b/CRM/Utils/Cache/Memcached.php index 9fcaff8261..1ddcf416a7 100644 --- a/CRM/Utils/Cache/Memcached.php +++ b/CRM/Utils/Cache/Memcached.php @@ -108,6 +108,13 @@ class CRM_Utils_Cache_Memcached { } } + /** + * @param $key + * @param $value + * + * @return bool + * @throws Exception + */ function set($key, &$value) { $key = $this->cleanKey($key); if (!$this->_cache->set($key, $value, $this->_timeout)) { @@ -118,17 +125,32 @@ class CRM_Utils_Cache_Memcached { return TRUE; } + /** + * @param $key + * + * @return mixed + */ function &get($key) { $key = $this->cleanKey($key); $result = $this->_cache->get($key); return $result; } + /** + * @param $key + * + * @return mixed + */ function delete($key) { $key = $this->cleanKey($key); return $this->_cache->delete($key); } + /** + * @param $key + * + * @return mixed|string + */ function cleanKey($key) { $key = preg_replace('/\s+|\W+/', '_', $this->_prefix . $key); if ( strlen($key) > self::MAX_KEY_LEN ) { diff --git a/CRM/Utils/Cache/NoCache.php b/CRM/Utils/Cache/NoCache.php index cf700d7380..44a00fc63c 100644 --- a/CRM/Utils/Cache/NoCache.php +++ b/CRM/Utils/Cache/NoCache.php @@ -54,18 +54,37 @@ class CRM_Utils_Cache_NoCache implements CRM_Utils_Cache_Interface { function __construct($config) { } + /** + * @param string $key + * @param mixed $value + * + * @return bool + */ function set($key, &$value) { return FALSE; } + /** + * @param string $key + * + * @return null + */ function get($key) { return NULL; } + /** + * @param string $key + * + * @return bool + */ function delete($key) { return FALSE; } + /** + * @return bool + */ function flush() { return FALSE; } diff --git a/CRM/Utils/Cache/SerializeCache.php b/CRM/Utils/Cache/SerializeCache.php index 9d87b23bab..47b94de822 100644 --- a/CRM/Utils/Cache/SerializeCache.php +++ b/CRM/Utils/Cache/SerializeCache.php @@ -25,6 +25,9 @@ +--------------------------------------------------------------------+ */ +/** + * Class CRM_Utils_Cache_SerializeCache + */ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { /** @@ -43,12 +46,22 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { $this->_cache = array(); } + /** + * @param $key + * + * @return string + */ function fileName ($key) { if (strlen($key) > 50) return CIVICRM_TEMPLATE_COMPILEDIR ."CRM_".md5($key).".php"; return CIVICRM_TEMPLATE_COMPILEDIR .$key.".php"; } + /** + * @param string $key + * + * @return mixed + */ function get ($key) { if (array_key_exists($key,$this->_cache)) return $this->_cache[$key]; @@ -60,6 +73,10 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { return $this->_cache[$key]; } + /** + * @param string $key + * @param mixed $value + */ function set($key, &$value) { if (file_exists($this->fileName ($key))) { return; @@ -68,6 +85,9 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { file_put_contents ($this->fileName ($key),"fileName ($key))) { unlink ($this->fileName ($key)); @@ -75,6 +95,9 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { unset($this->_cache[$key]); } + /** + * @param null $key + */ function flush($key =null) { $prefix = "CRM_"; if (!$handle = opendir(CIVICRM_TEMPLATE_COMPILEDIR)) { diff --git a/CRM/Utils/Cache/SqlGroup.php b/CRM/Utils/Cache/SqlGroup.php index d128bdc8b4..27194acb5c 100644 --- a/CRM/Utils/Cache/SqlGroup.php +++ b/CRM/Utils/Cache/SqlGroup.php @@ -85,11 +85,20 @@ class CRM_Utils_Cache_SqlGroup implements CRM_Utils_Cache_Interface { } } + /** + * @param string $key + * @param mixed $value + */ function set($key, &$value) { CRM_Core_BAO_Cache::setItem($value, $this->group, $key, $this->componentID); $this->frontCache[$key] = $value; } + /** + * @param string $key + * + * @return mixed + */ function get($key) { if (! array_key_exists($key, $this->frontCache)) { $this->frontCache[$key] = CRM_Core_BAO_Cache::getItem($this->group, $key, $this->componentID); @@ -97,10 +106,19 @@ class CRM_Utils_Cache_SqlGroup implements CRM_Utils_Cache_Interface { return $this->frontCache[$key]; } + /** + * @param $key + * @param null $default + * + * @return mixed + */ function getFromFrontCache($key, $default = NULL) { return CRM_Utils_Array::value($key, $this->frontCache, $default); } + /** + * @param string $key + */ function delete($key) { CRM_Core_BAO_Cache::deleteGroup($this->group, $key); unset($this->frontCache[$key]); diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index 8212acfae6..3f3cc3abc0 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -73,6 +73,9 @@ class CRM_Utils_Check_Env { return $messages; } + /** + * @return array + */ public function checkDebug() { $messages = array(); @@ -89,6 +92,9 @@ class CRM_Utils_Check_Env { return $messages; } + /** + * @return array + */ public function checkOutboundMail() { $messages = array(); @@ -109,4 +115,4 @@ class CRM_Utils_Check_Env { return $messages; } -} \ No newline at end of file +} diff --git a/CRM/Utils/Check/Message.php b/CRM/Utils/Check/Message.php index 0b9b7b5f9d..1dfb818ce7 100644 --- a/CRM/Utils/Check/Message.php +++ b/CRM/Utils/Check/Message.php @@ -48,6 +48,11 @@ class CRM_Utils_Check_Message { */ private $title; + /** + * @param $name + * @param $message + * @param $title + */ function __construct($name, $message, $title) { $this->name = $name; $this->message = $message; diff --git a/CRM/Utils/Check/Security.php b/CRM/Utils/Check/Security.php index 38700570ff..da5d6f44e8 100644 --- a/CRM/Utils/Check/Security.php +++ b/CRM/Utils/Check/Security.php @@ -267,6 +267,11 @@ class CRM_Utils_Check_Security { return $result; } + /** + * @param $topic + * + * @return string + */ public function createDocUrl($topic) { return CRM_Utils_System::getWikiBaseURL() . $topic; } diff --git a/CRM/Utils/Constant.php b/CRM/Utils/Constant.php index 93bc65d9df..ce9310ddd5 100644 --- a/CRM/Utils/Constant.php +++ b/CRM/Utils/Constant.php @@ -25,11 +25,14 @@ +--------------------------------------------------------------------+ */ +/** + * Class CRM_Utils_Constant + */ class CRM_Utils_Constant { /** * Determine the value of a constant, if any. - * + * * If the specified constant is undefined, return a default value. * * @param string $name diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index 3c377a6cfc..bec7a808d6 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -250,6 +250,11 @@ class CRM_Utils_Date { return $fullMonthNames; } + /** + * @param $string + * + * @return int + */ static function unixTime($string) { if (empty($string)) { return 0; @@ -656,6 +661,11 @@ class CRM_Utils_Date { return FALSE; } + /** + * @param $date + * + * @return bool + */ static function isDate(&$date) { if (CRM_Utils_System::isNull($date)) { return FALSE; @@ -663,10 +673,21 @@ class CRM_Utils_Date { return TRUE; } + /** + * @param null $timeStamp + * + * @return bool|string + */ static function currentDBDate($timeStamp = NULL) { return $timeStamp ? date('YmdHis', $timeStamp) : date('YmdHis'); } + /** + * @param $date + * @param null $now + * + * @return bool + */ static function overdue($date, $now = NULL) { $mysqlDate = self::isoToMysql($date); if (!$now) { @@ -1580,6 +1601,12 @@ class CRM_Utils_Date { } + /** + * @param $date + * @param $dateType + * + * @return null|string + */ static function formatDate($date, $dateType) { $formattedDate = NULL; if (empty($date)) { diff --git a/CRM/Utils/DeprecatedUtils.php b/CRM/Utils/DeprecatedUtils.php index 593de9552d..591cac52a7 100644 --- a/CRM/Utils/DeprecatedUtils.php +++ b/CRM/Utils/DeprecatedUtils.php @@ -1325,6 +1325,15 @@ function _civicrm_api3_deprecated_contact_check_custom_params($params, $csType = } } +/** + * @param $params + * @param bool $dupeCheck + * @param bool $dupeErrorArray + * @param bool $requiredCheck + * @param null $dedupeRuleGroupID + * + * @return array|null + */ function _civicrm_api3_deprecated_contact_check_params( &$params, $dupeCheck = TRUE, diff --git a/CRM/Utils/FakeObject.php b/CRM/Utils/FakeObject.php index 68e36bf019..0f87c043f8 100644 --- a/CRM/Utils/FakeObject.php +++ b/CRM/Utils/FakeObject.php @@ -12,10 +12,19 @@ * @endcode */ class CRM_Utils_FakeObject { + /** + * @param $array + */ function __construct($array) { $this->array = $array; } + /** + * @param $name + * @param $arguments + * + * @throws Exception + */ function __call($name, $arguments) { if (isset($this->array[$name]) && is_callable($this->array[$name])) { return call_user_func_array($this->array[$name], $arguments); @@ -23,4 +32,4 @@ class CRM_Utils_FakeObject { throw new Exception("Call to unimplemented method: $name"); } } -} \ No newline at end of file +} diff --git a/CRM/Utils/File.php b/CRM/Utils/File.php index af01467185..724f269bc1 100644 --- a/CRM/Utils/File.php +++ b/CRM/Utils/File.php @@ -177,6 +177,10 @@ class CRM_Utils_File { } } + /** + * @param $source + * @param $destination + */ static function copyDir($source, $destination) { $dir = opendir($source); @mkdir($destination); @@ -260,6 +264,13 @@ class CRM_Utils_File { return $name; } + /** + * @param $dsn + * @param $fileName + * @param null $prefix + * @param bool $isQueryString + * @param bool $dieOnErrors + */ static function sourceSQLFile($dsn, $fileName, $prefix = NULL, $isQueryString = FALSE, $dieOnErrors = TRUE) { require_once 'DB.php'; @@ -302,6 +313,11 @@ class CRM_Utils_File { } } + /** + * @param $ext + * + * @return bool + */ static function isExtensionSafe($ext) { static $extensions = NULL; if (!$extensions) { @@ -353,6 +369,11 @@ class CRM_Utils_File { return $name; } + /** + * @param $name + * + * @return string + */ static function makeFileName($name) { $uniqID = md5(uniqid(rand(), TRUE)); $info = pathinfo($name); @@ -370,6 +391,12 @@ class CRM_Utils_File { } } + /** + * @param $path + * @param $ext + * + * @return array + */ static function getFilesByExtension($path, $ext) { $path = self::addTrailingSlash($path); $dh = opendir($path); @@ -466,6 +493,11 @@ HTACCESS; return $_path; } + /** + * @param $directory + * + * @return string + */ static function relativeDirectory($directory) { // Do nothing on windows if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { @@ -489,6 +521,11 @@ HTACCESS; return $directory; } + /** + * @param $directory + * + * @return string + */ static function absoluteDirectory($directory) { // Do nothing on windows - config will need to specify absolute path if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { diff --git a/CRM/Utils/GlobalStack.php b/CRM/Utils/GlobalStack.php index 717c69baac..2e7c133a92 100644 --- a/CRM/Utils/GlobalStack.php +++ b/CRM/Utils/GlobalStack.php @@ -64,6 +64,9 @@ class CRM_Utils_GlobalStack { return self::$_singleton; } + /** + * @param $newFrame + */ public function push($newFrame) { $this->backups[] = $this->createBackup($newFrame); $this->applyFrame($newFrame); @@ -91,6 +94,9 @@ class CRM_Utils_GlobalStack { return $frame; } + /** + * @param $newFrame + */ public function applyFrame($newFrame) { foreach ($newFrame as $globalKey => $values) { if (is_array($values)) { diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index dfe84fa6d0..6405dbcf08 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -108,6 +108,19 @@ abstract class CRM_Utils_Hook { $fnSuffix ); + /** + * @param $numParams + * @param $arg1 + * @param $arg2 + * @param $arg3 + * @param $arg4 + * @param $arg5 + * @param $arg6 + * @param $fnSuffix + * @param $fnPrefix + * + * @return array|bool + */ function commonInvoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix, $fnPrefix @@ -216,6 +229,9 @@ abstract class CRM_Utils_Hook { return empty($result) ? TRUE : $result; } + /** + * @param $moduleList + */ function requireCiviModules(&$moduleList) { $civiModules = CRM_Core_PseudoConstant::getModuleExtensions(); foreach ($civiModules as $civiModule) { @@ -884,6 +900,13 @@ abstract class CRM_Utils_Hook { ); } + /** + * @param $recordBAO + * @param $recordID + * @param $isActive + * + * @return mixed + */ static function enableDisable($recordBAO, $recordID, $isActive) { return self::singleton()->invoke(3, $recordBAO, $recordID, $isActive, self::$_nullObject, self::$_nullObject, self::$_nullObject, @@ -1047,6 +1070,11 @@ abstract class CRM_Utils_Hook { ); } + /** + * @param $dao + * + * @return mixed + */ static function postSave(&$dao) { $hookName = 'civicrm_postSave_' . $dao->getTableName(); return self::singleton()->invoke(1, $dao, @@ -1290,6 +1318,13 @@ abstract class CRM_Utils_Hook { ); } + /** + * @param $varType + * @param $var + * @param $object + * + * @return mixed + */ static function alterReportVar($varType, &$var, &$object) { return self::singleton()->invoke(3, $varType, $var, $object, self::$_nullObject, diff --git a/CRM/Utils/Hook/Joomla.php b/CRM/Utils/Hook/Joomla.php index f63d9d2b2a..85d40ebab5 100644 --- a/CRM/Utils/Hook/Joomla.php +++ b/CRM/Utils/Hook/Joomla.php @@ -34,6 +34,32 @@ * */ class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook { + /** + *Invoke hooks + * + * @param int $numParams Number of parameters to pass to the hook + * @param mixed $arg1 parameter to be passed to the hook + * @param mixed $arg2 parameter to be passed to the hook + * @param mixed $arg3 parameter to be passed to the hook + * @param mixed $arg4 parameter to be passed to the hook + * @param mixed $arg5 parameter to be passed to the hook + * @param mixed $arg6 parameter to be passed to the hook + * @param string $fnSuffix function suffix, this is effectively the hook name + * + * @return mixed + */ + /** + * @param int $numParams + * @param mixed $arg1 + * @param mixed $arg2 + * @param mixed $arg3 + * @param mixed $arg4 + * @param mixed $arg5 + * @param mixed $arg6 + * @param string $fnSuffix + * + * @return mixed + */ function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix diff --git a/CRM/Utils/Hook/Soap.php b/CRM/Utils/Hook/Soap.php index c247d2294a..06ec177dde 100644 --- a/CRM/Utils/Hook/Soap.php +++ b/CRM/Utils/Hook/Soap.php @@ -34,6 +34,32 @@ * */ class CRM_Utils_Hook_Soap extends CRM_Utils_Hook { + /** + *Invoke hooks + * + * @param int $numParams Number of parameters to pass to the hook + * @param mixed $arg1 parameter to be passed to the hook + * @param mixed $arg2 parameter to be passed to the hook + * @param mixed $arg3 parameter to be passed to the hook + * @param mixed $arg4 parameter to be passed to the hook + * @param mixed $arg5 parameter to be passed to the hook + * @param mixed $arg6 parameter to be passed to the hook + * @param string $fnSuffix function suffix, this is effectively the hook name + * + * @return mixed + */ + /** + * @param int $numParams + * @param mixed $arg1 + * @param mixed $arg2 + * @param mixed $arg3 + * @param mixed $arg4 + * @param mixed $arg5 + * @param mixed $arg6 + * @param string $fnSuffix + * + * @return mixed + */ function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix diff --git a/CRM/Utils/Hook/UnitTests.php b/CRM/Utils/Hook/UnitTests.php index cc65f4498f..d0397ce37f 100644 --- a/CRM/Utils/Hook/UnitTests.php +++ b/CRM/Utils/Hook/UnitTests.php @@ -60,6 +60,32 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook { $this->adhocHooks[$hook] = $callable; } + /** + *Invoke hooks + * + * @param int $numParams Number of parameters to pass to the hook + * @param mixed $arg1 parameter to be passed to the hook + * @param mixed $arg2 parameter to be passed to the hook + * @param mixed $arg3 parameter to be passed to the hook + * @param mixed $arg4 parameter to be passed to the hook + * @param mixed $arg5 parameter to be passed to the hook + * @param mixed $arg6 parameter to be passed to the hook + * @param string $fnSuffix function suffix, this is effectively the hook name + * + * @return mixed + */ + /** + * @param int $numParams + * @param mixed $arg1 + * @param mixed $arg2 + * @param mixed $arg3 + * @param mixed $arg4 + * @param mixed $arg5 + * @param mixed $arg6 + * @param string $fnSuffix + * + * @return mixed + */ function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix) { diff --git a/CRM/Utils/Hook/WordPress.php b/CRM/Utils/Hook/WordPress.php index 600d577885..8a23888193 100644 --- a/CRM/Utils/Hook/WordPress.php +++ b/CRM/Utils/Hook/WordPress.php @@ -33,6 +33,32 @@ * */ class CRM_Utils_Hook_WordPress extends CRM_Utils_Hook { + /** + *Invoke hooks + * + * @param int $numParams Number of parameters to pass to the hook + * @param mixed $arg1 parameter to be passed to the hook + * @param mixed $arg2 parameter to be passed to the hook + * @param mixed $arg3 parameter to be passed to the hook + * @param mixed $arg4 parameter to be passed to the hook + * @param mixed $arg5 parameter to be passed to the hook + * @param mixed $arg6 parameter to be passed to the hook + * @param string $fnSuffix function suffix, this is effectively the hook name + * + * @return mixed + */ + /** + * @param int $numParams + * @param mixed $arg1 + * @param mixed $arg2 + * @param mixed $arg3 + * @param mixed $arg4 + * @param mixed $arg5 + * @param mixed $arg6 + * @param string $fnSuffix + * + * @return mixed + */ function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix diff --git a/CRM/Utils/HttpClient.php b/CRM/Utils/HttpClient.php index a3252a27c0..3148c53605 100644 --- a/CRM/Utils/HttpClient.php +++ b/CRM/Utils/HttpClient.php @@ -54,6 +54,9 @@ class CRM_Utils_HttpClient { */ protected $connectionTimeout; + /** + * @return CRM_Utils_HttpClient + */ public static function singleton() { if (!self::$singleton) { self::$singleton = new CRM_Utils_HttpClient(); @@ -61,6 +64,9 @@ class CRM_Utils_HttpClient { return self::$singleton; } + /** + * @param null $connectionTimeout + */ public function __construct($connectionTimeout = NULL) { $this->connectionTimeout = $connectionTimeout; } @@ -207,6 +213,9 @@ class CRM_Utils_HttpClient { return array($ch, $caConfig); } + /** + * @return bool + */ public function isRedirectSupported() { return (ini_get('open_basedir') == '') && (ini_get('safe_mode') == 'Off' || ini_get('safe_mode') === FALSE); } diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index 260daea200..82b89406f0 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -192,6 +192,12 @@ class CRM_Utils_Mail { return FALSE; } + /** + * @param $mailer + * @param $result + * + * @return string + */ static function errorMessage($mailer, $result) { $message = '

' . ts('An error occurred when CiviCRM attempted to send an email (via %1). If you received this error after submitting on online contribution or event registration - the transaction was completed, but we were unable to send the email receipt.', array( 1 => 'SMTP')) . '

' . '

' . ts('The mail library returned the following error message:') . '
' . $result->getMessage() . '

' . '

' . ts('This is probably related to a problem in your Outbound Email Settings (Administer CiviCRM » System Settings » Outbound Email), OR the FROM email address specifically configured for your contribution page or event. Possible causes are:') . '

'; @@ -209,6 +215,11 @@ class CRM_Utils_Mail { return $message; } + /** + * @param $to + * @param $headers + * @param $message + */ static function logger(&$to, &$headers, &$message) { if (is_array($to)) { $toString = implode(', ', $to); @@ -292,6 +303,12 @@ class CRM_Utils_Mail { return FALSE; } + /** + * @param $message + * @param null $params + * + * @return mixed + */ static function &setMimeParams(&$message, $params = NULL) { static $mimeParams = NULL; if (!$params) { @@ -309,6 +326,13 @@ class CRM_Utils_Mail { return $message->get($params); } + /** + * @param $name + * @param $email + * @param bool $useQuote + * + * @return null|string + */ static function formatRFC822Email($name, $email, $useQuote = FALSE) { $result = NULL; diff --git a/CRM/Utils/Mail/EmailProcessor.php b/CRM/Utils/Mail/EmailProcessor.php index 5d68dd3932..1c5eb1b659 100644 --- a/CRM/Utils/Mail/EmailProcessor.php +++ b/CRM/Utils/Mail/EmailProcessor.php @@ -37,6 +37,10 @@ // before the 4.1 release define('EMAIL_ACTIVITY_TYPE_ID', NULL); define('MAIL_BATCH_SIZE', 50); + +/** + * Class CRM_Utils_Mail_EmailProcessor + */ class CRM_Utils_Mail_EmailProcessor { /** @@ -126,6 +130,12 @@ class CRM_Utils_Mail_EmailProcessor { } } + /** + * @param $civiMail + * @param $dao + * + * @throws Exception + */ static function _process($civiMail, $dao) { // 0 = activities; 1 = bounce; $usedfor = $dao->is_default; diff --git a/CRM/Utils/Mail/Incoming.php b/CRM/Utils/Mail/Incoming.php index 5c2b8d8d9a..ed58956bc9 100644 --- a/CRM/Utils/Mail/Incoming.php +++ b/CRM/Utils/Mail/Incoming.php @@ -38,6 +38,12 @@ class CRM_Utils_Mail_Incoming { EMAILPROCESSOR_OVERRIDE = 2, EMAILPROCESSOR_IGNORE = 3; + /** + * @param $mail + * @param $attachments + * + * @return string + */ function formatMail($mail, &$attachments) { $t = ''; $t .= "From: " . self::formatAddress($mail->from) . "\n"; @@ -52,6 +58,12 @@ class CRM_Utils_Mail_Incoming { return $t; } + /** + * @param $part + * @param $attachments + * + * @throws Exception + */ function formatMailPart($part, &$attachments) { if ($part instanceof ezcMail) { return self::formatMail($part, $attachments); @@ -76,6 +88,12 @@ class CRM_Utils_Mail_Incoming { CRM_Core_Error::fatal(ts("No clue about the %1", array(1 => get_class($part)))); } + /** + * @param $part + * @param $attachments + * + * @throws Exception + */ function formatMailMultipart($part, &$attachments) { if ($part instanceof ezcMailMultiPartAlternative) { return self::formatMailMultipartAlternative($part, $attachments); @@ -100,6 +118,12 @@ class CRM_Utils_Mail_Incoming { CRM_Core_Error::fatal(ts("No clue about the %1", array(1 => get_class($part)))); } + /** + * @param $part + * @param $attachments + * + * @return string + */ function formatMailMultipartMixed($part, &$attachments) { $t = ''; foreach ($part->getParts() as $key => $alternativePart) { @@ -108,6 +132,12 @@ class CRM_Utils_Mail_Incoming { return $t; } + /** + * @param $part + * @param $attachments + * + * @return string + */ function formatMailMultipartRelated($part, &$attachments) { $t = ''; $t .= "-RELATED MAIN PART-\n"; @@ -120,6 +150,12 @@ class CRM_Utils_Mail_Incoming { return $t; } + /** + * @param $part + * @param $attachments + * + * @return string + */ function formatMailMultipartDigest($part, &$attachments) { $t = ''; foreach ($part->getParts() as $key => $alternativePart) { @@ -130,6 +166,12 @@ class CRM_Utils_Mail_Incoming { return $t; } + /** + * @param $part + * @param $attachments + * + * @return string + */ function formatMailRfc822Digest($part, &$attachments) { $t = ''; $t .= "-DIGEST-ITEM-\n"; @@ -139,6 +181,12 @@ class CRM_Utils_Mail_Incoming { return $t; } + /** + * @param $part + * @param $attachments + * + * @return string + */ function formatMailMultipartAlternative($part, &$attachments) { $t = ''; foreach ($part->getParts() as $key => $alternativePart) { @@ -149,11 +197,23 @@ class CRM_Utils_Mail_Incoming { return $t; } + /** + * @param $part + * @param $attachments + * + * @return string + */ function formatMailText($part, &$attachments) { $t = "\n{$part->text}\n"; return $t; } + /** + * @param $part + * @param $attachments + * + * @return string + */ function formatMailMultipartReport($part, &$attachments) { $t = ''; foreach ($part->getParts() as $key => $reportPart) { @@ -164,6 +224,12 @@ class CRM_Utils_Mail_Incoming { return $t; } + /** + * @param $part + * @param $attachments + * + * @return null + */ function formatMailFile($part, &$attachments) { $attachments[] = array( 'dispositionType' => $part->dispositionType, @@ -175,6 +241,11 @@ class CRM_Utils_Mail_Incoming { return NULL; } + /** + * @param $addresses + * + * @return string + */ function formatAddresses($addresses) { $fa = array(); foreach ($addresses as $address) { @@ -183,6 +254,11 @@ class CRM_Utils_Mail_Incoming { return implode(', ', $fa); } + /** + * @param $address + * + * @return string + */ function formatAddress($address) { $name = ''; if (!empty($address->name)) { @@ -191,6 +267,12 @@ class CRM_Utils_Mail_Incoming { return $name . "<{$address->email}>"; } + /** + * @param $file + * + * @return array + * @throws Exception + */ function &parse(&$file) { // check that the file exists and has some content @@ -223,6 +305,11 @@ class CRM_Utils_Mail_Incoming { return $mailParams; } + /** + * @param $mail + * + * @return array + */ function parseMailingObject(&$mail) { $config = CRM_Core_Config::singleton(); @@ -281,6 +368,12 @@ class CRM_Utils_Mail_Incoming { return $params; } + /** + * @param $address + * @param $params + * @param $subParam + * @param $mail + */ function parseAddress(&$address, &$params, &$subParam, &$mail) { // CRM-9484 if (empty($address->email)) { @@ -299,6 +392,12 @@ class CRM_Utils_Mail_Incoming { $subParam['id'] = $contactID ? $contactID : NULL; } + /** + * @param $addresses + * @param $token + * @param $params + * @param $mail + */ function parseAddresses(&$addresses, $token, &$params, &$mail) { $params[$token] = array(); diff --git a/CRM/Utils/Migrate/Export.php b/CRM/Utils/Migrate/Export.php index f37714c16e..1a611f9602 100644 --- a/CRM/Utils/Migrate/Export.php +++ b/CRM/Utils/Migrate/Export.php @@ -52,6 +52,9 @@ class CRM_Utils_Migrate_Export { */ protected $_xml; + /** + * + */ function __construct() { $this->_xml = array( 'customGroup' => array( @@ -392,6 +395,11 @@ class CRM_Utils_Migrate_Export { return $result; } + /** + * @param $groupName + * @param $daoName + * @param null $sql + */ function fetch($groupName, $daoName, $sql = NULL) { $idNameFields = isset($this->_xml[$groupName]['idNameFields']) ? $this->_xml[$groupName]['idNameFields'] : NULL; $mappedFields = isset($this->_xml[$groupName]['mappedFields']) ? $this->_xml[$groupName]['mappedFields'] : NULL; diff --git a/CRM/Utils/Migrate/ExportJSON.php b/CRM/Utils/Migrate/ExportJSON.php index d67ae0e0f4..fbcc348786 100644 --- a/CRM/Utils/Migrate/ExportJSON.php +++ b/CRM/Utils/Migrate/ExportJSON.php @@ -49,6 +49,9 @@ class CRM_Utils_Migrate_ExportJSON { protected $_sitePrefix = 'Site 1'; + /** + * @param $params + */ function __construct(&$params) { foreach ($params as $name => $value) { $varName = '_' . $name; @@ -134,6 +137,9 @@ class CRM_Utils_Migrate_ExportJSON { $this->auxTable($auxilaryTables); } + /** + * @param $tables + */ function auxTable($tables) { foreach ($tables as $tableName => $daoName) { $fields = & $this->dbFields($daoName, TRUE); @@ -143,6 +149,9 @@ class CRM_Utils_Migrate_ExportJSON { } } + /** + * @param $optionGroupVars + */ function optionGroup($optionGroupVars) { $names = array_values($optionGroupVars); $str = array(); @@ -169,6 +178,13 @@ WHERE g.name IN ( $nameString ) $this->sql($sql, 'civicrm_option_value', $fields); } + /** + * @param $ids + * @param $tableName + * @param $fields + * @param $whereField + * @param null $additionalWhereCond + */ function table(&$ids, $tableName, &$fields, @@ -194,6 +210,11 @@ SELECT * $this->sql($sql, $tableName, $fields); } + /** + * @param $sql + * @param $tableName + * @param $fields + */ function sql($sql, $tableName, &$fields) { $dao = & CRM_Core_DAO::executeQuery($sql); @@ -212,41 +233,65 @@ SELECT * $dao->free(); } + /** + * @param $contactIDs + */ function contact(&$contactIDs) { $fields = & $this->dbFields('CRM_Contact_DAO_Contact', TRUE); $this->table($contactIDs, 'civicrm_contact', $fields, 'id', NULL); } + /** + * @param $contactIDs + */ function note(&$contactIDs) { $fields = & $this->dbFields('CRM_Core_DAO_Note', TRUE); $this->table($contactIDs, 'civicrm_note', $fields, 'entity_id', "entity_table = 'civicrm_contact'"); } + /** + * @param $contactIDs + */ function phone(&$contactIDs) { $fields = & $this->dbFields('CRM_Core_DAO_Phone', TRUE); $this->table($contactIDs, 'civicrm_phone', $fields, 'contact_id', NULL); } + /** + * @param $contactIDs + */ function email(&$contactIDs) { $fields = & $this->dbFields('CRM_Core_DAO_Email', TRUE); $this->table($contactIDs, 'civicrm_email', $fields, 'contact_id', NULL); } + /** + * @param $contactIDs + */ function im(&$contactIDs) { $fields = & $this->dbFields('CRM_Core_DAO_IM', TRUE); $this->table($contactIDs, 'civicrm_im', $fields, 'contact_id', NULL); } + /** + * @param $contactIDs + */ function website(&$contactIDs) { $fields = & $this->dbFields('CRM_Core_DAO_Website', TRUE); $this->table($contactIDs, 'civicrm_website', $fields, 'contact_id', NULL); } + /** + * @param $contactIDs + */ function address(&$contactIDs) { $fields = & $this->dbFields('CRM_Core_DAO_Email', TRUE); $this->table($contactIDs, 'civicrm_address', $fields, 'contact_id', NULL); } + /** + * @param $contactIDs + */ function groupContact(&$contactIDs) { $fields = & $this->dbFields('CRM_Contact_DAO_GroupContact', TRUE); $this->table($contactIDs, 'civicrm_group_contact', $fields, 'contact_id', NULL); @@ -254,6 +299,9 @@ SELECT * // TODO - support group inheritance // Parent child group ids are encoded in a text string + /** + * @param $contactIDs + */ function group(&$contactIDs) { // handle groups only once static $_groupsHandled = array(); @@ -281,6 +329,9 @@ WHERE contact_id IN ( $ids ) } // TODO - support search builder and custom saved searches + /** + * @param $groupIDs + */ function savedSearch(&$groupIDs) { if (empty($groupIDs)) { return; @@ -298,11 +349,17 @@ WHERE g.id IN ( $idString ) $this->sql($sql, 'civicrm_saved_search', $fields); } + /** + * @param $contactIDs + */ function entityTag(&$contactIDs) { $fields = & $this->dbFields('CRM_Core_DAO_EntityTag', TRUE); $this->table($contactIDs, 'civicrm_entity_tag', $fields, 'entity_id', "entity_table = 'civicrm_contact'"); } + /** + * @param $contactIDs + */ function tag(&$contactIDs) { // handle tags only once static $_tagsHandled = array(); @@ -328,6 +385,10 @@ AND entity_table = 'civicrm_contact' $this->table($tagIDs, 'civicrm_tag', $fields, 'id'); } + /** + * @param $contactIDs + * @param $additionalContacts + */ function relationship(&$contactIDs, &$additionalContacts) { // handle relationships only once static $_relationshipsHandled = array(); @@ -374,6 +435,10 @@ AND entity_table = 'civicrm_contact' $dao->free(); } + /** + * @param $contactIDs + * @param $additionalContacts + */ function activity(&$contactIDs, &$additionalContacts) { static $_activitiesHandled = array(); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); @@ -429,6 +494,11 @@ WHERE ac.contact_id IN ( $ids ) $dao->free(); } + /** + * @param $id + * @param $name + * @param $value + */ function appendValue($id, $name, $value) { if (empty($value)) { return; @@ -441,6 +511,12 @@ WHERE ac.contact_id IN ( $ids ) $this->_values[$name][] = array_values($value); } + /** + * @param $daoName + * @param bool $onlyKeys + * + * @return array + */ function dbFields($daoName, $onlyKeys = FALSE) { static $_fieldsRetrieved = array(); @@ -471,6 +547,10 @@ WHERE ac.contact_id IN ( $ids ) } } + /** + * @param $contactIDs + * @param $additionalContacts + */ function addAdditionalContacts($contactIDs, &$additionalContacts) { if (!$this->_discoverContacts) { return; @@ -486,6 +566,9 @@ WHERE ac.contact_id IN ( $ids ) } } + /** + * @param $contactIDs + */ function export(&$contactIDs) { $chunks = & $this->splitContactIDs($contactIDs); @@ -501,6 +584,11 @@ WHERE ac.contact_id IN ( $ids ) } } + /** + * @param $fileName + * @param null $lastExportTime + * @param bool $discoverContacts + */ function run($fileName, $lastExportTime = NULL, $discoverContacts = FALSE diff --git a/CRM/Utils/Migrate/Import.php b/CRM/Utils/Migrate/Import.php index 6389a80ac7..124a58c536 100644 --- a/CRM/Utils/Migrate/Import.php +++ b/CRM/Utils/Migrate/Import.php @@ -33,6 +33,9 @@ * */ class CRM_Utils_Migrate_Import { + /** + * + */ function __construct() { } @@ -89,6 +92,14 @@ class CRM_Utils_Migrate_Import { CRM_Core_Config::clearDBCache(); } + /** + * @param $dao + * @param $xml + * @param bool $save + * @param null $keyName + * + * @return bool + */ function copyData(&$dao, &$xml, $save = FALSE, $keyName = NULL) { if ($keyName) { if (isset($xml->$keyName)) { @@ -123,6 +134,10 @@ class CRM_Utils_Migrate_Import { return TRUE; } + /** + * @param $xml + * @param $idMap + */ function optionGroups(&$xml, &$idMap) { foreach ($xml->OptionGroups as $optionGroupsXML) { foreach ($optionGroupsXML->OptionGroup as $optionGroupXML) { @@ -133,6 +148,10 @@ class CRM_Utils_Migrate_Import { } } + /** + * @param $xml + * @param $idMap + */ function optionValues(&$xml, &$idMap) { foreach ($xml->OptionValues as $optionValuesXML) { foreach ($optionValuesXML->OptionValue as $optionValueXML) { @@ -153,6 +172,9 @@ WHERE v.option_group_id = %1 } } + /** + * @param $xml + */ function relationshipTypes(&$xml) { foreach ($xml->RelationshipTypes as $relationshipTypesXML) { @@ -163,6 +185,9 @@ WHERE v.option_group_id = %1 } } + /** + * @param $xml + */ function contributionTypes(&$xml) { foreach ($xml->ContributionTypes as $contributionTypesXML) { @@ -173,6 +198,10 @@ WHERE v.option_group_id = %1 } } + /** + * @param $xml + * @param $idMap + */ function customGroups(&$xml, &$idMap) { foreach ($xml->CustomGroups as $customGroupsXML) { foreach ($customGroupsXML->CustomGroup as $customGroupXML) { @@ -301,6 +330,10 @@ AND v.name = %1 } } + /** + * @param $xml + * @param $idMap + */ function customFields(&$xml, &$idMap) { // Re-index by group id so we can build out the custom fields one table // at a time, and then rebuild the table triggers at the end, rather than @@ -348,6 +381,10 @@ AND v.name = %1 } } + /** + * @param $xml + * @param $idMap + */ function dbTemplateString(&$xml, &$idMap) { foreach ($xml->Persistent as $persistentXML) { foreach ($persistentXML->Persistent as $persistent) { @@ -361,6 +398,10 @@ AND v.name = %1 } } + /** + * @param $xml + * @param $idMap + */ function profileGroups(&$xml, &$idMap) { foreach ($xml->ProfileGroups as $profileGroupsXML) { foreach ($profileGroupsXML->ProfileGroup as $profileGroupXML) { @@ -372,6 +413,12 @@ AND v.name = %1 } } + /** + * @param $xml + * @param $idMap + * + * @throws Exception + */ function profileFields(&$xml, &$idMap) { foreach ($xml->ProfileFields as $profileFieldsXML) { foreach ($profileFieldsXML->ProfileField as $profileFieldXML) { @@ -410,6 +457,10 @@ AND f.column_name = %2 } } + /** + * @param $xml + * @param $idMap + */ function profileJoins(&$xml, &$idMap) { foreach ($xml->ProfileJoins as $profileJoinsXML) { foreach ($profileJoinsXML->ProfileJoin as $profileJoinXML) { diff --git a/CRM/Utils/Migrate/ImportJSON.php b/CRM/Utils/Migrate/ImportJSON.php index 09ac094611..fb16cc3958 100644 --- a/CRM/Utils/Migrate/ImportJSON.php +++ b/CRM/Utils/Migrate/ImportJSON.php @@ -38,11 +38,17 @@ class CRM_Utils_Migrate_ImportJSON { protected $_saveMapping; + /** + * + */ function __construct() { $this->_lookupCache = array(); $this->_saveMapping = array(); } + /** + * @param $file + */ function run($file) { $json = file_get_contents($file); @@ -69,6 +75,9 @@ class CRM_Utils_Migrate_ImportJSON { CRM_Core_Config::clearDBCache(); } + /** + * @param $contact + */ function contact(&$contact) { $this->restore($contact, 'CRM_Contact_DAO_Contact', @@ -77,6 +86,9 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $email + */ function email(&$email) { $this->restore($email, 'CRM_Core_DAO_Email', @@ -84,6 +96,9 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $phone + */ function phone(&$phone) { $this->restore($phone, 'CRM_Core_DAO_Phone', @@ -91,6 +106,9 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $address + */ function address(&$address) { $this->restore($address, 'CRM_Core_DAO_Address', @@ -98,6 +116,9 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $note + */ function note(&$note) { $this->restore($note, 'CRM_Core_DAO_Note', @@ -106,6 +127,9 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $relationship + */ function relationship(&$relationship) { $this->restore($relationship, 'CRM_Contact_DAO_Relationship', @@ -116,6 +140,10 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $activity + * @param $activityContacts + */ function activity($activity, $activityContacts) { $this->restore($activity, 'CRM_Activity_DAO_Activity', @@ -132,6 +160,10 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $group + * @param $groupContact + */ function group($group, $groupContact) { $this->restore($group, 'CRM_Contact_DAO_Group', @@ -148,6 +180,10 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $tag + * @param $entityTag + */ function tag($tag, $entityTag) { $this->restore($tag, 'CRM_Core_DAO_Tag', @@ -166,6 +202,12 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $chunk + * @param $daoName + * @param null $lookUpMapping + * @param null $dateFields + */ function restore(&$chunk, $daoName, $lookUpMapping = NULL, $dateFields = NULL) { $object = new $daoName(); $tableName = $object->__table; @@ -237,6 +279,9 @@ class CRM_Utils_Migrate_ImportJSON { } } + /** + * @param $tableName + */ function populateCache($tableName) { if (isset($this->_lookupCache[$tableName])) { return; diff --git a/CRM/Utils/Number.php b/CRM/Utils/Number.php index 3cf0033bb9..b79b994cac 100644 --- a/CRM/Utils/Number.php +++ b/CRM/Utils/Number.php @@ -1,4 +1,8 @@ $val) { $graph[$val] = $rows['value'][$key]; @@ -493,6 +508,12 @@ class CRM_Utils_OpenFlashChart { return self::buildChart($chartData, $chart); } + /** + * @param $params + * @param $chart + * + * @return array + */ static function buildChart(&$params, $chart) { $openFlashChart = array(); if ($chart && is_array($params) && !empty($params)) { diff --git a/CRM/Utils/OptionBag.php b/CRM/Utils/OptionBag.php index ebcf9d597c..aa2fe8edbc 100644 --- a/CRM/Utils/OptionBag.php +++ b/CRM/Utils/OptionBag.php @@ -1,8 +1,14 @@ data = $data; } @@ -39,6 +45,11 @@ class CRM_Utils_OptionBag implements ArrayAccess, IteratorAggregate, Countable { } } + /** + * @param $key + * + * @return bool + */ public function has($key) { return isset($this->data[$key]); } @@ -126,4 +137,4 @@ class CRM_Utils_OptionBag implements ArrayAccess, IteratorAggregate, Countable { } -} \ No newline at end of file +} diff --git a/CRM/Utils/PDF/Label.php b/CRM/Utils/PDF/Label.php index 69d6b520a5..e5a8326248 100644 --- a/CRM/Utils/PDF/Label.php +++ b/CRM/Utils/PDF/Label.php @@ -35,6 +35,10 @@ */ require_once 'tcpdf/tcpdf.php'; + +/** + * Class CRM_Utils_PDF_Label + */ class CRM_Utils_PDF_Label extends TCPDF { // make these properties public due to @@ -116,11 +120,21 @@ class CRM_Utils_PDF_Label extends TCPDF { $this->setPrintFooter(FALSE); } + /** + * @param $objectinstance + * @param string $methodname + */ function SetGenerator($objectinstance, $methodname = 'generateLabel') { $this->generatorMethod = $methodname; $this->generatorObject = $objectinstance; } + /** + * @param $name + * @param bool $convert + * + * @return float|int|mixed + */ function getFormatValue($name, $convert = FALSE) { if (isset($this->format[$name])) { $value = $this->format[$name]; @@ -139,6 +153,10 @@ class CRM_Utils_PDF_Label extends TCPDF { /* * Function to initialize label format settings */ + /** + * @param $format + * @param $unit + */ function LabelSetFormat(&$format, $unit) { $this->defaults = CRM_Core_BAO_LabelFormat::getDefaultValues(); $this->format = &$format; @@ -168,6 +186,9 @@ class CRM_Utils_PDF_Label extends TCPDF { /* * function to Generate the pdf of one label (can be modified using SetGenerator) */ + /** + * @param $text + */ function generateLabel($text) { $args = array( 'w' => $this->width, @@ -212,6 +233,9 @@ class CRM_Utils_PDF_Label extends TCPDF { /* * function to Print a label */ + /** + * @param $texte + */ function AddPdfLabel($texte) { if ($this->countX == $this->xNumber) { // Page full, we start a new one diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php index 544ae42c61..8104ea9163 100644 --- a/CRM/Utils/PDF/Utils.php +++ b/CRM/Utils/PDF/Utils.php @@ -34,6 +34,14 @@ */ class CRM_Utils_PDF_Utils { + /** + * @param $text + * @param string $fileName + * @param bool $output + * @param null $pdfFormat + * + * @return string|void + */ static function html2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) { if (is_array($text)) { $pages = &$text; @@ -105,6 +113,15 @@ class CRM_Utils_PDF_Utils { } } + /** + * @param $paper_size + * @param $orientation + * @param $html + * @param $output + * @param $fileName + * + * @return string + */ static function _html2pdf_dompdf($paper_size, $orientation, $html, $output, $fileName) { require_once 'packages/dompdf/dompdf_config.inc.php'; spl_autoload_register('DOMPDF_autoload'); @@ -121,6 +138,14 @@ class CRM_Utils_PDF_Utils { } } + /** + * @param $paper_size + * @param $orientation + * @param $margins + * @param $html + * @param $output + * @param $fileName + */ static function _html2pdf_wkhtmltopdf($paper_size, $orientation, $margins, $html, $output, $fileName) { require_once 'packages/snappy/src/autoload.php'; $config = CRM_Core_Config::singleton(); @@ -146,6 +171,14 @@ class CRM_Utils_PDF_Utils { /* * function to convert value from one metric to another */ + /** + * @param $value + * @param $from + * @param $to + * @param null $precision + * + * @return float|int + */ static function convertMetric($value, $from, $to, $precision = NULL) { switch ($from . $to) { case 'incm': @@ -202,6 +235,17 @@ class CRM_Utils_PDF_Utils { return $value; } + /** + * @param $fileName + * @param $searchPath + * @param $values + * @param int $numPages + * @param bool $echo + * @param string $output + * @param string $creator + * @param string $author + * @param string $title + */ static function &pdflib($fileName, $searchPath, &$values, diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index b703dbf5d8..cc92c5b397 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -44,6 +44,10 @@ */ require_once 'Pager/Sliding.php'; + +/** + * Class CRM_Utils_Pager + */ class CRM_Utils_Pager extends Pager_Sliding { /** @@ -261,12 +265,18 @@ class CRM_Utils_Pager extends Pager_Sliding { return array($offset, $this->_perPage); } + /** + * @return string + */ function getCurrentLocation() { $config = CRM_Core_Config::singleton(); $path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET); return CRM_Utils_System::url($path, CRM_Utils_System::getLinksUrl(self::PAGE_ID, FALSE, TRUE), FALSE, NULL, FALSE) . $this->getCurrentPageID(); } + /** + * @return string + */ function getFirstPageLink() { if ($this->isFirstPage()) { return ''; @@ -280,6 +290,9 @@ class CRM_Utils_Pager extends Pager_Sliding { ) . $this->_spacesBefore . $this->_spacesAfter; } + /** + * @return string + */ function getLastPageLink() { if ($this->isLastPage()) { return ''; @@ -293,6 +306,9 @@ class CRM_Utils_Pager extends Pager_Sliding { ); } + /** + * @return string + */ function getBackPageLink() { if ($this->_currentPage > 1) { $href = $this->makeURL(self::PAGE_ID, $this->getPreviousPageID()); @@ -304,6 +320,9 @@ class CRM_Utils_Pager extends Pager_Sliding { return ''; } + /** + * @return string + */ function getNextPageLink() { if ($this->_currentPage < $this->_totalPages) { $href = $this->makeURL(self::PAGE_ID, $this->getNextPageID()); diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index 885a1c3907..4605f1c28f 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -74,6 +74,11 @@ class CRM_Utils_REST { } // Generates values needed for error messages + /** + * @param string $message + * + * @return array + */ static function error($message = 'Unknown Error') { $values = array( 'error_message' => $message, @@ -83,17 +88,28 @@ class CRM_Utils_REST { } // Generates values needed for non-error responses. + /** + * @param $params + * + * @return array + */ static function simple($params) { $values = array('is_error' => 0); $values += $params; return $values; } + /** + * @return string + */ function run() { $result = self::handle(); return self::output($result); } + /** + * @return string + */ function bootAndRun() { $response = $this->loadCMSBootstrap(); if (is_array($response)) { @@ -102,6 +118,11 @@ class CRM_Utils_REST { return $this->run(); } + /** + * @param $result + * + * @return string + */ static function output(&$result) { $requestParams = CRM_Utils_Request::exportValues(); @@ -160,6 +181,11 @@ class CRM_Utils_REST { return $xml; } + /** + * @param $json + * + * @return string + */ static function jsonFormated($json) { $tabcount = 0; $result = ''; @@ -238,6 +264,9 @@ class CRM_Utils_REST { return $result; } + /** + * @return array|int + */ static function handle() { $requestParams = CRM_Utils_Request::exportValues(); @@ -308,6 +337,12 @@ class CRM_Utils_REST { return self::process($args, self::buildParamList()); } + /** + * @param $args + * @param $params + * + * @return array|int + */ static function process(&$args, $params) { $params['check_permissions'] = TRUE; $fnName = $apiFile = NULL; @@ -366,6 +401,9 @@ class CRM_Utils_REST { return $result; } + /** + * @return array|mixed|null + */ static function &buildParamList() { $requestParams = CRM_Utils_Request::exportValues(); $params = array(); @@ -397,6 +435,9 @@ class CRM_Utils_REST { return $params; } + /** + * @param $pearError + */ static function fatal($pearError) { header('Content-Type: text/xml'); $error = array(); diff --git a/CRM/Utils/ReCAPTCHA.php b/CRM/Utils/ReCAPTCHA.php index 2545f948ca..6b07762614 100644 --- a/CRM/Utils/ReCAPTCHA.php +++ b/CRM/Utils/ReCAPTCHA.php @@ -67,6 +67,9 @@ class CRM_Utils_ReCAPTCHA { return self::$_singleton; } + /** + * + */ function __construct() {} /** @@ -111,6 +114,12 @@ class CRM_Utils_ReCAPTCHA { ); } + /** + * @param $value + * @param $form + * + * @return mixed + */ static function validate($value, $form) { $config = CRM_Core_Config::singleton(); diff --git a/CRM/Utils/Rule.php b/CRM/Utils/Rule.php index 3d42693602..4c27b896e9 100644 --- a/CRM/Utils/Rule.php +++ b/CRM/Utils/Rule.php @@ -35,8 +35,17 @@ require_once 'HTML/QuickForm/Rule/Email.php'; +/** + * Class CRM_Utils_Rule + */ class CRM_Utils_Rule { + /** + * @param $str + * @param int $maxLength + * + * @return bool + */ static function title($str, $maxLength = 127) { // check length etc @@ -52,10 +61,20 @@ class CRM_Utils_Rule { return TRUE; } + /** + * @param $str + * + * @return bool + */ static function longTitle($str) { return self::title($str, 255); } + /** + * @param $str + * + * @return bool + */ static function variable($str) { // check length etc if (empty($str) || strlen($str) > 31) { @@ -70,6 +89,11 @@ class CRM_Utils_Rule { return TRUE; } + /** + * @param $str + * + * @return bool + */ static function qfVariable($str) { // check length etc //if ( empty( $str ) || strlen( $str ) > 31 ) { @@ -86,6 +110,11 @@ class CRM_Utils_Rule { return TRUE; } + /** + * @param $phone + * + * @return bool + */ static function phone($phone) { // check length etc if (empty($phone) || strlen($phone) > 16) { @@ -99,6 +128,11 @@ class CRM_Utils_Rule { return FALSE; } + /** + * @param $query + * + * @return bool + */ static function query($query) { // check length etc if (empty($query) || strlen($query) < 3 || strlen($query) > 127) { @@ -113,15 +147,30 @@ class CRM_Utils_Rule { return TRUE; } + /** + * @param $url + * + * @return bool + */ static function url($url) { return (bool) filter_var($url, FILTER_VALIDATE_URL); } + /** + * @param $string + * + * @return bool + */ static function wikiURL($string) { $items = explode(' ', trim($string), 2); return self::url($items[0]); } + /** + * @param $domain + * + * @return bool + */ static function domain($domain) { // not perfect, but better than the previous one; see CRM-1502 if (!preg_match('/^[A-Za-z0-9]([A-Za-z0-9\.\-]*[A-Za-z0-9])?$/', $domain)) { @@ -130,6 +179,12 @@ class CRM_Utils_Rule { return TRUE; } + /** + * @param $value + * @param null $default + * + * @return null + */ static function date($value, $default = NULL) { if (is_string($value) && preg_match('/^\d\d\d\d-?\d\d-?\d\d$/', $value) @@ -139,6 +194,12 @@ class CRM_Utils_Rule { return $default; } + /** + * @param $value + * @param null $default + * + * @return null|string + */ static function dateTime($value, $default = NULL) { $result = $default; if (is_string($value) && @@ -268,6 +329,11 @@ class CRM_Utils_Rule { return FALSE; } + /** + * @param $value + * + * @return bool + */ static function integer($value) { if (is_int($value)) { return TRUE; @@ -296,6 +362,11 @@ class CRM_Utils_Rule { return FALSE; } + /** + * @param $value + * + * @return bool + */ static function positiveInteger($value) { if (is_int($value)) { return ($value < 0) ? FALSE : TRUE; @@ -314,6 +385,11 @@ class CRM_Utils_Rule { return FALSE; } + /** + * @param $value + * + * @return bool + */ static function numeric($value) { // lets use a php gatekeeper to ensure this is numeric if (!is_numeric($value)) { @@ -323,10 +399,21 @@ class CRM_Utils_Rule { return preg_match('/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/', $value) ? TRUE : FALSE; } + /** + * @param $value + * @param $noOfDigit + * + * @return bool + */ static function numberOfDigit($value, $noOfDigit) { return preg_match('/^\d{' . $noOfDigit . '}$/', $value) ? TRUE : FALSE; } + /** + * @param $value + * + * @return mixed + */ static function cleanMoney($value) { // first remove all white space $value = str_replace(array(' ', "\t", "\n"), '', $value); @@ -358,6 +445,11 @@ class CRM_Utils_Rule { return $value; } + /** + * @param $value + * + * @return bool + */ static function money($value) { $config = CRM_Core_Config::singleton(); @@ -381,6 +473,12 @@ class CRM_Utils_Rule { return preg_match('/(^-?\d+\.\d?\d?$)|(^-?\.\d\d?$)/', $value) ? TRUE : FALSE; } + /** + * @param $value + * @param int $maxLength + * + * @return bool + */ static function string($value, $maxLength = 0) { if (is_string($value) && ($maxLength === 0 || strlen($value) <= $maxLength) @@ -390,16 +488,31 @@ class CRM_Utils_Rule { return FALSE; } + /** + * @param $value + * + * @return bool + */ static function boolean($value) { return preg_match( '/(^(1|0)$)|(^(Y(es)?|N(o)?)$)|(^(T(rue)?|F(alse)?)$)/i', $value ) ? TRUE : FALSE; } + /** + * @param $value + * + * @return bool + */ static function email($value) { return (bool) filter_var($value, FILTER_VALIDATE_EMAIL); } + /** + * @param $list + * + * @return bool + */ static function emailList($list) { $emails = explode(',', $list); foreach ($emails as $email) { @@ -414,6 +527,11 @@ class CRM_Utils_Rule { // allow between 4-6 digits as postal code since india needs 6 and US needs 5 (or // if u disregard the first 0, 4 (thanx excel!) // FIXME: we need to figure out how to localize such rules + /** + * @param $value + * + * @return bool + */ static function postalCode($value) { if (preg_match('/^\d{4,6}(-\d{4})?$/', $value)) { return TRUE; @@ -505,21 +623,44 @@ class CRM_Utils_Rule { return CRM_Core_DAO::objectExists($value, CRM_Utils_Array::value(0, $options), CRM_Utils_Array::value(1, $options), CRM_Utils_Array::value(2, $options, $name)); } + /** + * @param $value + * @param $options + * + * @return bool + */ static function optionExists($value, $options) { return CRM_Core_OptionValue::optionExists($value, $options[0], $options[1], $options[2], CRM_Utils_Array::value(3, $options, 'name')); } + /** + * @param $value + * @param $type + * + * @return bool + */ static function creditCardNumber($value, $type) { require_once 'Validate/Finance/CreditCard.php'; return Validate_Finance_CreditCard::number($value, $type); } + /** + * @param $value + * @param $type + * + * @return bool + */ static function cvv($value, $type) { require_once 'Validate/Finance/CreditCard.php'; return Validate_Finance_CreditCard::cvv($value, $type); } + /** + * @param $value + * + * @return bool + */ static function currencyCode($value) { static $currencyCodes = NULL; if (!$currencyCodes) { @@ -531,6 +672,11 @@ class CRM_Utils_Rule { return FALSE; } + /** + * @param $value + * + * @return bool + */ static function xssString($value) { if (is_string($value)) { return preg_match('!<(vb)?script[^>]*>.*!ims', @@ -542,10 +688,21 @@ class CRM_Utils_Rule { } } + /** + * @param $path + * + * @return bool + */ static function fileExists($path) { return file_exists($path); } + /** + * @param $value + * @param $options + * + * @return bool + */ static function autocomplete($value, $options) { if ($value) { $selectOption = CRM_Core_BAO_CustomOption::valuesByID($options['fieldID'], $options['optionGroupID']); @@ -557,6 +714,12 @@ class CRM_Utils_Rule { return TRUE; } + /** + * @param $value + * @param null $actualElementValue + * + * @return bool + */ static function validContact($value, $actualElementValue = NULL) { if ($actualElementValue) { $value = $actualElementValue; @@ -621,6 +784,11 @@ class CRM_Utils_Rule { return FALSE; } + /** + * @param $key + * + * @return bool + */ static function qfKey($key) { return ($key) ? CRM_Core_Key::valid($key) : FALSE; } diff --git a/CRM/Utils/Signer.php b/CRM/Utils/Signer.php index 03435adbd3..05987a6b0b 100644 --- a/CRM/Utils/Signer.php +++ b/CRM/Utils/Signer.php @@ -120,6 +120,9 @@ class CRM_Utils_Signer { return ($token == $newToken); } + /** + * @return string + */ function createSalt() { // It would be more secure to generate a new value but liable to run this // many times on certain admin pages; so instead we'll re-use the hash. diff --git a/CRM/Utils/SoapServer.php b/CRM/Utils/SoapServer.php index ce4e2b13cd..7d29014052 100644 --- a/CRM/Utils/SoapServer.php +++ b/CRM/Utils/SoapServer.php @@ -161,6 +161,15 @@ class CRM_Utils_SoapServer { return civicrm_api('Mailing', 'event_bounce', $params); } + /** + * @param $key + * @param $job + * @param $queue + * @param $hash + * + * @return array|int + * @throws SoapFault + */ public function mailer_event_unsubscribe($key, $job, $queue, $hash) { $this->verify($key); $params = array( @@ -174,6 +183,15 @@ class CRM_Utils_SoapServer { return civicrm_api('MailingGroup', 'event_unsubscribe', $params); } + /** + * @param $key + * @param $job + * @param $queue + * @param $hash + * + * @return array|int + * @throws SoapFault + */ public function mailer_event_domain_unsubscribe($key, $job, $queue, $hash) { $this->verify($key); $params = array( @@ -187,6 +205,15 @@ class CRM_Utils_SoapServer { return civicrm_api('MailingGroup', 'event_domain_unsubscribe', $params); } + /** + * @param $key + * @param $job + * @param $queue + * @param $hash + * + * @return array|int + * @throws SoapFault + */ public function mailer_event_resubscribe($key, $job, $queue, $hash) { $this->verify($key); $params = array( @@ -200,6 +227,15 @@ class CRM_Utils_SoapServer { return civicrm_api('MailingGroup', 'event_resubscribe', $params); } + /** + * @param $key + * @param $email + * @param $domain + * @param $group + * + * @return array|int + * @throws SoapFault + */ public function mailer_event_subscribe($key, $email, $domain, $group) { $this->verify($key); $params = array( @@ -210,6 +246,15 @@ class CRM_Utils_SoapServer { return civicrm_api('MailingGroup', 'event_subscribe', $params); } + /** + * @param $key + * @param $contact + * @param $subscribe + * @param $hash + * + * @return array|int + * @throws SoapFault + */ public function mailer_event_confirm($key, $contact, $subscribe, $hash) { $this->verify($key); $params = array( @@ -223,6 +268,19 @@ class CRM_Utils_SoapServer { return civicrm_api('Mailing', 'event_confirm', $params); } + /** + * @param $key + * @param $job + * @param $queue + * @param $hash + * @param $bodyTxt + * @param $rt + * @param null $bodyHTML + * @param null $fullEmail + * + * @return array|int + * @throws SoapFault + */ public function mailer_event_reply($key, $job, $queue, $hash, $bodyTxt, $rt, $bodyHTML = NULL, $fullEmail = NULL) { $this->verify($key); $params = array( @@ -239,6 +297,16 @@ class CRM_Utils_SoapServer { return civicrm_api('Mailing', 'event_reply', $params); } + /** + * @param $key + * @param $job + * @param $queue + * @param $hash + * @param $email + * + * @return array|int + * @throws SoapFault + */ public function mailer_event_forward($key, $job, $queue, $hash, $email) { $this->verify($key); $params = array( @@ -251,6 +319,13 @@ class CRM_Utils_SoapServer { return civicrm_api('Mailing', 'event_forward', $params); } + /** + * @param $key + * @param $params + * + * @return array|int + * @throws SoapFault + */ public function get_contact($key, $params) { $this->verify($key); $params['version'] = 3; diff --git a/CRM/Utils/String.php b/CRM/Utils/String.php index 93ff782732..7e3b8f0d49 100644 --- a/CRM/Utils/String.php +++ b/CRM/Utils/String.php @@ -265,6 +265,12 @@ class CRM_Utils_String { return CRM_Core_DAO::$_nullArray; } + /** + * @param $str + * @param $stringRules + * + * @return mixed + */ static function redaction($str, $stringRules) { //redact the strings if (!empty($stringRules)) { @@ -419,6 +425,10 @@ class CRM_Utils_String { return $text; } + /** + * @param $string + * @param $params + */ static function extractName($string, &$params) { $name = trim($string); if (empty($name)) { @@ -469,6 +479,11 @@ class CRM_Utils_String { } } + /** + * @param $string + * + * @return array + */ static function &makeArray($string) { $string = trim($string); diff --git a/CRM/Utils/Sunlight.php b/CRM/Utils/Sunlight.php index a4ab7c0cbf..a6cf20d31c 100644 --- a/CRM/Utils/Sunlight.php +++ b/CRM/Utils/Sunlight.php @@ -36,6 +36,12 @@ class CRM_Utils_Sunlight { static $_apiURL = 'http://api.sunlightlabs.com/'; static $_apiKey = NULL; + /** + * @param $uri + * + * @return SimpleXMLElement + * @throws Exception + */ static function makeAPICall($uri) { require_once 'HTTP/Request.php'; $params = array( @@ -57,6 +63,11 @@ class CRM_Utils_Sunlight { return simplexml_load_string($string); } + /** + * @param $zipcode + * + * @return array + */ static function getCityState($zipcode) { $key = self::$_apiKey; $uri = "places.getCityStateFromZip.php?zip={$zipcode}&apikey={$key}&output=xml"; @@ -65,6 +76,11 @@ class CRM_Utils_Sunlight { return array($xml->city, $xml->state); } + /** + * @param $peopleID + * + * @return array + */ static function getDetailedInfo($peopleID) { $key = self::$_apiKey; $uri = "people.getPersonInfo.php?id={$peopleID}&apikey={$key}&output=xml"; @@ -94,6 +110,11 @@ class CRM_Utils_Sunlight { return $result; } + /** + * @param $uri + * + * @return array + */ static function getPeopleInfo($uri) { $xml = self::makeAPICall($uri); @@ -104,6 +125,12 @@ class CRM_Utils_Sunlight { return $result; } + /** + * @param $city + * @param $state + * + * @return array|null + */ static function getRepresentativeInfo($city, $state) { if (!$city || !$state @@ -116,6 +143,11 @@ class CRM_Utils_Sunlight { return self::getPeopleInfo($uri); } + /** + * @param $state + * + * @return array|null + */ static function getSenatorInfo($state) { if (!$state) { return NULL; @@ -126,6 +158,13 @@ class CRM_Utils_Sunlight { return self::getPeopleInfo($uri); } + /** + * @param $city + * @param $state + * @param null $zipcode + * + * @return array + */ static function getInfo($city, $state, $zipcode = NULL) { if ($zipcode) { list($city, $state) = self::getCityState($zipcode); diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index d42f699ac1..76a2c1dfab 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -252,6 +252,18 @@ class CRM_Utils_System { return $config->userSystem->url($path, $query, $absolute, $fragment, $htmlize, $frontend, $forceBackend); } + /** + * @param $text + * @param null $path + * @param null $query + * @param bool $absolute + * @param null $fragment + * @param bool $htmlize + * @param bool $frontend + * @param bool $forceBackend + * + * @return string + */ static function href($text, $path = NULL, $query = NULL, $absolute = TRUE, $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE ) { @@ -259,11 +271,17 @@ class CRM_Utils_System { return "$text"; } + /** + * @return mixed + */ static function permissionDenied() { $config = CRM_Core_Config::singleton(); return $config->userSystem->permissionDenied(); } + /** + * @return mixed + */ static function logout() { $config = CRM_Core_Config::singleton(); return $config->userSystem->logout(); @@ -1188,6 +1206,11 @@ class CRM_Utils_System { * @return string * IP address of logged in user. */ + /** + * @param bool $strictIPV4 + * + * @return mixed|string + */ static function ipAddress($strictIPV4 = TRUE) { $address = CRM_Utils_Array::value('REMOTE_ADDR', $_SERVER); @@ -1816,6 +1839,9 @@ class CRM_Utils_System { return $cache; } + /** + * @return bool + */ static function isInUpgradeMode() { $args = explode('/', $_GET['q']); $upgradeInProcess = CRM_Core_Session::singleton()->get('isUpgradePending'); @@ -1826,4 +1852,4 @@ class CRM_Utils_System { return FALSE; } } -} \ No newline at end of file +} diff --git a/CRM/Utils/System/Drupal6.php b/CRM/Utils/System/Drupal6.php index 765be3a6d8..c18b5331f5 100644 --- a/CRM/Utils/System/Drupal6.php +++ b/CRM/Utils/System/Drupal6.php @@ -567,6 +567,9 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase { drupal_set_message($message); } + /** + * @return mixed + */ function logout() { module_load_include('inc', 'user', 'user.pages'); return user_logout(); diff --git a/CRM/Utils/SystemLogger.php b/CRM/Utils/SystemLogger.php index 6b9b680651..57b9eb2a19 100644 --- a/CRM/Utils/SystemLogger.php +++ b/CRM/Utils/SystemLogger.php @@ -33,6 +33,21 @@ * */ class CRM_Utils_SystemLogger extends Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface { + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + * @return null + */ + /** + * @param mixed $level + * @param string $message + * @param array $context + * + * @return null + */ public function log($level, $message, array $context = array()) { if(!isset($context['hostname'])) { $context['hostname'] = CRM_Utils_System::ipAddress(); diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 14de246496..bd5b16598a 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -802,7 +802,16 @@ class CRM_Utils_Token { } return $tokenHtml; } - public static function getHookTokenReplacement( + + /** + * @param $token + * @param $contact + * @param $category + * @param bool $html + * @param bool $escapeSmarty + * + * @return mixed|string + */public static function getHookTokenReplacement( $token, &$contact, $category, @@ -1358,6 +1367,11 @@ class CRM_Utils_Token { } } + /** + * @param $tokens + * + * @return array + */ static function flattenTokens(&$tokens) { $flattenTokens = array(); diff --git a/CRM/Utils/Weight.php b/CRM/Utils/Weight.php index b1dcfb7940..df1f36efd3 100644 --- a/CRM/Utils/Weight.php +++ b/CRM/Utils/Weight.php @@ -24,6 +24,10 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ */ + +/** + * Class CRM_Utils_Weight + */ class CRM_Utils_Weight { /** * @var array, list of GET fields which must be validated @@ -332,6 +336,13 @@ class CRM_Utils_Weight { return $resultDAO; } + /** + * @param $rows + * @param $daoName + * @param $idName + * @param $returnURL + * @param null $filter + */ static function addOrder(&$rows, $daoName, $idName, $returnURL, $filter = NULL) { if (empty($rows)) { return; @@ -462,6 +473,9 @@ class CRM_Utils_Weight { self::fixOrderOutput($url); } + /** + * @param $url + */ static function fixOrderOutput($url) { if (empty($_GET['snippet']) || $_GET['snippet'] !== 'json') { CRM_Utils_System::redirect($url); diff --git a/CRM/Utils/XML.php b/CRM/Utils/XML.php index cdbe2e0cd5..ab3338b72d 100644 --- a/CRM/Utils/XML.php +++ b/CRM/Utils/XML.php @@ -89,6 +89,11 @@ class CRM_Utils_XML { return array($xml, $error); } + /** + * @param $errors + * + * @return string + */ protected static function formatErrors($errors) { $messages = array(); -- 2.25.1