[MediaWiki-commits] [Gerrit] Update LabelDescriptionDuplicateDetector documentation - change (mediawiki...Wikibase)
jenkins-bot has submitted this change and it was merged. Change subject: Update LabelDescriptionDuplicateDetector documentation .. Update LabelDescriptionDuplicateDetector documentation ... and remove an unused parameter. This patch is not important, obviously. I think it's better to merge most other patches first. I will rebase this later. Change-Id: If45845564cace68d83daae6d3d4f446aa86fadf6 --- M repo/includes/LabelDescriptionDuplicateDetector.php 1 file changed, 25 insertions(+), 26 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/LabelDescriptionDuplicateDetector.php b/repo/includes/LabelDescriptionDuplicateDetector.php index 26260ef..9b4b060 100644 --- a/repo/includes/LabelDescriptionDuplicateDetector.php +++ b/repo/includes/LabelDescriptionDuplicateDetector.php @@ -72,9 +72,9 @@ * * @since 0.5 * -* @param array $labels An associative array of labels, +* @param string[] $labels An associative array of labels, *with language codes as the keys. -* @param array|null $descriptions An associative array of descriptions, +* @param string[]|null $descriptions An associative array of descriptions, *with language codes as the keys. * @param EntityId $entityId The Id of the Entity the terms come from. Conflicts *with this entity will be considered self-conflicts and ignored. @@ -86,7 +86,7 @@ * The error code will be either 'label-conflict' or 'label-with-description-conflict', * depending on whether descriptions where given. */ - public function detectTermConflicts( $labels, $descriptions, EntityId $entityId = null ) { + public function detectTermConflicts( array $labels, $descriptions, EntityId $entityId = null ) { if ( !is_array( $labels ) ) { throw new InvalidArgumentException( '$labels must be an array' ); } @@ -100,7 +100,7 @@ } if ( $descriptions === null ) { - $termSpecs = $this->buildLabelConflictSpecs( $labels, $descriptions ); + $termSpecs = $this->buildLabelConflictSpecs( $labels ); $errorCode = 'label-conflict'; } else { $termSpecs = $this->buildLabelDescriptionConflictSpecs( $labels, $descriptions ); @@ -122,31 +122,31 @@ * of label and description for a given language. This applies only for languages for * which both label and description are given in $terms. * -* @param array|null $labels An associative array of labels, +* @param string[] $labels An associative array of labels, *with language codes as the keys. -* @param array|null $descriptions An associative array of descriptions, +* @param string[] $descriptions An associative array of descriptions, *with language codes as the keys. * -* @return array An array suitable for use with TermIndex::getMatchingTermCombination(). +* @return array[] An array suitable for use with TermIndex::getMatchingTermCombination(). */ private function buildLabelDescriptionConflictSpecs( array $labels, array $descriptions ) { $termSpecs = array(); - foreach ( $labels as $lang => $label ) { - if ( !isset( $descriptions[$lang] ) ) { + foreach ( $labels as $languageCode => $label ) { + if ( !isset( $descriptions[$languageCode] ) ) { // If there's no description, there will be no conflict continue; } $label = new Term( array( - 'termLanguage' => $lang, + 'termLanguage' => $languageCode, 'termText' => $label, 'termType' => Term::TYPE_LABEL, ) ); $description = new Term( array( - 'termLanguage' => $lang, - 'termText' => $descriptions[$lang], + 'termLanguage' => $languageCode, + 'termText' => $descriptions[$languageCode], 'termType' => Term::TYPE_DESCRIPTION, ) ); @@ -160,19 +160,17 @@ * Builds a term spec array suitable for finding entities with any of the given labels * for a given language. * -* @param array $labels An associative array mapping language codes to -*records. Reach record is an associative array with
[MediaWiki-commits] [Gerrit] Update LabelDescriptionDuplicateDetector documentation - change (mediawiki...Wikibase)
Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/133693 Change subject: Update LabelDescriptionDuplicateDetector documentation .. Update LabelDescriptionDuplicateDetector documentation ... and remove an unused parameter. This patch is not important, obviously. I think it's better to merge most other patches first. I will rebase this later. Change-Id: If45845564cace68d83daae6d3d4f446aa86fadf6 --- M repo/includes/LabelDescriptionDuplicateDetector.php 1 file changed, 25 insertions(+), 26 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/93/133693/1 diff --git a/repo/includes/LabelDescriptionDuplicateDetector.php b/repo/includes/LabelDescriptionDuplicateDetector.php index 26260ef..9b4b060 100644 --- a/repo/includes/LabelDescriptionDuplicateDetector.php +++ b/repo/includes/LabelDescriptionDuplicateDetector.php @@ -72,9 +72,9 @@ * * @since 0.5 * -* @param array $labels An associative array of labels, +* @param string[] $labels An associative array of labels, *with language codes as the keys. -* @param array|null $descriptions An associative array of descriptions, +* @param string[]|null $descriptions An associative array of descriptions, *with language codes as the keys. * @param EntityId $entityId The Id of the Entity the terms come from. Conflicts *with this entity will be considered self-conflicts and ignored. @@ -86,7 +86,7 @@ * The error code will be either 'label-conflict' or 'label-with-description-conflict', * depending on whether descriptions where given. */ - public function detectTermConflicts( $labels, $descriptions, EntityId $entityId = null ) { + public function detectTermConflicts( array $labels, $descriptions, EntityId $entityId = null ) { if ( !is_array( $labels ) ) { throw new InvalidArgumentException( '$labels must be an array' ); } @@ -100,7 +100,7 @@ } if ( $descriptions === null ) { - $termSpecs = $this->buildLabelConflictSpecs( $labels, $descriptions ); + $termSpecs = $this->buildLabelConflictSpecs( $labels ); $errorCode = 'label-conflict'; } else { $termSpecs = $this->buildLabelDescriptionConflictSpecs( $labels, $descriptions ); @@ -122,31 +122,31 @@ * of label and description for a given language. This applies only for languages for * which both label and description are given in $terms. * -* @param array|null $labels An associative array of labels, +* @param string[] $labels An associative array of labels, *with language codes as the keys. -* @param array|null $descriptions An associative array of descriptions, +* @param string[] $descriptions An associative array of descriptions, *with language codes as the keys. * -* @return array An array suitable for use with TermIndex::getMatchingTermCombination(). +* @return array[] An array suitable for use with TermIndex::getMatchingTermCombination(). */ private function buildLabelDescriptionConflictSpecs( array $labels, array $descriptions ) { $termSpecs = array(); - foreach ( $labels as $lang => $label ) { - if ( !isset( $descriptions[$lang] ) ) { + foreach ( $labels as $languageCode => $label ) { + if ( !isset( $descriptions[$languageCode] ) ) { // If there's no description, there will be no conflict continue; } $label = new Term( array( - 'termLanguage' => $lang, + 'termLanguage' => $languageCode, 'termText' => $label, 'termType' => Term::TYPE_LABEL, ) ); $description = new Term( array( - 'termLanguage' => $lang, - 'termText' => $descriptions[$lang], + 'termLanguage' => $languageCode, + 'termText' => $descriptions[$languageCode], 'termType' => Term::TYPE_DESCRIPTION, ) ); @@ -160,19 +160,17 @@ * Builds a term spec array suitable for finding entities with any of the given labels * for a given language. * -* @param array $labels An associative array mapping language codes to -