From: Seamus Lee Date: Thu, 11 Apr 2019 01:10:56 +0000 (+1000) Subject: (NFC) Lint additional php files up to the new coder standard X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=683bf89187ea00ea7c6a4d41306ad1fbb4f3cde2;p=civicrm-core.git (NFC) Lint additional php files up to the new coder standard --- diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 64ee29b15d..0051422252 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -38,11 +38,11 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /** * @var string */ - static $_entityTable = NULL; - static $_objectTable = NULL; - static $_operation = NULL; + public static $_entityTable = NULL; + public static $_objectTable = NULL; + public static $_operation = NULL; - static $_fieldKeys = NULL; + public static $_fieldKeys = NULL; /** * Get ACL entity table. diff --git a/CRM/ACL/BAO/Cache.php b/CRM/ACL/BAO/Cache.php index f5ca812269..921adfeaf6 100644 --- a/CRM/ACL/BAO/Cache.php +++ b/CRM/ACL/BAO/Cache.php @@ -36,7 +36,7 @@ */ class CRM_ACL_BAO_Cache extends CRM_ACL_DAO_Cache { - static $_cache = NULL; + public static $_cache = NULL; /** * @param int $id diff --git a/CRM/ACL/BAO/EntityRole.php b/CRM/ACL/BAO/EntityRole.php index a329052b80..8ed2b2e0b8 100644 --- a/CRM/ACL/BAO/EntityRole.php +++ b/CRM/ACL/BAO/EntityRole.php @@ -35,7 +35,7 @@ * Access Control EntityRole. */ class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole { - static $_entityTable = NULL; + public static $_entityTable = NULL; /** * Get entity table. diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index 4413ce82b2..21ad61efbc 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -39,7 +39,7 @@ class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/ACL/Page/ACLBasic.php b/CRM/ACL/Page/ACLBasic.php index 2d03da6c96..e55fb919cd 100644 --- a/CRM/ACL/Page/ACLBasic.php +++ b/CRM/ACL/Page/ACLBasic.php @@ -37,7 +37,7 @@ class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/ACL/Page/EntityRole.php b/CRM/ACL/Page/EntityRole.php index 947e7d78ef..d8e70c555b 100644 --- a/CRM/ACL/Page/EntityRole.php +++ b/CRM/ACL/Page/EntityRole.php @@ -39,7 +39,7 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Badge/Page/Layout.php b/CRM/Badge/Page/Layout.php index da2e4ca1fa..da978c55f7 100644 --- a/CRM/Badge/Page/Layout.php +++ b/CRM/Badge/Page/Layout.php @@ -41,7 +41,7 @@ class CRM_Badge_Page_Layout extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 2b264dd8be..897fcbc6f8 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -462,8 +462,9 @@ AND ( p.is_active = 1 OR p.id IS NULL ) /** * Retrieve the basic contact type associated with given subType. * - * @param array /string $subType contact subType. - * @return array/string of basicTypes. + * @param array|string $subType contact subType. + * @return array|string + * basicTypes. */ public static function getBasicType($subType) { static $_cache = NULL; @@ -664,7 +665,7 @@ WHERE name = %1"; else { $name = self::getBasicType($contactName); if (!$name) { - return; + return NULL; } $value = ['name' => "New $name"]; CRM_Core_BAO_Navigation::retrieve($value, $navinfo); @@ -891,6 +892,7 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause); * Custom group id. * @param array $subtypes * List of subtypes related to which entry is to be removed. + * @param array $subtypesToPreserve * * @return bool */ diff --git a/CRM/Contribute/Page/Premium.php b/CRM/Contribute/Page/Premium.php index eb0c035fa5..25189668ad 100644 --- a/CRM/Contribute/Page/Premium.php +++ b/CRM/Contribute/Page/Premium.php @@ -41,7 +41,7 @@ class CRM_Contribute_Page_Premium extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Widget/Widget.php b/CRM/Widget/Widget.php index 023917a154..dbc4afe80c 100644 --- a/CRM/Widget/Widget.php +++ b/CRM/Widget/Widget.php @@ -11,7 +11,7 @@ */ class CRM_Widget_Widget { - static $_methodTable; + public static $_methodTable; public function initialize() { if (!self::$_methodTable) { diff --git a/Civi.php b/Civi.php index ee6138c984..12b2119b45 100644 --- a/Civi.php +++ b/Civi.php @@ -18,7 +18,7 @@ class Civi { /** * A central location for static variable storage. - * + * @var array * @code * `Civi::$statics[__CLASS__]['foo'] = 'bar'; * @endcode diff --git a/bin/ContributionProcessor.php b/bin/ContributionProcessor.php index 3342fd484c..640b350638 100644 --- a/bin/ContributionProcessor.php +++ b/bin/ContributionProcessor.php @@ -31,7 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CiviContributeProcessor { - static $_paypalParamsMapper = array( + public static $_paypalParamsMapper = array( //category => array(paypal_param => civicrm_field); 'contact' => array( 'salutation' => 'prefix_id', @@ -72,10 +72,13 @@ class CiviContributeProcessor { ), ); - static $_csvParamsMapper = array( - // Note: if csv header is not present in the mapper, header itself - // is considered as a civicrm field. - //category => array(csv_header => civicrm_field); + /** + * Note: if csv header is not present in the mapper, header itself + * is considered as a civicrm field. + * category => array(csv_header => civicrm_field); + * @var array + */ + public static $_csvParamsMapper = array( 'contact' => array( 'first_name' => 'first_name', 'last_name' => 'last_name', diff --git a/bin/cli.class.php b/bin/cli.class.php index 8f6705f2d0..aa609d3080 100644 --- a/bin/cli.class.php +++ b/bin/cli.class.php @@ -39,26 +39,35 @@ */ class civicrm_cli { // required values that must be passed - // via the command line - var $_required_arguments = array('action', 'entity'); - var $_additional_arguments = array(); - var $_entity = NULL; - var $_action = NULL; - var $_output = FALSE; - var $_joblog = FALSE; - var $_semicolon = FALSE; - var $_config; - - // optional arguments - var $_site = 'localhost'; - var $_user = NULL; - var $_password = NULL; + /** + * via the command line + * @var array + */ + public $_required_arguments = array('action', 'entity'); + public $_additional_arguments = array(); + public $_entity = NULL; + public $_action = NULL; + public $_output = FALSE; + public $_joblog = FALSE; + public $_semicolon = FALSE; + public $_config; + + /** + * optional arguments + * @var string + */ + public $_site = 'localhost'; + public $_user = NULL; + public $_password = NULL; // all other arguments populate the parameters - // array that is passed to civicrm_api - var $_params = array('version' => 3); + /** + * array that is passed to civicrm_api + * @var array + */ + public $_params = array('version' => 3); - var $_errors = array(); + public $_errors = array(); /** * @return bool @@ -340,7 +349,7 @@ class civicrm_cli { * the database in a csv file format. */ class civicrm_cli_csv_exporter extends civicrm_cli { - var $separator = ','; + public $separator = ','; /** */ @@ -391,8 +400,8 @@ class civicrm_cli_csv_exporter extends civicrm_cli { * passed to the script. */ class civicrm_cli_csv_file extends civicrm_cli { - var $header; - var $separator = ','; + public $header; + public $separator = ','; /** */ @@ -441,6 +450,7 @@ class civicrm_cli_csv_file extends civicrm_cli { } /* return a params as expected */ + /** * @param $data * @@ -468,6 +478,7 @@ class civicrm_cli_csv_file extends civicrm_cli { * */ class civicrm_cli_csv_importer extends civicrm_cli_csv_file { + /** * @param array $params */ @@ -489,6 +500,7 @@ class civicrm_cli_csv_importer extends civicrm_cli_csv_file { * */ class civicrm_cli_csv_deleter extends civicrm_cli_csv_file { + /** * @param array $params */ diff --git a/civicrm-version.php b/civicrm-version.php index f99d34cad7..2209ab9240 100644 --- a/civicrm-version.php +++ b/civicrm-version.php @@ -64,10 +64,12 @@ namespace _CiviVersion_ { 'administrator/components/com_civicrm/civicrm/civicrm-version.php', ), 'Drupal' => array( - 'modules/system/system.module', // D7 + // D7 + 'modules/system/system.module', ), 'Drupal8' => array( - 'core/core.services.yml', // D8 + // D8 + 'core/core.services.yml', ), 'Backdrop' => array( 'core/modules/layout/layout.module', @@ -112,6 +114,7 @@ namespace _CiviVersion_ { } namespace { + /** * Get the CiviCRM version. * TODO : For now this function is not included in \Civi\Version class so not to break any code @@ -125,4 +128,5 @@ namespace { 'cms' => \_CiviVersion_\Util::findCMS(), ]; } + } diff --git a/install/index.php b/install/index.php index f0aa01eafa..c6cd5c63ba 100644 --- a/install/index.php +++ b/install/index.php @@ -163,7 +163,7 @@ elseif ($installType == 'backdrop') { $object = new CRM_Utils_System_Backdrop(); $cmsPath = $object->cmsRootPath(); $siteDir = getSiteDir($cmsPath, $_SERVER['SCRIPT_FILENAME']); - $alreadyInstalled = file_exists($cmsPath . CIVICRM_DIRECTORY_SEPARATOR . 'civicrm.settings.php'); + $alreadyInstalled = file_exists($cmsPath . CIVICRM_DIRECTORY_SEPARATOR . 'civicrm.settings.php'); } elseif ($installType == 'wordpress') { $cmsPath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'civicrm'; @@ -424,7 +424,10 @@ else { * $description[2] - The test error to show, if it goes wrong */ class InstallRequirements { - var $errors, $warnings, $tests, $conn; + public $errors; + public $warnings; + public $tests; + public $conn; // @see CRM_Upgrade_Form::MINIMUM_THREAD_STACK const MINIMUM_THREAD_STACK = 192; @@ -1170,7 +1173,6 @@ class InstallRequirements { mysqli_query($conn, 'DROP TABLE civicrm_install_temp_table_test'); } - /** * @param $server * @param string $username @@ -1274,7 +1276,8 @@ class InstallRequirements { return; } - $result = mysqli_query($conn, "SHOW VARIABLES LIKE 'thread_stack'"); // bytes => kb + // bytes => kb + $result = mysqli_query($conn, "SHOW VARIABLES LIKE 'thread_stack'"); if (!$result) { $testDetails[2] = ts('Could not get information about the thread_stack of the database.'); $this->error($testDetails); @@ -1519,6 +1522,7 @@ class InstallRequirements { * Class Installer */ class Installer extends InstallRequirements { + /** * @param $server * @param $username @@ -1729,10 +1733,9 @@ class Installer extends InstallRequirements { //change the default language to one chosen if (isset($config['seedLanguage']) && $config['seedLanguage'] != 'en_US') { civicrm_api3('Setting', 'create', array( - 'domain_id' => 'current_domain', - 'lcMessages' => $config['seedLanguage'], - ) - ); + 'domain_id' => 'current_domain', + 'lcMessages' => $config['seedLanguage'], + )); } $output .= ''; diff --git a/sql/GenerateData.php b/sql/GenerateData.php index 5b47295608..13b6c400ea 100644 --- a/sql/GenerateData.php +++ b/sql/GenerateData.php @@ -196,16 +196,23 @@ class CRM_GCD { $this->householdIndividual = array_combine($this->Household, $this->householdIndividual); } - /********************************* + /* * private members - *********************************/ + * + */ - // enum's from database + /** + * enum's from database + * @var array + */ private $preferredCommunicationMethod = array('1', '2', '3', '4', '5'); private $contactType = array('Individual', 'Household', 'Organization'); private $phoneType = array('1', '2', '3', '4'); - // customizable enums (foreign keys) + /** + * customizable enums (foreign keys) + * @var array + */ private $prefix = array( // Female 1 => array( @@ -219,35 +226,56 @@ class CRM_GCD { 4 => 'Dr.', ), ); + /** + * @var array + */ private $suffix = array(1 => 'Jr.', 2 => 'Sr.', 3 => 'II', 4 => 'III'); private $gender = array(1 => 'female', 2 => 'male'); - // store domain id's + /** + * store domain id's + * @var array + */ private $domain = array(); - // store contact id's + /** + * store contact id's + * @var array + */ private $contact = array(); private $Individual = array(); private $Household = array(); private $Organization = array(); // store which contacts have a location entity - // for automatic management of is_primary field + /** + * for automatic management of is_primary field + * @var array + */ private $location = array( 'Email' => array(), 'Phone' => array(), 'Address' => array(), ); - // stores the strict individual id and household id to individual id mapping + /** + * stores the strict individual id and household id to individual id mapping + * @var array + */ private $strictIndividual = array(); private $householdIndividual = array(); private $householdName = array(); - // sample data in xml format + /** + * sample data in xml format + * @var array + */ private $sampleData = array(); - // private vars + /** + * private vars + * @var array + */ private $startCid; private $numIndividual = 0; private $numHousehold = 0; @@ -261,7 +289,7 @@ class CRM_GCD { /********************************* * private methods - ******************************** + * ******************************* * @param int $size * @return string */ diff --git a/sql/GenerateReportData.php b/sql/GenerateReportData.php index a1c55579a3..e50b8ddf46 100644 --- a/sql/GenerateReportData.php +++ b/sql/GenerateReportData.php @@ -33,7 +33,7 @@ * */ -/******************************************************* +/** * This class generates data for the schema located in Contact.sql * * each public method generates data for the concerned table. @@ -74,9 +74,9 @@ * Contact Location = 15% for Households, 10% for Organizations, (75-(15*4))% for Individuals. * (Assumption is that each household contains 4 individuals) * - *******************************************************/ + */ -/******************************************************* +/** * * Note: implication of using of mt_srand(1) in constructor * The data generated will be done in a consistent manner @@ -86,7 +86,7 @@ * to get consistent random numbers then the mt_srand(1) shld * be in each function that adds data to each table. * - *******************************************************/ + */ require_once '../civicrm.config.php'; @@ -117,9 +117,9 @@ require_once 'CRM/Member/DAO/MembershipPayment.php'; */ class CRM_GCD { - /******************************************************* + /** * constants - *******************************************************/ + */ const DATA_FILENAME = "sample_data.xml"; const NUM_DOMAIN = 1; const NUM_CONTACT = 5000; @@ -149,32 +149,47 @@ class CRM_GCD { //const ADD_TO_DB=FALSE; const DEBUG_LEVEL = 1; - /********************************* + /*** * private members - *********************************/ + */ - // enum's from database + /** + * enum's from database + * @var array + */ private $preferredCommunicationMethod = array('1', '2', '3', '4', '5'); private $contactType = array('Individual', 'Household', 'Organization'); private $phoneType = array('1', '2', '3', '4'); - // customizable enums (foreign keys) + /** + * customizable enums (foreign keys) + * @var array + */ private $prefix = array(1 => 'Mrs', 2 => 'Ms', 3 => 'Mr', 4 => 'Dr'); private $suffix = array(1 => 'Jr', 2 => 'Sr'); private $gender = array(1 => 'Female', 2 => 'Male'); private $greetingType = array(1 => 'Dear [first]', 2 => 'Dear [prefix] [first] [last]', 3 => 'Dear [prefix] [last]'); - // store domain id's + /** + * store domain id's + * @var array + */ private $domain = array(); - // store contact id's + /** + * store contact id's + * @var array + */ private $contact = array(); private $individual = array(); private $household = array(); private $organization = array(); - // store names, firstnames, street 1, street2 + /** + * store names, firstnames, street 1, street2 + * @var array + */ private $firstName = array(); private $lastName = array(); private $streetName = array(); @@ -198,14 +213,23 @@ class CRM_GCD { private $degree = array(); private $school = array(); - // stores the strict individual id and household id to individual id mapping + /** + * stores the strict individual id and household id to individual id mapping + * @var array + */ private $strictIndividual = array(); private $householdIndividual = array(); - // sample data in xml format + /** + * sample data in xml format + * @var int + */ private $sampleData = NULL; - // private vars + /** + * private vars + * @var int + */ private $numIndividual = 0; private $numHousehold = 0; private $numOrganization = 0; @@ -234,13 +258,15 @@ class CRM_GCD { 1116 => array('Gdańsk', 'Gdynia'), ), ); - + /** + * @var array + */ private $groupMembershipStatus = array('Added', 'Removed', 'Pending'); private $subscriptionHistoryMethod = array('Admin', 'Email'); - /********************************* + /** * private methods - ******************************** + * * @param int $size * @return string */ @@ -298,8 +324,8 @@ class CRM_GCD { return mt_rand(1, count($array1)); } - // country state city combo + /** * @return array */ @@ -375,8 +401,8 @@ class CRM_GCD { return date($dateFormat, mt_rand($today - $numSecond, $today)); } - // insert data into db's + /** * @param $dao */ @@ -391,6 +417,7 @@ class CRM_GCD { } // update data into db's + /** * @param $dao */ @@ -571,7 +598,6 @@ class CRM_GCD { } } - public function initDB() { $config = CRM_Core_Config::singleton(); } @@ -1213,7 +1239,8 @@ class CRM_GCD { $this->_insert($activityContactDAO); if (in_array($activityTypeID, array( - 6, 9))) { + 6, 9, + ))) { $activityTargetDAO = new CRM_Activity_DAO_ActivityContact(); $activityTargetDAO->activity_id = $activityDAO->id; $activityTargetDAO->contact_id = mt_rand(1, 101); @@ -1703,7 +1730,6 @@ function module_list() { return array(); } - echo ("Starting data generation on " . date("F dS h:i:s A") . "\n"); $obj1 = new CRM_GCD(); $obj1->initID(); diff --git a/xml/GenCode.php b/xml/GenCode.php index 8fef7b0d41..cee7f1475a 100644 --- a/xml/GenCode.php +++ b/xml/GenCode.php @@ -22,7 +22,8 @@ if ($memLimit >= 0 and $memLimit < 536870912) { // Note: When processing all locales, CRM_Core_I18n::singleton() eats a lot of RAM. ini_set('memory_limit', -1); } -date_default_timezone_set('UTC'); // avoid php warnings if timezone is not set - CRM-10844 +// avoid php warnings if timezone is not set - CRM-10844 +date_default_timezone_set('UTC'); define('CIVICRM_UF', 'Drupal'); define('CIVICRM_UF_BASEURL', '/'); @@ -32,14 +33,23 @@ CRM_Core_ClassLoader::singleton()->register(); # TODO: pull these settings from configuration $genCode = new CRM_Core_CodeGen_Main( - '../CRM/Core/DAO/', // $CoreDAOCodePath - '../sql/', // $sqlCodePath - '../', // $phpCodePath - '../templates/', // $tplCodePath - NULL, // IGNORE - @$argv[3], // cms - empty($argv[2]) ? NULL : $argv[2], // db version - empty($argv[1]) ? 'schema/Schema.xml' : $argv[1], // schema file - getenv('CIVICRM_GENCODE_DIGEST') ? getenv('CIVICRM_GENCODE_DIGEST') : NULL // path to digest file + // $CoreDAOCodePath + '../CRM/Core/DAO/', + // $sqlCodePath + '../sql/', + // $phpCodePath + '../', + // $tplCodePath + '../templates/', + // IGNORE + NULL, + // cms + @$argv[3], + // db version + empty($argv[2]) ? NULL : $argv[2], + // schema file + empty($argv[1]) ? 'schema/Schema.xml' : $argv[1], + // path to digest file + getenv('CIVICRM_GENCODE_DIGEST') ? getenv('CIVICRM_GENCODE_DIGEST') : NULL ); $genCode->main(); diff --git a/xml/plugins/block.ts.php b/xml/plugins/block.ts.php index a610ec0901..2522bbba64 100644 --- a/xml/plugins/block.ts.php +++ b/xml/plugins/block.ts.php @@ -1,4 +1,5 @@