From 6714d8d227f25c94a3435acf445ef902c36b880c Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 11:22:19 +1000 Subject: [PATCH] (NFC) Bring CRM/Utils folder up to future coder standards --- CRM/Utils/API/AbstractFieldCoder.php | 4 +- CRM/Utils/API/HTMLInputCoder.php | 27 +++-- CRM/Utils/API/MatchOption.php | 3 +- CRM/Utils/Address/BatchUpdate.php | 24 ++--- CRM/Utils/Array.php | 3 +- CRM/Utils/Cache.php | 3 +- CRM/Utils/Cache/APCcache.php | 12 ++- CRM/Utils/Cache/ArrayCache.php | 4 +- CRM/Utils/Cache/ArrayDecorator.php | 3 +- CRM/Utils/Cache/FastArrayDecorator.php | 3 +- CRM/Utils/Cache/Memcache.php | 7 +- CRM/Utils/Cache/Memcached.php | 9 +- CRM/Utils/Cache/NaiveMultipleTrait.php | 1 + CRM/Utils/Cache/NoCache.php | 6 +- CRM/Utils/Cache/Redis.php | 9 +- CRM/Utils/Cache/SerializeCache.php | 10 +- CRM/Utils/Cache/SqlGroup.php | 5 +- CRM/Utils/Cache/Tiered.php | 3 +- CRM/Utils/Check/Component.php | 4 +- CRM/Utils/Check/Component/Env.php | 13 ++- CRM/Utils/Check/Component/PriceFields.php | 3 +- CRM/Utils/Check/Component/Security.php | 2 - CRM/Utils/Date.php | 11 +-- CRM/Utils/DeprecatedUtils.php | 13 ++- CRM/Utils/FakeObject.php | 1 + CRM/Utils/File.php | 3 +- CRM/Utils/GlobalStack.php | 2 +- CRM/Utils/Hook.php | 23 +++-- CRM/Utils/Hook/Joomla.php | 1 + CRM/Utils/Hook/Soap.php | 1 + CRM/Utils/Hook/UnitTests.php | 2 +- CRM/Utils/Hook/WordPress.php | 1 - CRM/Utils/JS.php | 1 + CRM/Utils/Mail.php | 8 +- CRM/Utils/Migrate/Export.php | 16 +-- CRM/Utils/Migrate/ExportJSON.php | 6 +- CRM/Utils/Migrate/Import.php | 1 + CRM/Utils/Money.php | 8 +- CRM/Utils/Network.php | 1 + CRM/Utils/Number.php | 10 +- CRM/Utils/OpenFlashChart.php | 16 +-- CRM/Utils/PDF/Document.php | 5 +- CRM/Utils/PDF/Label.php | 115 +++++++++++++++++----- CRM/Utils/PDF/Utils.php | 4 +- CRM/Utils/Pager.php | 12 +-- CRM/Utils/PseudoConstant.php | 1 + CRM/Utils/QueryFormatter.php | 7 +- CRM/Utils/REST.php | 16 ++- CRM/Utils/ReCAPTCHA.php | 1 - CRM/Utils/Request.php | 4 +- CRM/Utils/SQL/BaseParamQuery.php | 11 ++- CRM/Utils/SQL/Insert.php | 4 +- CRM/Utils/SQL/Select.php | 1 - CRM/Utils/SQL/TempTable.php | 10 +- CRM/Utils/Signer.php | 6 +- CRM/Utils/SoapServer.php | 4 +- CRM/Utils/String.php | 1 - CRM/Utils/System.php | 11 +-- CRM/Utils/System/Base.php | 23 +++-- CRM/Utils/System/DrupalBase.php | 12 +-- CRM/Utils/System/Joomla.php | 5 +- CRM/Utils/System/Soap.php | 5 +- CRM/Utils/System/UnitTests.php | 1 + CRM/Utils/System/WordPress.php | 6 +- CRM/Utils/SystemLogger.php | 1 + CRM/Utils/Token.php | 41 ++++---- CRM/Utils/Url.php | 4 +- CRM/Utils/Verp.php | 16 +-- CRM/Utils/Weight.php | 3 +- CRM/Utils/Wrapper.php | 1 + CRM/Utils/XML.php | 12 ++- CRM/Utils/Zip.php | 9 +- 72 files changed, 397 insertions(+), 238 deletions(-) diff --git a/CRM/Utils/API/AbstractFieldCoder.php b/CRM/Utils/API/AbstractFieldCoder.php index e14e23ff4d..6dfefd8fca 100644 --- a/CRM/Utils/API/AbstractFieldCoder.php +++ b/CRM/Utils/API/AbstractFieldCoder.php @@ -92,7 +92,7 @@ abstract class CRM_Utils_API_AbstractFieldCoder implements API_Wrapper { * * @param array|string $values the field value from the API */ - public abstract function encodeInput(&$values); + abstract public function encodeInput(&$values); /** * Decode output. @@ -101,7 +101,7 @@ abstract class CRM_Utils_API_AbstractFieldCoder implements API_Wrapper { * * @return mixed */ - public abstract function decodeOutput(&$values); + abstract public function decodeOutput(&$values); /** * @inheritDoc diff --git a/CRM/Utils/API/HTMLInputCoder.php b/CRM/Utils/API/HTMLInputCoder.php index 91df1ac522..bc9a2b5181 100644 --- a/CRM/Utils/API/HTMLInputCoder.php +++ b/CRM/Utils/API/HTMLInputCoder.php @@ -97,19 +97,28 @@ class CRM_Utils_API_HTMLInputCoder extends CRM_Utils_API_AbstractFieldCoder { 'honor_block_text', 'pay_later_text', 'pay_later_receipt', - 'label', // This is needed for FROM Email Address configuration. dgg - 'url', // This is needed for navigation items urls + // This is needed for FROM Email Address configuration. dgg + 'label', + // This is needed for navigation items urls + 'url', 'details', - 'msg_text', // message templates’ text versions - 'text_message', // (send an) email to contact’s and CiviMail’s text version - 'data', // data i/p of persistent table - 'sqlQuery', // CRM-6673 + // message templates’ text versions + 'msg_text', + // (send an) email to contact’s and CiviMail’s text version + 'text_message', + // data i/p of persistent table + 'data', + // CRM-6673 + 'sqlQuery', 'pcp_title', 'pcp_intro_text', - 'new', // The 'new' text in word replacements - 'replyto_email', // e.g. '"Full Name" ' + // The 'new' text in word replacements + 'new', + // e.g. '"Full Name" ' + 'replyto_email', 'operator', - 'content', // CRM-20468 + // CRM-20468 + 'content', ]; $custom = CRM_Core_DAO::executeQuery('SELECT id FROM civicrm_custom_field WHERE html_type = "RichTextEditor"'); while ($custom->fetch()) { diff --git a/CRM/Utils/API/MatchOption.php b/CRM/Utils/API/MatchOption.php index 408dd3b8f4..0f0cdc8170 100644 --- a/CRM/Utils/API/MatchOption.php +++ b/CRM/Utils/API/MatchOption.php @@ -153,7 +153,8 @@ class CRM_Utils_API_MatchOption implements API_Wrapper { if ($isMandatory) { throw new API_Exception("Failed to match existing record"); } - return $createParams; // OK, don't care + // OK, don't care + return $createParams; } elseif ($getResult['count'] == 1) { $item = array_shift($getResult['values']); diff --git a/CRM/Utils/Address/BatchUpdate.php b/CRM/Utils/Address/BatchUpdate.php index 688c8e4237..9b16c0d2f4 100644 --- a/CRM/Utils/Address/BatchUpdate.php +++ b/CRM/Utils/Address/BatchUpdate.php @@ -39,14 +39,14 @@ */ class CRM_Utils_Address_BatchUpdate { - var $start = NULL; - var $end = NULL; - var $geocoding = 1; - var $parse = 1; - var $throttle = 0; + public $start = NULL; + public $end = NULL; + public $geocoding = 1; + public $parse = 1; + public $throttle = 0; - var $returnMessages = []; - var $returnError = 0; + public $returnMessages = []; + public $returnError = 0; /** * Class constructor. @@ -260,16 +260,16 @@ class CRM_Utils_Address_BatchUpdate { $this->returnMessages[] = ts("Addresses Evaluated: %1", [ 1 => $totalAddresses, - ]) . "\n"; + ]) . "\n"; if ($processGeocode) { $this->returnMessages[] = ts("Addresses Geocoded: %1", [ - 1 => $totalGeocoded, - ]) . "\n"; + 1 => $totalGeocoded, + ]) . "\n"; } if ($parseStreetAddress) { $this->returnMessages[] = ts("Street Addresses Parsed: %1", [ - 1 => $totalAddressParsed, - ]) . "\n"; + 1 => $totalAddressParsed, + ]) . "\n"; if ($unparseableContactAddress) { $this->returnMessages[] = "
\n" . ts("Following is the list of contacts whose address is not parsed:") . "
\n"; foreach ($unparseableContactAddress as $contactLink) { diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index b95b9c4be3..4cda076ea3 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -1063,7 +1063,8 @@ class CRM_Utils_Array { (count($keys) == 1 && (current($keys) > 1 || is_string(current($keys)) || - (current($keys) == 1 && $array[1] == 1) // handle (0 => 4), (1 => 1) + // handle (0 => 4), (1 => 1) + (current($keys) == 1 && $array[1] == 1) ) ) ) { diff --git a/CRM/Utils/Cache.php b/CRM/Utils/Cache.php index ee4ac03f36..23975cae4d 100644 --- a/CRM/Utils/Cache.php +++ b/CRM/Utils/Cache.php @@ -251,7 +251,8 @@ class CRM_Utils_Cache { * Ex: 'ArrayCache', 'Memcache', 'Redis'. */ public static function getCacheDriver() { - $className = 'ArrayCache'; // default to ArrayCache for now + // default to ArrayCache for now + $className = 'ArrayCache'; // Maintain backward compatibility for now. // Setting CIVICRM_USE_MEMCACHE or CIVICRM_USE_ARRAYCACHE will diff --git a/CRM/Utils/Cache/APCcache.php b/CRM/Utils/Cache/APCcache.php index e18c06121f..187da7edb8 100644 --- a/CRM/Utils/Cache/APCcache.php +++ b/CRM/Utils/Cache/APCcache.php @@ -32,8 +32,10 @@ */ class CRM_Utils_Cache_APCcache implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; const DEFAULT_TIMEOUT = 3600; const DEFAULT_PREFIX = ''; @@ -123,8 +125,10 @@ class CRM_Utils_Cache_APCcache implements CRM_Utils_Cache_Interface { public function flush() { $allinfo = apc_cache_info('user'); $keys = $allinfo['cache_list']; - $prefix = $this->_prefix; // Our keys follows this pattern: ([A-Za-z0-9_]+)?CRM_[A-Za-z0-9_]+ - $lp = strlen($prefix); // Get prefix length + // Our keys follows this pattern: ([A-Za-z0-9_]+)?CRM_[A-Za-z0-9_]+ + $prefix = $this->_prefix; + // Get prefix length + $lp = strlen($prefix); foreach ($keys as $key) { $name = $key['info']; diff --git a/CRM/Utils/Cache/ArrayCache.php b/CRM/Utils/Cache/ArrayCache.php index 47475326f3..92badc0cda 100644 --- a/CRM/Utils/Cache/ArrayCache.php +++ b/CRM/Utils/Cache/ArrayCache.php @@ -37,12 +37,14 @@ class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface { use CRM_Utils_Cache_NaiveMultipleTrait; - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; const DEFAULT_TIMEOUT = 3600; /** * The cache storage container, an in memory array by default + * @var array */ protected $_cache; diff --git a/CRM/Utils/Cache/ArrayDecorator.php b/CRM/Utils/Cache/ArrayDecorator.php index c9007070c3..86ac79728a 100644 --- a/CRM/Utils/Cache/ArrayDecorator.php +++ b/CRM/Utils/Cache/ArrayDecorator.php @@ -41,7 +41,8 @@ */ class CRM_Utils_Cache_ArrayDecorator implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; /** * @var int diff --git a/CRM/Utils/Cache/FastArrayDecorator.php b/CRM/Utils/Cache/FastArrayDecorator.php index 82ef578d72..d0eb1d2a9e 100644 --- a/CRM/Utils/Cache/FastArrayDecorator.php +++ b/CRM/Utils/Cache/FastArrayDecorator.php @@ -54,7 +54,8 @@ */ class CRM_Utils_Cache_FastArrayDecorator implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; /** * @var int diff --git a/CRM/Utils/Cache/Memcache.php b/CRM/Utils/Cache/Memcache.php index 3e8057c49d..511663792e 100644 --- a/CRM/Utils/Cache/Memcache.php +++ b/CRM/Utils/Cache/Memcache.php @@ -32,7 +32,8 @@ */ class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; const DEFAULT_HOST = 'localhost'; const DEFAULT_PORT = 11211; @@ -163,7 +164,6 @@ class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface { return ($result !== FALSE); } - /** * @param $key * @@ -194,7 +194,8 @@ class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface { $value = $this->_cache->get($key); if ($value === FALSE) { $value = uniqid(); - $this->_cache->set($key, $value, FALSE, 0); // Indefinite. + // Indefinite. + $this->_cache->set($key, $value, FALSE, 0); } $this->_truePrefix = [ 'value' => $value, diff --git a/CRM/Utils/Cache/Memcached.php b/CRM/Utils/Cache/Memcached.php index eeed41cc14..fd3aee39c2 100644 --- a/CRM/Utils/Cache/Memcached.php +++ b/CRM/Utils/Cache/Memcached.php @@ -32,7 +32,8 @@ */ class CRM_Utils_Cache_Memcached implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; const DEFAULT_HOST = 'localhost'; const DEFAULT_PORT = 11211; @@ -227,7 +228,8 @@ class CRM_Utils_Cache_Memcached implements CRM_Utils_Cache_Interface { $maxLen = self::MAX_KEY_LEN - strlen($truePrefix); $key = preg_replace('/\s+|\W+/', '_', $key); if (strlen($key) > $maxLen) { - $md5Key = md5($key); // this should be 32 characters in length + // this should be 32 characters in length + $md5Key = md5($key); $subKeyLen = $maxLen - 1 - strlen($md5Key); $key = substr($key, 0, $subKeyLen) . "_" . $md5Key; } @@ -256,7 +258,8 @@ class CRM_Utils_Cache_Memcached implements CRM_Utils_Cache_Interface { $value = $this->_cache->get($key); if ($this->_cache->getResultCode() === Memcached::RES_NOTFOUND) { $value = uniqid(); - $this->_cache->add($key, $value, 0); // Indefinite. + // Indefinite. + $this->_cache->add($key, $value, 0); } $this->_truePrefix = [ 'value' => $value, diff --git a/CRM/Utils/Cache/NaiveMultipleTrait.php b/CRM/Utils/Cache/NaiveMultipleTrait.php index 16916f2a71..14914d964b 100644 --- a/CRM/Utils/Cache/NaiveMultipleTrait.php +++ b/CRM/Utils/Cache/NaiveMultipleTrait.php @@ -109,6 +109,7 @@ trait CRM_Utils_Cache_NaiveMultipleTrait { } /** + * @param $func * @param $keys * @throws \CRM_Utils_Cache_InvalidArgumentException */ diff --git a/CRM/Utils/Cache/NoCache.php b/CRM/Utils/Cache/NoCache.php index 9d39503782..42921bd7c8 100644 --- a/CRM/Utils/Cache/NoCache.php +++ b/CRM/Utils/Cache/NoCache.php @@ -32,8 +32,10 @@ */ class CRM_Utils_Cache_NoCache implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; /** * We only need one instance of this object. So we use the singleton diff --git a/CRM/Utils/Cache/Redis.php b/CRM/Utils/Cache/Redis.php index 1b64e42881..f7c8435f79 100644 --- a/CRM/Utils/Cache/Redis.php +++ b/CRM/Utils/Cache/Redis.php @@ -34,8 +34,10 @@ */ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; const DEFAULT_HOST = 'localhost'; const DEFAULT_PORT = 6379; @@ -76,7 +78,8 @@ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface { public static function connect($config) { $host = isset($config['host']) ? $config['host'] : self::DEFAULT_HOST; $port = isset($config['port']) ? $config['port'] : self::DEFAULT_PORT; - $pass = CRM_Utils_Constant::value('CIVICRM_DB_CACHE_PASSWORD'); // Ugh. + // Ugh. + $pass = CRM_Utils_Constant::value('CIVICRM_DB_CACHE_PASSWORD'); $id = implode(':', ['connect', $host, $port /* $pass is constant */]); if (!isset(Civi::$statics[__CLASS__][$id])) { // Ideally, we'd track the connection in the service-container, but the diff --git a/CRM/Utils/Cache/SerializeCache.php b/CRM/Utils/Cache/SerializeCache.php index 3b1cf9517e..f17b459107 100644 --- a/CRM/Utils/Cache/SerializeCache.php +++ b/CRM/Utils/Cache/SerializeCache.php @@ -37,10 +37,12 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { use CRM_Utils_Cache_NaiveMultipleTrait; - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; /** * The cache storage container, an array by default, stored in a file under templates + * @var array */ private $_cache; @@ -101,7 +103,8 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { throw new \RuntimeException("FIXME: " . __CLASS__ . "::set() should support non-NULL TTL"); } if (file_exists($this->fileName($key))) { - return FALSE; // WTF, write-once cache?! + // WTF, write-once cache?! + return FALSE; } $this->_cache[$key] = $value; $bytes = file_put_contents($this->fileName($key), "version, '<')) { $updates[] = ts('%1 (%2) version %3 is installed. Upgrade to version %5.', [ - 1 => CRM_Utils_Array::value('label', $row), - 2 => $key, - 3 => $row['version'], - 4 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', "action=update&id=$key&key=$key") . '"', - 5 => $remotes[$key]->version, - ]); + 1 => CRM_Utils_Array::value('label', $row), + 2 => $key, + 3 => $row['version'], + 4 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', "action=update&id=$key&key=$key") . '"', + 5 => $remotes[$key]->version, + ]); } else { if (empty($row['label'])) { @@ -692,7 +692,6 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component { return $messages; } - /** * Checks if there are pending extension upgrades. * diff --git a/CRM/Utils/Check/Component/PriceFields.php b/CRM/Utils/Check/Component/PriceFields.php index 47e325cfe0..4261c95a8d 100644 --- a/CRM/Utils/Check/Component/PriceFields.php +++ b/CRM/Utils/Check/Component/PriceFields.php @@ -53,7 +53,8 @@ class CRM_Utils_Check_Component_PriceFields extends CRM_Utils_Check_Component { $url = CRM_Utils_System::url('civicrm/admin/price/field', [ 'reset' => 1, 'action' => 'browse', - 'sid' => $dao->ps_id]); + 'sid' => $dao->ps_id, + ]); $html .= "$dao->ps_title$dao->psf_labelView Price Set Fields"; } if ($count > 0) { diff --git a/CRM/Utils/Check/Component/Security.php b/CRM/Utils/Check/Component/Security.php index 984bf5fc3a..c0291e50d9 100644 --- a/CRM/Utils/Check/Component/Security.php +++ b/CRM/Utils/Check/Component/Security.php @@ -202,7 +202,6 @@ class CRM_Utils_Check_Component_Security extends CRM_Utils_Check_Component { return $messages; } - /** * Check that some files are not present. * @@ -276,7 +275,6 @@ class CRM_Utils_Check_Component_Security extends CRM_Utils_Check_Component { return $messages; } - /** * Check that the sysadmin has not modified the Cxn * security setup. diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index 913c930a45..24b2f73880 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -763,7 +763,6 @@ class CRM_Utils_Date { } } - /** * @param null $timeStamp * @@ -901,7 +900,7 @@ class CRM_Utils_Date { * @return int * array $results contains years or months */ - static public function calculateAge($birthDate) { + public static function calculateAge($birthDate) { $results = []; $formatedBirthDate = CRM_Utils_Date::customFormat($birthDate, '%Y-%m-%d'); @@ -1858,9 +1857,9 @@ class CRM_Utils_Date { } foreach ([ - 'from', - 'to', - ] as $item) { + 'from', + 'to', + ] as $item) { if (!empty($$item)) { $dateRange[$item] = self::format($$item); } @@ -1961,7 +1960,6 @@ class CRM_Utils_Date { return $field; } - /** * Get the fields required for the 'extra' parameter when adding a datepicker. * @@ -2170,7 +2168,6 @@ class CRM_Utils_Date { return $month; } - /** * Convert a relative date format to an api field. * diff --git a/CRM/Utils/DeprecatedUtils.php b/CRM/Utils/DeprecatedUtils.php index e05a690cd8..9d2d7ca4e0 100644 --- a/CRM/Utils/DeprecatedUtils.php +++ b/CRM/Utils/DeprecatedUtils.php @@ -780,12 +780,12 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { } foreach ([ - 'Phone', - 'Email', - 'IM', - 'OpenID', - 'Phone_Ext', - ] as $block) { + 'Phone', + 'Email', + 'IM', + 'OpenID', + 'Phone_Ext', + ] as $block) { $name = strtolower($block); if (!array_key_exists($name, $values)) { continue; @@ -1063,7 +1063,6 @@ function _civicrm_api3_deprecated_validate_formatted_contact(&$params) { return civicrm_api3_create_success(TRUE); } - /** * @deprecated - this is part of the import parser not the API & needs to be moved on out * diff --git a/CRM/Utils/FakeObject.php b/CRM/Utils/FakeObject.php index d119548e3c..83823708f8 100644 --- a/CRM/Utils/FakeObject.php +++ b/CRM/Utils/FakeObject.php @@ -43,6 +43,7 @@ * @endcode */ class CRM_Utils_FakeObject { + /** * @param $array */ diff --git a/CRM/Utils/File.php b/CRM/Utils/File.php index d9040ffc0f..b51905f714 100644 --- a/CRM/Utils/File.php +++ b/CRM/Utils/File.php @@ -797,7 +797,8 @@ HTACCESS; } } if (empty($childParts)) { - return FALSE; // same directory + // same directory + return FALSE; } else { return TRUE; diff --git a/CRM/Utils/GlobalStack.php b/CRM/Utils/GlobalStack.php index 50bf3c268a..0884e3b134 100644 --- a/CRM/Utils/GlobalStack.php +++ b/CRM/Utils/GlobalStack.php @@ -62,7 +62,7 @@ class CRM_Utils_GlobalStack { * * @return CRM_Utils_GlobalStack */ - static public function singleton() { + public static function singleton() { if (self::$_singleton === NULL) { self::$_singleton = new CRM_Utils_GlobalStack(); } diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index c4c8cd0ae9..8282a89c7c 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -44,10 +44,15 @@ abstract class CRM_Utils_Hook { const SUMMARY_BELOW = 1; // place hook content above const SUMMARY_ABOVE = 2; - // create your own summaries + /** + *create your own summaries + */ const SUMMARY_REPLACE = 3; - static $_nullObject = NULL; + /** + * @var ojbect + */ + public static $_nullObject = NULL; /** * We only need one instance of this object. So we use the singleton @@ -123,7 +128,7 @@ abstract class CRM_Utils_Hook { * * @return mixed */ - public abstract function invokeViaUF( + abstract public function invokeViaUF( $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix @@ -1596,6 +1601,7 @@ abstract class CRM_Utils_Hook { 'civicrm_triggerInfo' ); } + /** * This hook allows changes to the spec of which tables to log. * @@ -1862,7 +1868,7 @@ abstract class CRM_Utils_Hook { } /** - * @param CRM_Core_Exception Exception $exception + * @param CRM_Core_ExceptionObject $exception * @param mixed $request * Reserved for future use. */ @@ -1981,7 +1987,6 @@ abstract class CRM_Utils_Hook { ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge'); } - /** * This hook is called before encoding data in barcode. * @@ -2290,7 +2295,7 @@ abstract class CRM_Utils_Hook { } /** - * @param array $fileSearches + * @param array $fileSearches CRM_Core_FileSearchInterface * @return mixed */ public static function fileSearches(&$fileSearches) { @@ -2426,8 +2431,8 @@ abstract class CRM_Utils_Hook { /** * This hook is called before an inbound SMS is processed. * - * @param CRM_SMS_Message Object $message - * An SMS message recieved + * @param \CRM_SMS_MessageObject $message + * An SMS message received * @return mixed */ public static function inboundSMS(&$message) { @@ -2438,7 +2443,7 @@ abstract class CRM_Utils_Hook { * This hook is called to modify api params of EntityRef form field * * @param array $params - * + * @param string $formName * @return mixed */ public static function alterEntityRefParams(&$params, $formName) { diff --git a/CRM/Utils/Hook/Joomla.php b/CRM/Utils/Hook/Joomla.php index d0448e948b..eb2f7b0c77 100644 --- a/CRM/Utils/Hook/Joomla.php +++ b/CRM/Utils/Hook/Joomla.php @@ -53,6 +53,7 @@ class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook { * * @return mixed */ + /** * @param int $numParams * @param mixed $arg1 diff --git a/CRM/Utils/Hook/Soap.php b/CRM/Utils/Hook/Soap.php index fe6274e617..99e3522d75 100644 --- a/CRM/Utils/Hook/Soap.php +++ b/CRM/Utils/Hook/Soap.php @@ -53,6 +53,7 @@ class CRM_Utils_Hook_Soap extends CRM_Utils_Hook { * * @return mixed */ + /** * @param int $numParams * @param mixed $arg1 diff --git a/CRM/Utils/Hook/UnitTests.php b/CRM/Utils/Hook/UnitTests.php index 39f35eac1a..f5fa1400a9 100644 --- a/CRM/Utils/Hook/UnitTests.php +++ b/CRM/Utils/Hook/UnitTests.php @@ -35,7 +35,7 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook { protected $mockObject; /** - * @var array $adhocHooks to call + * @var array */ protected $adhocHooks; protected $civiModules = NULL; diff --git a/CRM/Utils/Hook/WordPress.php b/CRM/Utils/Hook/WordPress.php index 2b7bc5bd7c..ba032151ba 100644 --- a/CRM/Utils/Hook/WordPress.php +++ b/CRM/Utils/Hook/WordPress.php @@ -160,7 +160,6 @@ class CRM_Utils_Hook_WordPress extends CRM_Utils_Hook { } - /** * Build the list of plugins ("modules" in CiviCRM terminology) to be processed for hooks. * diff --git a/CRM/Utils/JS.php b/CRM/Utils/JS.php index f6d6710e97..95340e36a3 100644 --- a/CRM/Utils/JS.php +++ b/CRM/Utils/JS.php @@ -32,6 +32,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_JS { + /** * Parse a javascript file for translatable strings. * diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index 539b760523..ca7526bf37 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -319,8 +319,8 @@ class CRM_Utils_Mail { */ public 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.', [ - 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:') . '

'; + 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:') . '

'; if (is_a($mailer, 'Mail_smtp')) { $message .= '
    ' . '
  • ' . ts('Your SMTP Username or Password are incorrect.') . '
  • ' . '
  • ' . ts('Your SMTP Server (machine) name is incorrect.') . '
  • ' . '
  • ' . ts('You need to use a Port other than the default port 25 in your environment.') . '
  • ' . '
  • ' . ts('Your SMTP server is just not responding right now (it is down for some reason).') . '
  • '; @@ -330,8 +330,8 @@ class CRM_Utils_Mail { } $message .= '
  • ' . ts('The FROM Email Address configured for this feature may not be a valid sender based on your email service provider rules.') . '
  • ' . '
' . '

' . ts('Check this page for more information.', [ - 1 => CRM_Utils_System::docURL2('user/advanced-configuration/email-system-configuration', TRUE), - ]) . '

'; + 1 => CRM_Utils_System::docURL2('user/advanced-configuration/email-system-configuration', TRUE), + ]) . '

'; return $message; } diff --git a/CRM/Utils/Migrate/Export.php b/CRM/Utils/Migrate/Export.php index c6b372fc15..7497fb962a 100644 --- a/CRM/Utils/Migrate/Export.php +++ b/CRM/Utils/Migrate/Export.php @@ -475,14 +475,14 @@ class CRM_Utils_Migrate_Export { // hack for extends_entity_column_value if ($name == 'extends_entity_column_value') { if (in_array($object->extends, [ - 'Event', - 'Activity', - 'Relationship', - 'Individual', - 'Organization', - 'Household', - 'Case', - ])) { + 'Event', + 'Activity', + 'Relationship', + 'Individual', + 'Organization', + 'Household', + 'Case', + ])) { if ($object->extends == 'Event') { $key = 'event_type'; } diff --git a/CRM/Utils/Migrate/ExportJSON.php b/CRM/Utils/Migrate/ExportJSON.php index b9adff7887..ffaa63065b 100644 --- a/CRM/Utils/Migrate/ExportJSON.php +++ b/CRM/Utils/Migrate/ExportJSON.php @@ -434,9 +434,9 @@ AND entity_table = 'civicrm_contact' $this->appendValue($dao->id, 'civicrm_relationship', $relationship); $this->addAdditionalContacts([ - $dao->contact_id_a, - $dao->contact_id_b, - ], + $dao->contact_id_a, + $dao->contact_id_b, + ], $additionalContacts ); } diff --git a/CRM/Utils/Migrate/Import.php b/CRM/Utils/Migrate/Import.php index 0a25d24bc7..340e10d51a 100644 --- a/CRM/Utils/Migrate/Import.php +++ b/CRM/Utils/Migrate/Import.php @@ -31,6 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_Migrate_Import { + /** * Class constructor. */ diff --git a/CRM/Utils/Money.php b/CRM/Utils/Money.php index 77606d7061..ce15b9995b 100644 --- a/CRM/Utils/Money.php +++ b/CRM/Utils/Money.php @@ -35,7 +35,7 @@ * Money utilties */ class CRM_Utils_Money { - static $_currencySymbols = NULL; + public static $_currencySymbols = NULL; /** * Format a monetary string. @@ -87,9 +87,9 @@ class CRM_Utils_Money { if (!self::$_currencySymbols) { self::$_currencySymbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', [ - 'keyColumn' => 'name', - 'labelColumn' => 'symbol', - ]); + 'keyColumn' => 'name', + 'labelColumn' => 'symbol', + ]); } if (!$currency) { diff --git a/CRM/Utils/Network.php b/CRM/Utils/Network.php index 0564590867..0a256816b0 100644 --- a/CRM/Utils/Network.php +++ b/CRM/Utils/Network.php @@ -34,6 +34,7 @@ * Simple static helpers for network operations */ class CRM_Utils_Network { + /** * Try connecting to a TCP service; if it fails, retry. Repeat until serverStartupTimeOut elapses. * diff --git a/CRM/Utils/Number.php b/CRM/Utils/Number.php index 619c8118d3..02e31ad96a 100644 --- a/CRM/Utils/Number.php +++ b/CRM/Utils/Number.php @@ -34,6 +34,7 @@ * Class CRM_Utils_Number */ class CRM_Utils_Number { + /** * Create a random number with a given precision. * @@ -64,13 +65,16 @@ class CRM_Utils_Number { public static function createTruncatedDecimal($keyValue, $precision) { list ($sigFigs, $decFigs) = $precision; $sign = ($keyValue < 0) ? '-1' : 1; - $val = str_replace('.', '', abs($keyValue)); // ex: -123.456 ==> 123456 - $val = substr($val, 0, $sigFigs); // ex: 123456 => 1234 + // ex: -123.456 ==> 123456 + $val = str_replace('.', '', abs($keyValue)); + // ex: 123456 => 1234 + $val = substr($val, 0, $sigFigs); // Move any extra digits after decimal $extraFigs = strlen($val) - ($sigFigs - $decFigs); if ($extraFigs > 0) { - return $sign * $val / pow(10, $extraFigs); // ex: 1234 => 1.234 + // ex: 1234 => 1.234 + return $sign * $val / pow(10, $extraFigs); } else { return $sign * $val; diff --git a/CRM/Utils/OpenFlashChart.php b/CRM/Utils/OpenFlashChart.php index 9f0b8f2db4..26e34292eb 100644 --- a/CRM/Utils/OpenFlashChart.php +++ b/CRM/Utils/OpenFlashChart.php @@ -470,10 +470,10 @@ class CRM_Utils_OpenFlashChart { // carry some chart params if pass. foreach ([ - 'xSize', - 'ySize', - 'divName', - ] as $f) { + 'xSize', + 'ySize', + 'divName', + ] as $f) { if (!empty($rows[$f])) { $chartData[$f] = $rows[$f]; } @@ -510,10 +510,10 @@ class CRM_Utils_OpenFlashChart { // carry some chart params if pass. foreach ([ - 'xSize', - 'ySize', - 'divName', - ] as $f) { + 'xSize', + 'ySize', + 'divName', + ] as $f) { if (!empty($rows[$f])) { $chartData[$f] = $rows[$f]; } diff --git a/CRM/Utils/PDF/Document.php b/CRM/Utils/PDF/Document.php index 2fa43b4a43..25490c9bb0 100644 --- a/CRM/Utils/PDF/Document.php +++ b/CRM/Utils/PDF/Document.php @@ -124,7 +124,8 @@ class CRM_Utils_PDF_Document { $phpWord = \PhpOffice\PhpWord\IOFactory::load($fileName, $formats[$ext]); } - \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(TRUE); //CRM-20015 + //CRM-20015 + \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(TRUE); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $formats[$ext]); CRM_Utils_System::setHttpHeader('Content-Type', "application/$ext"); @@ -147,7 +148,7 @@ class CRM_Utils_PDF_Document { * @param string $type File type * * @return array - * Return extracted content of document in HTML and document type + * Return extracted content of document in HTML and document type */ public static function docReader($path, $type) { $type = array_search($type, CRM_Core_SelectValues::documentApplicationType()); diff --git a/CRM/Utils/PDF/Label.php b/CRM/Utils/PDF/Label.php index df5f935fb9..1dc7caad17 100644 --- a/CRM/Utils/PDF/Label.php +++ b/CRM/Utils/PDF/Label.php @@ -40,51 +40,120 @@ class CRM_Utils_PDF_Label extends TCPDF { // make these properties public due to // CRM-5880 - // Default label format values + /** + * Default label format values + * @var array + */ public $defaults; - // Current label format values + /** + * Current label format values + * @var array + */ public $format; - // Name of format + /** + * Name of format + * @var string + */ public $formatName; - // Left margin of labels + /** + * Left margin of labels + * @var float + */ public $marginLeft; - // Top margin of labels + /** + * Top margin of labels + * @var float + */ public $marginTop; - // Horizontal space between 2 labels + /** + * Horizontal space between 2 labels + * @var float + */ public $xSpace; - // Vertical space between 2 labels + /** + * Vertical space between 2 labels + * @var float + */ public $ySpace; - // Number of labels horizontally + /** + * Number of labels horizontally + * @var float + */ public $xNumber; - // Number of labels vertically + /** + * Number of labels vertically + * @var float + */ public $yNumber; - // Width of label + /** + * Width of label + * @var float + */ public $width; - // Height of label + /** + * Height of label + * @var float + */ public $height; - // Line Height of label - used in event code + /** + * Line Height of label - used in event code + * @var float + */ public $lineHeight = 0; - // Space between text and left edge of label + /** + * Space between text and left edge of label + * @var float + */ public $paddingLeft; - // Space between text and top edge of label + /** + * Space between text and top edge of label + * @var float + */ public $paddingTop; - // Character size (in points) + /** + * Character size (in points) + * @var float + */ public $charSize; - // Metric used for all PDF doc measurements + /** + * Metric used for all PDF doc measurements + * @var string + */ public $metricDoc; - // Name of the font + /** + * Name of the font + * @var string + */ public $fontName; - // 'B' bold, 'I' italic, 'BI' bold+italic + /** + * 'B' bold, 'I' italic, 'BI' bold+italic + * @var string + */ public $fontStyle; - // Paper size name + /** + * Paper size name + * @var string + */ public $paperSize; - // Paper orientation + /** + * Paper orientation + * @var string + */ public $orientation; - // Paper dimensions array (w, h) + /** + * Paper dimensions array (w, h) + * @var array + */ public $paper_dimensions; - // Counter for positioning labels + /** + * Counter for positioning labels + * @var float + */ public $countX = 0; - // Counter for positioning labels + /** + * Counter for positioning labels + * @var float + */ public $countY = 0; /** diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php index 72c0d6c5bf..7694dc24c7 100644 --- a/CRM/Utils/PDF/Utils.php +++ b/CRM/Utils/PDF/Utils.php @@ -28,6 +28,7 @@ use Dompdf\Dompdf; use Dompdf\Options; + /** * * @package CRM @@ -141,7 +142,8 @@ class CRM_Utils_PDF_Utils { // This function also uses the FPDI library documented at: http://www.setasign.com/products/fpdi/about/ // Syntax borrowed from https://github.com/jake-mw/CDNTaxReceipts/blob/master/cdntaxreceipts.functions.inc require_once 'tcpdf/tcpdf.php'; - require_once 'FPDI/fpdi.php'; // This library is only in the 'packages' area as of version 4.5 + // This library is only in the 'packages' area as of version 4.5 + require_once 'FPDI/fpdi.php'; $paper_size_arr = [$paper_size[2], $paper_size[3]]; diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index 74f8afee2d..390764d766 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -112,13 +112,13 @@ class CRM_Utils_Pager extends Pager_Sliding { * page variable, but a different form element for one at the bottom. */ $this->_response['titleTop'] = ts('Page %1 of %2', [ - 1 => '', - 2 => $this->_response['numPages'], - ]); + 1 => '', + 2 => $this->_response['numPages'], + ]); $this->_response['titleBottom'] = ts('Page %1 of %2', [ - 1 => '', - 2 => $this->_response['numPages'], - ]); + 1 => '', + 2 => $this->_response['numPages'], + ]); } /** diff --git a/CRM/Utils/PseudoConstant.php b/CRM/Utils/PseudoConstant.php index 4ccbdba0de..7a3cf0d547 100644 --- a/CRM/Utils/PseudoConstant.php +++ b/CRM/Utils/PseudoConstant.php @@ -36,6 +36,7 @@ class CRM_Utils_PseudoConstant { /** * CiviCRM pseudoconstant classes for wrapper functions. + * @var array */ private static $constantClasses = [ 'CRM_Core_PseudoConstant', diff --git a/CRM/Utils/QueryFormatter.php b/CRM/Utils/QueryFormatter.php index 863226ea15..9c4b49ee59 100644 --- a/CRM/Utils/QueryFormatter.php +++ b/CRM/Utils/QueryFormatter.php @@ -88,6 +88,9 @@ class CRM_Utils_QueryFormatter { */ const MODE_WILDWORDS_SUFFIX = 'wildwords-suffix'; + /** + * @var \CRM_Utils_QueryFormatter|NULL + */ static protected $singleton; /** @@ -407,8 +410,8 @@ class CRM_Utils_QueryFormatter { } /** - * @param $text - * @bool $quotes + * @param string $text + * @param bool $quotes * @return array */ protected function parseWords($text, $quotes) { diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index 52e7e52964..b1df33aee1 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -35,11 +35,13 @@ class CRM_Utils_REST { /** * Number of seconds we should let a REST process idle + * @var int */ - static $rest_timeout = 0; + public static $rest_timeout = 0; /** * Cache the actual UF Class + * @var string */ public $ufClass; @@ -399,8 +401,10 @@ class CRM_Utils_REST { CRM_Utils_System::setHttpHeader("Status", "404 Not Found"); die("Can't find the requested template file templates/$tpl"); } - if (array_key_exists('id', $_GET)) {// special treatmenent, because it's often used - $smarty->assign('id', (int) $_GET['id']);// an id is always positive + // special treatmenent, because it's often used + if (array_key_exists('id', $_GET)) { + // an id is always positive + $smarty->assign('id', (int) $_GET['id']); } $pos = strpos(implode(array_keys($_GET)), '<'); @@ -480,7 +484,8 @@ class CRM_Utils_REST { $params['check_permissions'] = TRUE; $params['version'] = 3; - $_GET['json'] = $requestParams['json'] = 1; // $requestParams is local-only; this line seems pointless unless there's a side-effect influencing other functions + // $requestParams is local-only; this line seems pointless unless there's a side-effect influencing other functions + $_GET['json'] = $requestParams['json'] = 1; if (!$params['sequential']) { $params['sequential'] = 1; } @@ -597,7 +602,8 @@ class CRM_Utils_REST { if (!empty($q)) { if (count($args) == 2 && $args[1] == 'ping') { CRM_Utils_System::loadBootStrap([], FALSE, FALSE); - return NULL; // this is pretty wonky but maybe there's some reason I can't see + // this is pretty wonky but maybe there's some reason I can't see + return NULL; } if (count($args) != 3) { return self::error('ERROR: Malformed REST path'); diff --git a/CRM/Utils/ReCAPTCHA.php b/CRM/Utils/ReCAPTCHA.php index d1afe457a1..3198043014 100644 --- a/CRM/Utils/ReCAPTCHA.php +++ b/CRM/Utils/ReCAPTCHA.php @@ -62,7 +62,6 @@ class CRM_Utils_ReCAPTCHA { return self::$_singleton; } - /** * Check if reCaptcha settings is avilable to add on form. */ diff --git a/CRM/Utils/Request.php b/CRM/Utils/Request.php index a435d65a7c..2f55cea32c 100644 --- a/CRM/Utils/Request.php +++ b/CRM/Utils/Request.php @@ -146,7 +146,7 @@ class CRM_Utils_Request { * @param array $method - '$_GET', '$_POST' or '$_REQUEST'. * * @return mixed - * The value of the variable + * The value of the variable */ protected static function getValue($name, $method) { if (isset($method[$name])) { @@ -235,7 +235,7 @@ class CRM_Utils_Request { * @param array $attributes * The form attributes array. * - * @return string $value + * @return string * The desired value. */ public static function retrieveComponent($attributes) { diff --git a/CRM/Utils/SQL/BaseParamQuery.php b/CRM/Utils/SQL/BaseParamQuery.php index c2a61422b3..f48d05556c 100644 --- a/CRM/Utils/SQL/BaseParamQuery.php +++ b/CRM/Utils/SQL/BaseParamQuery.php @@ -36,11 +36,20 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess { */ const INTERPOLATE_AUTO = 'auto'; + /** + * @var mixed + */ protected $mode = NULL; + /** + * @var array + */ protected $params = []; - // Public to work-around PHP 5.3 limit. + /** + * Public to work-around PHP 5.3 limit. + * @var bool + */ public $strict = NULL; /** diff --git a/CRM/Utils/SQL/Insert.php b/CRM/Utils/SQL/Insert.php index c06bd601c1..816c89f605 100644 --- a/CRM/Utils/SQL/Insert.php +++ b/CRM/Utils/SQL/Insert.php @@ -36,6 +36,7 @@ class CRM_Utils_SQL_Insert { /** * Array list of column names + * @var array */ private $columns; @@ -62,7 +63,8 @@ class CRM_Utils_SQL_Insert { $row = []; foreach ((array) $dao as $key => $value) { if ($value === 'null') { - $value = NULL; // Blerg!!! + // Blerg!!! + $value = NULL; } // Skip '_foobar' and '{\u00}*_options' and 'N'. if (preg_match('/[a-zA-Z]/', $key{0}) && $key !== 'N') { diff --git a/CRM/Utils/SQL/Select.php b/CRM/Utils/SQL/Select.php index 87190c69d2..bdb892ed4d 100644 --- a/CRM/Utils/SQL/Select.php +++ b/CRM/Utils/SQL/Select.php @@ -389,7 +389,6 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { return $this->insertInto($table, $fields); } - /** * @param array $fields * The fields to fill in the other table (in order). diff --git a/CRM/Utils/SQL/TempTable.php b/CRM/Utils/SQL/TempTable.php index 1cf5d81f78..5433b17c41 100644 --- a/CRM/Utils/SQL/TempTable.php +++ b/CRM/Utils/SQL/TempTable.php @@ -70,7 +70,8 @@ class CRM_Utils_SQL_TempTable { const UTF8 = 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci'; const CATEGORY_LENGTH = 12; const CATEGORY_REGEXP = ';^[a-zA-Z0-9]+$;'; - const ID_LENGTH = 37; // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37 + // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37 + const ID_LENGTH = 37; const ID_REGEXP = ';^[a-zA-Z0-9_]+$;'; const INNODB = 'ENGINE=InnoDB'; const MEMORY = 'ENGINE=MEMORY'; @@ -78,7 +79,12 @@ class CRM_Utils_SQL_TempTable { /** * @var bool */ - protected $durable, $utf8; + protected $durable; + + /** + * @var bool + */ + protected $utf8; protected $category; diff --git a/CRM/Utils/Signer.php b/CRM/Utils/Signer.php index 6e906392aa..6323b8931d 100644 --- a/CRM/Utils/Signer.php +++ b/CRM/Utils/Signer.php @@ -64,10 +64,12 @@ class CRM_Utils_Signer { * Array, fields which should be part of the signature. */ public function __construct($secret, $paramNames) { - sort($paramNames); // ensure consistent serialization of payloads + // ensure consistent serialization of payloads + sort($paramNames); $this->secret = $secret; $this->paramNames = $paramNames; - $this->signDelim = "_"; // chosen to be valid in URLs but not in salt or md5 + // chosen to be valid in URLs but not in salt or md5 + $this->signDelim = "_"; $this->defaultSalt = CRM_Utils_String::createRandom(self::SALT_LEN, CRM_Utils_String::ALPHANUMERIC); } diff --git a/CRM/Utils/SoapServer.php b/CRM/Utils/SoapServer.php index 104436ceee..395cd549eb 100644 --- a/CRM/Utils/SoapServer.php +++ b/CRM/Utils/SoapServer.php @@ -35,11 +35,13 @@ class CRM_Utils_SoapServer { /** * Number of seconds we should let a soap process idle + * @var int */ - static $soap_timeout = 0; + public static $soap_timeout = 0; /** * Cache the actual UF Class + * @var string */ public $ufClass; diff --git a/CRM/Utils/String.php b/CRM/Utils/String.php index d01dd52a00..c740e72a1f 100644 --- a/CRM/Utils/String.php +++ b/CRM/Utils/String.php @@ -625,7 +625,6 @@ class CRM_Utils_String { return str_replace($search, $replace, $string); } - /** * Use HTMLPurifier to clean up a text string and remove any potential * xss attacks. This is primarily used in public facing pages which diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 64c035bde6..1ac8d03d0b 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -54,13 +54,13 @@ */ class CRM_Utils_System { - static $_callbacks = NULL; + public static $_callbacks = NULL; /** * @var string * Page title */ - static $title = ''; + public static $title = ''; /** * Access methods in the appropriate CMS class @@ -103,8 +103,7 @@ class CRM_Utils_System { } } - return - self::url( + return self::url( $path, CRM_Utils_System::getLinksUrl($urlVar, $includeReset, $includeForce), $absolute @@ -688,7 +687,6 @@ class CRM_Utils_System { return $config->userSystem->setMessage($message); } - /** * Determine whether a value is null-ish. * @@ -1168,8 +1166,7 @@ class CRM_Utils_System { * this function, please go and change the code in the install script as well. */ public static function isSSL() { - return - (isset($_SERVER['HTTPS']) && + return (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? TRUE : FALSE; } diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 3f99ae6af9..bf6830d8e4 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -11,44 +11,44 @@ abstract class CRM_Utils_System_Base { * The correct method is to have functions on the UF classes for all UF specific * functions and leave the codebase oblivious to the type of CMS * - * @deprecated * @var bool + * @deprecated * TRUE, if the CMS is Drupal. */ - var $is_drupal = FALSE; + public $is_drupal = FALSE; /** * Deprecated property to check if this is a joomla install. The correct method is to have functions on the UF classes for all UF specific * functions and leave the codebase oblivious to the type of CMS * - * @deprecated * @var bool + * @deprecated * TRUE, if the CMS is Joomla!. */ - var $is_joomla = FALSE; + public $is_joomla = FALSE; /** * deprecated property to check if this is a wordpress install. The correct method is to have functions on the UF classes for all UF specific * functions and leave the codebase oblivious to the type of CMS * - * @deprecated * @var bool + * @deprecated * TRUE, if the CMS is WordPress. */ - var $is_wordpress = FALSE; + public $is_wordpress = FALSE; /** * Does this CMS / UF support a CMS specific logging mechanism? - * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions * @var bool + * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions */ - var $supports_UF_Logging = FALSE; + public $supports_UF_Logging = FALSE; /** * @var bool * TRUE, if the CMS allows CMS forms to be extended by hooks. */ - var $supports_form_extensions = FALSE; + public $supports_form_extensions = FALSE; public function initialize() { if (\CRM_Utils_System::isSSL()) { @@ -56,7 +56,7 @@ abstract class CRM_Utils_System_Base { } } - public abstract function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL); + abstract public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL); /** * Append an additional breadcrumb tag to the existing breadcrumb. @@ -424,7 +424,7 @@ abstract class CRM_Utils_System_Base { * @return string * loginURL for the current CMS */ - public abstract function getLoginURL($destination = ''); + abstract public function getLoginURL($destination = ''); /** * Get the login destination string. @@ -710,7 +710,6 @@ abstract class CRM_Utils_System_Base { } } - /** * Get timezone from CMS. * diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index e9061b5698..75d04ca712 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -40,10 +40,10 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { /** * Does this CMS / UF support a CMS specific logging mechanism? - * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions * @var bool + * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions */ - var $supports_UF_Logging = TRUE; + public $supports_UF_Logging = TRUE; /** */ @@ -266,10 +266,10 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { public function getUserRecordUrl($contactID) { $uid = CRM_Core_BAO_UFMatch::getUFId($contactID); if (CRM_Core_Session::singleton() - ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([ - 'cms:administer users', - 'cms:view user account', - ]) + ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([ + 'cms:administer users', + 'cms:view user account', + ]) ) { return $this->url('user/' . $uid); }; diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 827493037b..f98c794adf 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -35,6 +35,7 @@ * Joomla specific stuff goes here. */ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { + /** * Class constructor. */ @@ -317,8 +318,8 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { global $database; $query = $db->getQuery(TRUE); $query->select($db->quoteName('email')) - ->from($db->quoteName('#__users')) - ->where($db->quoteName('id') . ' = ' . $user->id); + ->from($db->quoteName('#__users')) + ->where($db->quoteName('id') . ' = ' . $user->id); $database->setQuery($query); $user->email = $database->loadResult(); } diff --git a/CRM/Utils/System/Soap.php b/CRM/Utils/System/Soap.php index 4685848434..2edca70da7 100644 --- a/CRM/Utils/System/Soap.php +++ b/CRM/Utils/System/Soap.php @@ -38,9 +38,10 @@ class CRM_Utils_System_Soap extends CRM_Utils_System_Base { /** * UF container variables. + * @var string */ - static $uf = NULL; - static $ufClass = NULL; + public static $uf = NULL; + public static $ufClass = NULL; /** * Given a permission string, check for access requirements diff --git a/CRM/Utils/System/UnitTests.php b/CRM/Utils/System/UnitTests.php index b1344e6723..4882bbdb76 100644 --- a/CRM/Utils/System/UnitTests.php +++ b/CRM/Utils/System/UnitTests.php @@ -37,6 +37,7 @@ * Helper authentication class for unit tests */ class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base { + /** */ public function __construct() { diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 5449099855..a188cff501 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -37,6 +37,7 @@ * WordPress specific stuff goes here */ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { + /** */ public function __construct() { @@ -460,6 +461,9 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { * Optional credentials * - name: string, cms username * - pass: string, cms password + * @param bool $loadUser + * @param bool $throwError + * @param mixed $realPath * * @return bool */ @@ -788,7 +792,7 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { public function getUserRecordUrl($contactID) { $uid = CRM_Core_BAO_UFMatch::getUFId($contactID); if (CRM_Core_Session::singleton() - ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(['cms:administer users']) + ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(['cms:administer users']) ) { return CRM_Core_Config::singleton()->userFrameworkBaseURL . "wp-admin/user-edit.php?user_id=" . $uid; } diff --git a/CRM/Utils/SystemLogger.php b/CRM/Utils/SystemLogger.php index aed0518846..6410588941 100644 --- a/CRM/Utils/SystemLogger.php +++ b/CRM/Utils/SystemLogger.php @@ -31,6 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_SystemLogger extends Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface { + /** * Logs with an arbitrary level. * diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 89d67e0c5b..d9014d7760 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -35,9 +35,9 @@ * Class to abstract token replacement. */ class CRM_Utils_Token { - static $_requiredTokens = NULL; + public static $_requiredTokens = NULL; - static $_tokens = [ + public static $_tokens = [ 'action' => [ 'forward', 'optOut', @@ -88,7 +88,6 @@ class CRM_Utils_Token { 'welcome' => ['group'], ]; - /** * @deprecated * This is used by CiviMail but will be made redundant by FlexMailer. @@ -116,7 +115,7 @@ class CRM_Utils_Token { * The message. * * @return bool|array - * true if all required tokens are found, + * true if all required tokens are found, * else an array of the missing tokens */ public static function requiredTokens(&$str) { @@ -178,7 +177,7 @@ class CRM_Utils_Token { * The token variable. * @param string $value * The value to substitute for the token. - * @param string (reference) $str The string to replace in + * @param string $str (reference) The string to replace in * * @param bool $escapeSmarty * @@ -1260,10 +1259,10 @@ class CRM_Utils_Token { // special case for greeting replacement foreach ([ - 'email_greeting', - 'postal_greeting', - 'addressee', - ] as $val) { + 'email_greeting', + 'postal_greeting', + 'addressee', + ] as $val) { if (!empty($contactDetails[$contactID][$val])) { $contactDetails[$contactID][$val] = $contactDetails[$contactID]["{$val}_display"]; } @@ -1300,8 +1299,8 @@ class CRM_Utils_Token { * contactDetails with hooks swapped out */ public static function getAnonymousTokenDetails($contactIDs = [ - 0, - ], + 0, + ], $returnProperties = NULL, $skipOnHold = TRUE, $skipDeceased = TRUE, @@ -1432,6 +1431,7 @@ class CRM_Utils_Token { * * @param string $tokenString * @param array $contactDetails + * @param array $greetingTokens */ private static function removeNullContactTokens(&$tokenString, $contactDetails, &$greetingTokens) { $greetingTokensOriginal = $greetingTokens; @@ -1477,10 +1477,10 @@ class CRM_Utils_Token { $flattenTokens = []; foreach ([ - 'html', - 'text', - 'subject', - ] as $prop) { + 'html', + 'text', + 'subject', + ] as $prop) { if (!isset($tokens[$prop])) { continue; } @@ -1676,7 +1676,8 @@ class CRM_Utils_Token { public static function replaceContributionTokens($str, &$contribution, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE) { $key = 'contribution'; if (!$knownTokens || !CRM_Utils_Array::value($key, $knownTokens)) { - return $str; //early return + //early return + return $str; } self::_buildContributionTokens(); @@ -1759,9 +1760,9 @@ class CRM_Utils_Token { case 'fee': try { $value = civicrm_api3('membership_type', 'getvalue', [ - 'id' => $membership['membership_type_id'], - 'return' => 'minimum_fee', - ]); + 'id' => $membership['membership_type_id'], + 'return' => 'minimum_fee', + ]); $value = CRM_Utils_Money::format($value, NULL, NULL, TRUE); } catch (CiviCRM_API3_Exception $e) { @@ -1847,7 +1848,7 @@ class CRM_Utils_Token { * @param string $entity * @param bool $usedForTokenWidget * - * @return array $customTokens + * @return array * return custom field tokens in array('custom_N' => 'label') format */ public static function getCustomFieldTokens($entity, $usedForTokenWidget = FALSE) { diff --git a/CRM/Utils/Url.php b/CRM/Utils/Url.php index 314df438d6..4396263aac 100644 --- a/CRM/Utils/Url.php +++ b/CRM/Utils/Url.php @@ -35,7 +35,7 @@ class CRM_Utils_Url { * * @param string $url * - * @return UriInterface + * @return \GuzzleHttp\Psr7\UriInterface */ public static function parseUrl($url) { return new Uri($url); @@ -44,7 +44,7 @@ class CRM_Utils_Url { /** * Unparse url back to a string. * - * @param UriInterface $parsed + * @param \GuzzleHttp\Psr7\UriInterface $parsed * * @return string */ diff --git a/CRM/Utils/Verp.php b/CRM/Utils/Verp.php index 87600a04ef..a9d5140c3c 100644 --- a/CRM/Utils/Verp.php +++ b/CRM/Utils/Verp.php @@ -33,9 +33,11 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_Verp { - /* Mapping of reserved characters to hex codes */ - - static $encodeMap = [ + /** + * Mapping of reserved characters to hex codes + * @var array + */ + public static $encodeMap = [ '+' => '2B', '@' => '40', ':' => '3A', @@ -46,9 +48,11 @@ class CRM_Utils_Verp { ']' => '5D', ]; - /* Mapping of hex codes to reserved characters */ - - static $decodeMap = [ + /** + * Mapping of hex codes to reserved characters + * @var array + */ + public static $decodeMap = [ '40' => '@', '3A' => ':', '25' => '%', diff --git a/CRM/Utils/Weight.php b/CRM/Utils/Weight.php index 5fcc2a8162..3e4add68b7 100644 --- a/CRM/Utils/Weight.php +++ b/CRM/Utils/Weight.php @@ -35,8 +35,9 @@ class CRM_Utils_Weight { * To reduce the size of this patch, we only sign the exploitable fields * which make up "$baseURL" in addOrder() (eg 'filter' or 'dao'). * Less-exploitable fields (eg 'dir') are left unsigned. + * 'id','src','dst','dir' */ - static $SIGNABLE_FIELDS = ['reset', 'dao', 'idName', 'url', 'filter']; // 'id','src','dst','dir' + public static $SIGNABLE_FIELDS = ['reset', 'dao', 'idName', 'url', 'filter']; /** * Correct duplicate weight entries by putting them (duplicate weights) in sequence. diff --git a/CRM/Utils/Wrapper.php b/CRM/Utils/Wrapper.php index 7d17e1028a..df9b8a8f32 100644 --- a/CRM/Utils/Wrapper.php +++ b/CRM/Utils/Wrapper.php @@ -41,6 +41,7 @@ class CRM_Utils_Wrapper { * Simple Controller. * * The controller which will handle the display and processing of this page. + * @var \CRM_Core_Controller_Simple object */ protected $_controller; diff --git a/CRM/Utils/XML.php b/CRM/Utils/XML.php index 7eaa32040e..daaf0a6772 100644 --- a/CRM/Utils/XML.php +++ b/CRM/Utils/XML.php @@ -40,8 +40,10 @@ class CRM_Utils_XML { * (0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE) */ public static function parseFile($file) { - $xml = FALSE; // SimpleXMLElement - $error = FALSE; // string + // SimpleXMLElement + $xml = FALSE; + // string + $error = FALSE; if (!file_exists($file)) { $error = 'File ' . $file . ' does not exist.'; @@ -72,8 +74,10 @@ class CRM_Utils_XML { * (0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE) */ public static function parseString($string) { - $xml = FALSE; // SimpleXMLElement - $error = FALSE; // string + // SimpleXMLElement + $xml = FALSE; + // string + $error = FALSE; $oldLibXMLErrors = libxml_use_internal_errors(); libxml_use_internal_errors(TRUE); diff --git a/CRM/Utils/Zip.php b/CRM/Utils/Zip.php index b0cb93835a..2ef4c7915d 100644 --- a/CRM/Utils/Zip.php +++ b/CRM/Utils/Zip.php @@ -44,7 +44,7 @@ class CRM_Utils_Zip { * @return mixed * FALSE if #root level items !=1; otherwise, the name of base dir */ - static public function findBaseDirName(ZipArchive $zip) { + public static function findBaseDirName(ZipArchive $zip) { $cnt = $zip->numFiles; $base = FALSE; @@ -77,7 +77,7 @@ class CRM_Utils_Zip { * @return array(string) * no trailing / */ - static public function findBaseDirs(ZipArchive $zip) { + public static function findBaseDirs(ZipArchive $zip) { $cnt = $zip->numFiles; $basedirs = []; @@ -101,7 +101,7 @@ class CRM_Utils_Zip { * @return string|bool * Return string or FALSE */ - static public function guessBasedir(ZipArchive $zip, $expected) { + public static function guessBasedir(ZipArchive $zip, $expected) { $candidate = FALSE; $basedirs = CRM_Utils_Zip::findBaseDirs($zip); if (in_array($expected, $basedirs)) { @@ -118,7 +118,6 @@ class CRM_Utils_Zip { } } - /** * An inefficient helper for creating a ZIP file from data in memory. * This is only intended for building temp files for unit-testing. @@ -131,7 +130,7 @@ class CRM_Utils_Zip { * Array, keys are file names and values are file contents. * @return bool */ - static public function createTestZip($zipName, $dirs, $files) { + public static function createTestZip($zipName, $dirs, $files) { $zip = new ZipArchive(); $res = $zip->open($zipName, ZipArchive::CREATE); if ($res === TRUE) { -- 2.25.1