Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/191008
Change subject: Fix/enhance PHPDoc tags in TermIndex classes
......................................................................
Fix/enhance PHPDoc tags in TermIndex classes
This is split from I6d83809. This is a pure documentation-only change.
And I'm splitting long lines.
Change-Id: I2bb472ccefe5c2dcf6648685f028ce76c9dc000c
---
M lib/includes/store/TermIndex.php
M lib/includes/store/sql/TermSqlIndex.php
M lib/tests/phpunit/store/MockTermIndex.php
M repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
4 files changed, 92 insertions(+), 43 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/08/191008/1
diff --git a/lib/includes/store/TermIndex.php b/lib/includes/store/TermIndex.php
index 10b9dfb..a7f30d4 100644
--- a/lib/includes/store/TermIndex.php
+++ b/lib/includes/store/TermIndex.php
@@ -48,7 +48,11 @@
*
* @return Term[]
*/
- public function getTermsOfEntity( EntityId $entityId, array $termTypes
= null, array $languageCodes = null );
+ public function getTermsOfEntity(
+ EntityId $entityId,
+ array $termTypes = null,
+ array $languageCodes = null
+ );
/**
* Returns the terms stored for the given entities. Can be filtered by
language.
@@ -64,7 +68,11 @@
*
* @return Term[]
*/
- public function getTermsOfEntities( array $entityIds, array $termTypes
= null, array $languageCodes = null );
+ public function getTermsOfEntities(
+ array $entityIds,
+ array $termTypes = null,
+ array $languageCodes = null
+ );
/**
* Returns the terms that match the provided conditions.
@@ -91,7 +99,12 @@
*
* @return Term[]
*/
- public function getMatchingTerms( array $terms, $termType = null,
$entityType = null, array $options = array() );
+ public function getMatchingTerms(
+ array $terms,
+ $termType = null,
+ $entityType = null,
+ array $options = array()
+ );
/**
* Returns the IDs that match the provided conditions.
diff --git a/lib/includes/store/sql/TermSqlIndex.php
b/lib/includes/store/sql/TermSqlIndex.php
index 123cfe3..f586785 100644
--- a/lib/includes/store/sql/TermSqlIndex.php
+++ b/lib/includes/store/sql/TermSqlIndex.php
@@ -11,6 +11,7 @@
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\LegacyIdInterpreter;
+use Wikibase\DataModel\Term\AliasGroup;
use Wikibase\DataModel\Term\Fingerprint;
use Wikibase\DataModel\Term\FingerprintProvider;
use Wikibase\Lib\Store\LabelConflictFinder;
@@ -91,7 +92,7 @@
*
* @param EntityDocument $entity
*
- * @return boolean Success indicator
+ * @return bool Success indicator
*/
public function saveTermsOfEntity( EntityDocument $entity ) {
wfProfileIn( __METHOD__ );
@@ -140,7 +141,7 @@
* @param Term[] $terms
* @param DatabaseBase $dbw
*
- * @return boolean Success indicator
+ * @return bool Success indicator
*/
public function insertTermsInternal( EntityDocument $entity, $terms,
DatabaseBase $dbw ) {
wfProfileIn( __METHOD__ );
@@ -230,6 +231,7 @@
$terms[] = $term;
}
+ /** @var AliasGroup $aliasGroup */
foreach ( $fingerprint->getAliasGroups() as $aliasGroup ) {
foreach ( $aliasGroup->getAliases() as $alias ) {
$term = new Term( $extraFields );
@@ -257,7 +259,7 @@
* @param Term[] $terms
* @param DatabaseBase $dbw
*
- * @return boolean Success indicator
+ * @return bool Success indicator
*/
public function deleteTermsInternal( EntityId $entityId, $terms,
DatabaseBase $dbw ) {
wfProfileIn( __METHOD__ );
@@ -353,7 +355,7 @@
*
* @param EntityId $entityId
*
- * @return boolean Success indicator
+ * @return bool Success indicator
*/
public function deleteTermsOfEntity( EntityId $entityId ) {
wfProfileIn( __METHOD__ );
@@ -428,7 +430,7 @@
* @param string[]|null $languageCodes
*
* @throws MWException
- * @return array
+ * @return Term[]
*/
private function fetchTerms(
array $entityIds,
@@ -500,7 +502,7 @@
}
/**
- * Returns the Database connection to wich to write.
+ * Returns the Database connection to which to write.
*
* @since 0.4
*
@@ -515,14 +517,19 @@
*
* @since 0.2
*
- * @param array $terms
+ * @param Term[] $terms
* @param string|null $termType
* @param string|null $entityType
* @param array $options
*
* @return Term[]
*/
- public function getMatchingTerms( array $terms, $termType = null,
$entityType = null, array $options = array() ) {
+ public function getMatchingTerms(
+ array $terms,
+ $termType = null,
+ $entityType = null,
+ array $options = array()
+ ) {
if ( empty( $terms ) ) {
return array();
}
@@ -564,7 +571,7 @@
*
* @since 0.4
*
- * @param array $terms
+ * @param Term[] $terms
* @param string $entityType
* @param array $options There is an implicit LIMIT of 5000 items in
this implementation
*
@@ -662,7 +669,13 @@
*
* @return string[]
*/
- private function termsToConditions( DatabaseBase $db, array $terms,
$termType, $entityType, array $options = array() ) {
+ private function termsToConditions(
+ DatabaseBase $db,
+ array $terms,
+ $termType,
+ $entityType,
+ array $options = array()
+ ) {
wfProfileIn( __METHOD__ );
$conditions = array();
@@ -688,7 +701,13 @@
*
* @return array
*/
- protected function termMatchConditions( DatabaseBase $db, Term $term,
$termType, $entityType, array $options = array() ) {
+ protected function termMatchConditions(
+ DatabaseBase $db,
+ Term $term,
+ $termType,
+ $entityType,
+ array $options = array()
+ ) {
wfProfileIn( __METHOD__ );
$options = array_merge(
@@ -797,7 +816,7 @@
*
* @since 0.2
*
- * @return boolean Success indicator
+ * @return bool Success indicator
*/
public function clear() {
$dbw = $this->getConnection( DB_MASTER );
@@ -860,7 +879,11 @@
* @throws InvalidArgumentException
* @return Term[]
*/
- public function getLabelWithDescriptionConflicts( $entityType, array
$labels, array $descriptions ) {
+ public function getLabelWithDescriptionConflicts(
+ $entityType,
+ array $labels,
+ array $descriptions
+ ) {
$labels = array_intersect_key( $labels, $descriptions );
$descriptions = array_intersect_key( $descriptions, $labels );
diff --git a/lib/tests/phpunit/store/MockTermIndex.php
b/lib/tests/phpunit/store/MockTermIndex.php
index a7c1790..4f234eb 100644
--- a/lib/tests/phpunit/store/MockTermIndex.php
+++ b/lib/tests/phpunit/store/MockTermIndex.php
@@ -77,7 +77,11 @@
*
* @return EntityId[]
*/
- public function getLabelWithDescriptionConflicts( $entityType, array
$labels, array $descriptions ) {
+ public function getLabelWithDescriptionConflicts(
+ $entityType,
+ array $labels,
+ array $descriptions
+ ) {
$labels = array_intersect_key( $labels, $descriptions );
$descriptions = array_intersect_key( $descriptions, $labels );
@@ -192,7 +196,11 @@
*
* @return Term[]
*/
- public function getTermsOfEntity( EntityId $entityId, array $termTypes
= null, array $languageCodes = null ) {
+ public function getTermsOfEntity(
+ EntityId $entityId,
+ array $termTypes = null,
+ array $languageCodes = null
+ ) {
$matchingTerms = array();
if ( is_array( $termTypes ) ) {
@@ -226,7 +234,11 @@
*
* @return Term[]
*/
- public function getTermsOfEntities( array $entityIds, array $termTypes
= null, array $languageCodes = null ) {
+ public function getTermsOfEntities(
+ array $entityIds,
+ array $termTypes = null,
+ array $languageCodes = null
+ ) {
$terms = array();
foreach ( $entityIds as $id ) {
@@ -242,7 +254,12 @@
/**
* @throws Exception always
*/
- public function termExists( $termValue, $termType = null, $termLanguage
= null, $entityType = null ) {
+ public function termExists(
+ $termValue,
+ $termType = null,
+ $termLanguage = null,
+ $entityType = null
+ ) {
throw new Exception( 'not implemented by mock class ' );
}
@@ -260,7 +277,12 @@
*
* @return Term[]
*/
- public function getMatchingTerms( array $terms, $termType = null,
$entityType = null, array $options = array() ) {
+ public function getMatchingTerms(
+ array $terms,
+ $termType = null,
+ $entityType = null,
+ array $options = array()
+ ) {
$matchingTerms = array();
$language = $terms[0]->getLanguage();
diff --git a/repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
b/repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
index 5eaa848..ee67490 100644
--- a/repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
+++ b/repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
@@ -56,10 +56,10 @@
/**
* @dataProvider termProvider
- * @param $languageCode
- * @param $termText
- * @param $searchText
- * @param boolean $matches
+ * @param string $languageCode
+ * @param string $termText
+ * @param string $searchText
+ * @param bool $matches
*/
public function testGetMatchingTerms2( $languageCode, $termText,
$searchText, $matches ) {
$withoutTermSearchKey = WikibaseRepo::getDefaultInstance()->
@@ -70,11 +70,9 @@
}
$termIndex = $this->getTermIndex();
-
$termIndex->clear();
$item = new Item( new ItemId( 'Q42' ) );
-
$item->setLabel( $languageCode, $termText );
$termIndex->saveTermsOfEntity( $item );
@@ -181,10 +179,10 @@
/**
* @dataProvider termProvider
- * @param $languageCode
- * @param $termText
- * @param $searchText
- * @param boolean $matches
+ * @param string $languageCode
+ * @param string $termText
+ * @param string $searchText
+ * @param bool $matches
*/
public function testGetMatchingTermsWeights( $languageCode, $termText,
$searchText, $matches ) {
$termIndex = $this->getTermIndex();
@@ -196,14 +194,12 @@
$termIndex->clear();
$item1 = new Item( new ItemId( 'Q42' ) );
-
$item1->setLabel( $languageCode, $termText );
$item1->getSiteLinkList()->addNewSiteLink( 'enwiki', 'A' );
$termIndex->saveTermsOfEntity( $item1 );
$item2 = new Item( new ItemId( 'Q23' ) );
-
$item2->setLabel( $languageCode, $termText );
$item2->getSiteLinkList()->addNewSiteLink( 'enwiki', 'B' );
$item2->getSiteLinkList()->addNewSiteLink( 'dewiki', 'B' );
@@ -213,7 +209,6 @@
$termIndex->saveTermsOfEntity( $item2 );
$item3 = new Item( new ItemId( 'Q108' ) );
-
$item3->setLabel( $languageCode, $termText );
$item3->getSiteLinkList()->addNewSiteLink( 'hrwiki', 'C' );
$item3->getSiteLinkList()->addNewSiteLink( 'uzwiki', 'C' );
@@ -240,18 +235,14 @@
/**
* @dataProvider termProvider
- * @param $languageCode
- * @param $termText
- * @param $searchText
- * @param boolean $matches
+ * @param string $languageCode
+ * @param string $termText
*/
- public function testPrefixSearch( $languageCode, $termText,
$searchText, $matches ) {
+ public function testPrefixSearch( $languageCode, $termText ) {
$termIndex = $this->getTermIndex();
-
$termIndex->clear();
$item1 = new Item( new ItemId( 'Q42' ) );
-
$item1->setLabel( $languageCode, $termText );
$termIndex->saveTermsOfEntity( $item1 );
@@ -272,14 +263,14 @@
/**
* @dataProvider termProvider
+ * @param string $languageCode
+ * @param string $termText
*/
public function testPrefixSearchQuoting( $languageCode, $termText ) {
$termIndex = $this->getTermIndex();
-
$termIndex->clear();
$item1 = new Item( new ItemId( 'Q42' ) );
-
$item1->setLabel( $languageCode, $termText );
$termIndex->saveTermsOfEntity( $item1 );
--
To view, visit https://gerrit.wikimedia.org/r/191008
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2bb472ccefe5c2dcf6648685f028ce76c9dc000c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits