Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/352549 )

Change subject: Make use of Assert::parameterType in TermSqlIndex
......................................................................

Make use of Assert::parameterType in TermSqlIndex

Change-Id: Ib7c5ce41228f14bb14f6ad2884157a453d7d76cf
---
M lib/includes/Store/Sql/TermSqlIndex.php
1 file changed, 3 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/49/352549/1

diff --git a/lib/includes/Store/Sql/TermSqlIndex.php 
b/lib/includes/Store/Sql/TermSqlIndex.php
index f2804e5..e5f0a64 100644
--- a/lib/includes/Store/Sql/TermSqlIndex.php
+++ b/lib/includes/Store/Sql/TermSqlIndex.php
@@ -109,9 +109,7 @@
         */
        public function saveTermsOfEntity( EntityDocument $entity ) {
                $entityId = $entity->getId();
-               if ( $entityId === null ) {
-                       throw new InvalidArgumentException( '$entity must have 
an ID' );
-               }
+               Assert::parameterType( EntityId::class, $entity->getId(), 
'$entity->getId()' );
 
                $this->assertEntityIdFromRightRepository( $entityId );
 
@@ -863,9 +861,7 @@
         * @return TermIndexEntry[]
         */
        public function getLabelConflicts( $entityType, array $labels, array 
$aliases = null ) {
-               if ( !is_string( $entityType ) ) {
-                       throw new InvalidArgumentException( '$entityType must 
be a string' );
-               }
+               Assert::parameterType( 'string', $entityType, '$entityType' );
 
                if ( empty( $labels ) && empty( $aliases ) ) {
                        return array();
@@ -987,9 +983,7 @@
                        $texts = (array)$texts;
 
                        foreach ( $texts as $text ) {
-                               if ( !is_string( $text ) ) {
-                                       throw new InvalidArgumentException( 
'$textsByLanguage must contain string values only' );
-                               }
+                               Assert::parameterType( 'string', $text, '$text' 
);
 
                                foreach ( $types as $type ) {
                                        $criteria[] = new 
TermIndexSearchCriteria( [

-- 
To view, visit https://gerrit.wikimedia.org/r/352549
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7c5ce41228f14bb14f6ad2884157a453d7d76cf
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

Reply via email to