@@ -73,8 +73,8 @@ class Index
7373 */
7474 private $ comment = '' ;
7575
76- /** @var int 0 if the index cannot contain duplicates, 1 if it can. */
77- private $ nonUnique = 0 ;
76+ /** @var bool false if the index cannot contain duplicates, true if it can. */
77+ private bool $ nonUnique = false ;
7878
7979 /**
8080 * Indicates how the key is packed. NULL if it is not.
@@ -317,7 +317,7 @@ public function set(array $params): void
317317 }
318318
319319 if (isset ($ params ['Non_unique ' ])) {
320- $ this ->nonUnique = $ params ['Non_unique ' ];
320+ $ this ->nonUnique = ( bool ) $ params ['Non_unique ' ];
321321 }
322322
323323 if (isset ($ params ['Packed ' ])) {
@@ -334,7 +334,7 @@ public function set(array $params): void
334334 } elseif ($ this ->type === 'SPATIAL ' ) {
335335 $ this ->choice = 'SPATIAL ' ;
336336 $ this ->type = '' ;
337- } elseif ($ this ->nonUnique == ' 0 ' ) {
337+ } elseif (! $ this ->nonUnique ) {
338338 $ this ->choice = 'UNIQUE ' ;
339339 } else {
340340 $ this ->choice = 'INDEX ' ;
@@ -480,11 +480,11 @@ public function isPacked()
480480 }
481481
482482 /**
483- * Returns integer 0 if the index cannot contain duplicates, 1 if it can
483+ * Returns bool false if the index cannot contain duplicates, true if it can
484484 *
485- * @return int 0 if the index cannot contain duplicates, 1 if it can
485+ * @return bool false if the index cannot contain duplicates, true if it can
486486 */
487- public function getNonUnique ()
487+ public function getNonUnique (): bool
488488 {
489489 return $ this ->nonUnique ;
490490 }
@@ -494,23 +494,15 @@ public function getNonUnique()
494494 *
495495 * @param bool $as_text whether to output should be in text
496496 *
497- * @return mixed whether the index is a 'Unique' index
497+ * @return string|bool whether the index is a 'Unique' index
498498 */
499- public function isUnique ($ as_text = false )
499+ public function isUnique ($ as_text = false ): string | bool
500500 {
501501 if ($ as_text ) {
502- $ r = [
503- '0 ' => __ ('Yes ' ),
504- '1 ' => __ ('No ' ),
505- ];
506- } else {
507- $ r = [
508- '0 ' => true ,
509- '1 ' => false ,
510- ];
502+ return $ this ->nonUnique ? __ ('No ' ) : __ ('Yes ' );
511503 }
512504
513- return $ r [ $ this ->nonUnique ] ;
505+ return ! $ this ->nonUnique ;
514506 }
515507
516508 /**
0 commit comments