@@ -106,17 +106,17 @@ public function __construct(array $params = [])
106106 }
107107
108108 /**
109- * Creates(if not already created) and returns the corresponding Index object
110- *
111- * @param string $schema database name
112- * @param string $table table name
113- * @param string $index_name index name
109+ * Creates (if not already created) and returns the corresponding Index object
114110 *
115111 * @return Index corresponding Index object
116112 */
117- public static function singleton ($ schema , $ table , $ index_name = '' )
118- {
119- self ::loadIndexes ($ table , $ schema );
113+ public static function singleton (
114+ DatabaseInterface $ dbi ,
115+ string $ schema ,
116+ string $ table ,
117+ string $ index_name = ''
118+ ): Index {
119+ self ::loadIndexes ($ dbi , $ table , $ schema );
120120 if (! isset (self ::$ registry [$ schema ][$ table ][$ index_name ])) {
121121 $ index = new Index ();
122122 if (strlen ($ index_name ) > 0 ) {
@@ -133,14 +133,11 @@ public static function singleton($schema, $table, $index_name = '')
133133 /**
134134 * returns an array with all indexes from the given table
135135 *
136- * @param string $table table
137- * @param string $schema schema
138- *
139- * @return Index[] array of indexes
136+ * @return Index[]
140137 */
141- public static function getFromTable ($ table , $ schema )
138+ public static function getFromTable (DatabaseInterface $ dbi , string $ table , string $ schema ): array
142139 {
143- self ::loadIndexes ($ table , $ schema );
140+ self ::loadIndexes ($ dbi , $ table , $ schema );
144141
145142 if (isset (self ::$ registry [$ schema ][$ table ])) {
146143 return self ::$ registry [$ schema ][$ table ];
@@ -161,7 +158,7 @@ public static function getFromTable($table, $schema)
161158 public static function getFromTableByChoice ($ table , $ schema , $ choices = 31 )
162159 {
163160 $ indexes = [];
164- foreach (self ::getFromTable ($ table , $ schema ) as $ index ) {
161+ foreach (self ::getFromTable ($ GLOBALS [ ' dbi ' ], $ table , $ schema ) as $ index ) {
165162 if (($ choices & self ::PRIMARY ) && $ index ->getChoice () === 'PRIMARY ' ) {
166163 $ indexes [] = $ index ;
167164 }
@@ -191,14 +188,11 @@ public static function getFromTableByChoice($table, $schema, $choices = 31)
191188 /**
192189 * return primary if set, false otherwise
193190 *
194- * @param string $table table
195- * @param string $schema schema
196- *
197191 * @return Index|false primary index or false if no one exists
198192 */
199- public static function getPrimary ($ table , $ schema )
193+ public static function getPrimary (DatabaseInterface $ dbi , string $ table , string $ schema )
200194 {
201- self ::loadIndexes ($ table , $ schema );
195+ self ::loadIndexes ($ dbi , $ table , $ schema );
202196
203197 if (isset (self ::$ registry [$ schema ][$ table ]['PRIMARY ' ])) {
204198 return self ::$ registry [$ schema ][$ table ]['PRIMARY ' ];
@@ -209,17 +203,14 @@ public static function getPrimary($table, $schema)
209203
210204 /**
211205 * Load index data for table
212- *
213- * @param string $table table
214- * @param string $schema schema
215206 */
216- private static function loadIndexes ($ table , $ schema ): bool
207+ private static function loadIndexes (DatabaseInterface $ dbi , string $ table , string $ schema ): bool
217208 {
218209 if (isset (self ::$ registry [$ schema ][$ table ])) {
219210 return true ;
220211 }
221212
222- $ _raw_indexes = $ GLOBALS [ ' dbi ' ] ->getTableIndexes ($ schema , $ table );
213+ $ _raw_indexes = $ dbi ->getTableIndexes ($ schema , $ table );
223214 foreach ($ _raw_indexes as $ _each_index ) {
224215 $ _each_index ['Schema ' ] = $ schema ;
225216 $ keyName = $ _each_index ['Key_name ' ];
@@ -471,7 +462,7 @@ public static function getIndexTypes()
471462
472463 public function hasPrimary (): bool
473464 {
474- return (bool ) self ::getPrimary ($ this ->table , $ this ->schema );
465+ return (bool ) self ::getPrimary ($ GLOBALS [ ' dbi ' ], $ this ->table , $ this ->schema );
475466 }
476467
477468 /**
@@ -592,7 +583,7 @@ public function getCompareData()
592583 */
593584 public static function findDuplicates ($ table , $ schema )
594585 {
595- $ indexes = self ::getFromTable ($ table , $ schema );
586+ $ indexes = self ::getFromTable ($ GLOBALS [ ' dbi ' ], $ table , $ schema );
596587
597588 $ output = '' ;
598589
0 commit comments