From 05935c2ab14015bd3e2b61e5e3a4f0852313bd99 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Fri, 30 Dec 2022 10:47:09 +0000 Subject: [PATCH] When using @var annotations, ensure type comes first --- CRM/Case/Info.php | 4 ++-- CRM/Core/BAO/File.php | 4 ++-- CRM/Extension/Mapper.php | 2 +- CRM/Extension/MixinLoader.php | 2 +- Civi/CCase/Events.php | 2 +- Civi/Test/CiviEnvBuilder/SqlFileStep.php | 5 ++++- Civi/Test/CiviEnvBuilder/SqlStep.php | 5 ++++- .../CRM/Contact/Form/Search/Custom/FullText.php | 6 +++--- .../CRM/Contribute/Form/Task/PDFLetterCommonTest.php | 6 +++--- tests/phpunit/CiviTest/CiviCaseTestCase.php | 2 +- 10 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CRM/Case/Info.php b/CRM/Case/Info.php index d657e50d4e..5269af7a2d 100644 --- a/CRM/Case/Info.php +++ b/CRM/Case/Info.php @@ -112,7 +112,7 @@ class CRM_Case_Info extends CRM_Core_Component_Info { public function getReferenceCounts($dao) { $result = []; if ($dao instanceof CRM_Core_DAO_OptionValue) { - /** @var $dao CRM_Core_DAO_OptionValue */ + /** @var CRM_Core_DAO_OptionValue $dao */ $activity_type_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name'); if ($activity_type_gid == $dao->option_group_id) { $count = CRM_Case_XMLRepository::singleton() @@ -127,7 +127,7 @@ class CRM_Case_Info extends CRM_Core_Component_Info { } } elseif ($dao instanceof CRM_Contact_DAO_RelationshipType) { - /** @var $dao CRM_Contact_DAO_RelationshipType */ + /** @var CRM_Contact_DAO_RelationshipType $dao */ // Need to look both directions, but no need to translate case role // direction from XML perspective to client-based perspective diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index 5f1bca7f7c..9d8cb0ae30 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -763,15 +763,15 @@ HEREDOC; /** * Get a reference to the file-search service (if one is available). * - * @return CRM_Core_FileSearchInterface|NULL + * @return CRM_Core_FileSearchInterface|null */ public static function getSearchService() { $fileSearches = []; CRM_Utils_Hook::fileSearches($fileSearches); // use the first available search + /** @var CRM_Core_FileSearchInterface $fileSearch */ foreach ($fileSearches as $fileSearch) { - /** @var $fileSearch CRM_Core_FileSearchInterface */ return $fileSearch; } return NULL; diff --git a/CRM/Extension/Mapper.php b/CRM/Extension/Mapper.php index 16a9e19def..87211fc062 100644 --- a/CRM/Extension/Mapper.php +++ b/CRM/Extension/Mapper.php @@ -355,8 +355,8 @@ class CRM_Extension_Mapper { // TODO optimization/caching $urls = []; $urls['civicrm'] = $this->keyToUrl('civicrm'); + /** @var CRM_Core_Module $module */ foreach ($this->getModules() as $module) { - /** @var $module CRM_Core_Module */ if ($module->is_active) { try { $urls[$module->name] = $this->keyToUrl($module->name); diff --git a/CRM/Extension/MixinLoader.php b/CRM/Extension/MixinLoader.php index edb67a0814..272d962d96 100644 --- a/CRM/Extension/MixinLoader.php +++ b/CRM/Extension/MixinLoader.php @@ -64,8 +64,8 @@ class CRM_Extension_MixinLoader { } } + /** @var \CRM_Extension_MixInfo $ext */ foreach ($mixInfos as $ext) { - /** @var \CRM_Extension_MixInfo $ext */ foreach ($ext->mixins as $verExpr) { $doneId = $ext->longName . '::' . $verExpr; if (isset($this->done[$doneId])) { diff --git a/Civi/CCase/Events.php b/Civi/CCase/Events.php index 114875f17e..7d0bea3295 100644 --- a/Civi/CCase/Events.php +++ b/Civi/CCase/Events.php @@ -96,8 +96,8 @@ class Events { public static function delegateToXmlListeners(\Civi\CCase\Event\CaseChangeEvent $event) { $p = new \CRM_Case_XMLProcessor_Process(); $listeners = $p->getListeners($event->analyzer->getCaseType()); + /** @var \Civi\CCase\CaseChangeListener $listener */ foreach ($listeners as $listener) { - /** @var $listener \Civi\CCase\CaseChangeListener */ $listener->onCaseChange($event); } } diff --git a/Civi/Test/CiviEnvBuilder/SqlFileStep.php b/Civi/Test/CiviEnvBuilder/SqlFileStep.php index ffb9ca1b0d..aa6d26e855 100644 --- a/Civi/Test/CiviEnvBuilder/SqlFileStep.php +++ b/Civi/Test/CiviEnvBuilder/SqlFileStep.php @@ -24,8 +24,11 @@ class SqlFileStep implements StepInterface { return is_file($this->file) && is_readable($this->file); } + /** + * @param \CiviEnvBuilder $ctx + * @throws \RuntimeException + */ public function run($ctx) { - /** @var $ctx \CiviEnvBuilder */ if (\Civi\Test::execute(@file_get_contents($this->file)) === FALSE) { throw new \RuntimeException("Cannot load {$this->file}. Aborting."); } diff --git a/Civi/Test/CiviEnvBuilder/SqlStep.php b/Civi/Test/CiviEnvBuilder/SqlStep.php index e892883e03..3055bc65a6 100644 --- a/Civi/Test/CiviEnvBuilder/SqlStep.php +++ b/Civi/Test/CiviEnvBuilder/SqlStep.php @@ -20,8 +20,11 @@ class SqlStep implements StepInterface { return TRUE; } + /** + * @param \CiviEnvBuilder $ctx + * @throws \RuntimeException + */ public function run($ctx) { - /** @var $ctx \CiviEnvBuilder */ if (\Civi\Test::execute($this->sql) === FALSE) { throw new \RuntimeException("Cannot execute: {$this->sql}"); } diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php index 9619ff36c4..f3a9fd78da 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php @@ -231,8 +231,8 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu } public function fillTable() { + /** @var CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery $partialQuery */ foreach ($this->_partialQueries as $partialQuery) { - /** @var $partialQuery CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery */ if (!$this->_table || $this->_table == $partialQuery->getName()) { if ($partialQuery->isActive()) { $result = $partialQuery->fillTempTable($this->_text, $this->_entityIDTableName, $this->_tableName, $this->_limitClause, $this->_limitDetailClause); @@ -301,8 +301,8 @@ WHERE t.table_name = 'Activity' AND // also add a select box to allow the search to be constrained $tables = ['' => ts('All tables')]; + /** @var CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery $partialQuery */ foreach ($this->_partialQueries as $partialQuery) { - /** @var $partialQuery CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery */ if ($partialQuery->isActive()) { $tables[$partialQuery->getName()] = $partialQuery->getLabel(); } @@ -360,8 +360,8 @@ WHERE t.table_name = 'Activity' AND $this->initialize(); $summary = []; + /** @var CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery $partialQuery */ foreach ($this->_partialQueries as $partialQuery) { - /** @var $partialQuery CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery */ $summary[$partialQuery->getName()] = []; } diff --git a/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php b/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php index 456be2e722..a05a40c041 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php @@ -205,7 +205,7 @@ class CRM_Contribute_Form_Task_PDFLetterCommonTest extends CiviUnitTestCase { ]; $contributionId = $this->createContribution(); - /** @var $form CRM_Contribute_Form_Task_PDFLetter */ + /** @var CRM_Contribute_Form_Task_PDFLetter $form */ $form = $this->getFormObject('CRM_Contribute_Form_Task_PDFLetter', $formValues); $form->setContributionIds([$contributionId]); $format = Civi::settings()->get('dateformatFull'); @@ -244,7 +244,7 @@ class CRM_Contribute_Form_Task_PDFLetterCommonTest extends CiviUnitTestCase { 'html_message' => '{contact.display_name}', 'document_type' => 'pdf', ]; - /** @var $form CRM_Contribute_Form_Task_PDFLetter */ + /** @var CRM_Contribute_Form_Task_PDFLetter $form */ $form = $this->getFormObject('CRM_Contribute_Form_Task_PDFLetter', $formValues); $form->setContributionIds([$this->createContribution()]); try { @@ -277,7 +277,7 @@ class CRM_Contribute_Form_Task_PDFLetterCommonTest extends CiviUnitTestCase { $formValues['html_message'] .= "$token : {contribution.$token}\n"; } $formValues['html_message'] .= '{emoji.favourite_emoticon}'; - /** @var $form CRM_Contribute_Form_Task_PDFLetter */ + /** @var CRM_Contribute_Form_Task_PDFLetter $form */ $form = $this->getFormObject('CRM_Contribute_Form_Task_PDFLetter', $formValues); $form->setContributionIds([$this->createContribution(array_merge(['campaign_id' => $tokens['campaign_id:label']], $tokens))]); try { diff --git a/tests/phpunit/CiviTest/CiviCaseTestCase.php b/tests/phpunit/CiviTest/CiviCaseTestCase.php index b23cca88c8..6c58f70c4c 100644 --- a/tests/phpunit/CiviTest/CiviCaseTestCase.php +++ b/tests/phpunit/CiviTest/CiviCaseTestCase.php @@ -96,7 +96,7 @@ class CiviCaseTestCase extends CiviUnitTestCase { $enableResult = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase'); $this->assertTrue($enableResult, 'Cannot enable CiviCase in line ' . __LINE__); - /** @var $hooks \CRM_Utils_Hook_UnitTests */ + /** @var \CRM_Utils_Hook_UnitTests $hooks */ $hooks = \CRM_Utils_Hook::singleton(); $hooks->setHook('civicrm_caseTypes', array($this, 'hook_caseTypes')); \CRM_Case_XMLRepository::singleton(TRUE); -- 2.25.1