@@ -46,7 +46,6 @@ class TableChecker extends \XoopsObject
4646 public const CHECKTYPE_UPDATE_REPORT = 2 ; //update and report
4747
4848 /**
49- * @param \XoopsModules\Modulebuilder\Common\TableChecker|null
5049 * @param mixed $mydirname
5150 * @param mixed $checktype
5251 */
@@ -72,7 +71,7 @@ public function processSQL()
7271 if ($ numRows ) {
7372 //table exist
7473 $ this ->result [] = 'Table exist: ' . $ table ;
75- $ ret = $ this ->checkTableFields ($ table , $ tabledef ['fields ' ]);
74+ // $ret = $this->checkTableFields($table, $tabledef['fields']);
7675 } else {
7776 if ($ this ::CHECKTYPE_UPDATE == $ this ->checktype || $ this ::CHECKTYPE_UPDATE_REPORT == $ this ->checktype ) {
7877 // create new table
@@ -92,6 +91,8 @@ public function processSQL()
9291 if (self ::CHECKTYPE_REPORT == $ this ->checktype || self ::CHECKTYPE_UPDATE_REPORT == $ this ->checktype ) {
9392 return $ this ->result ;
9493 }
94+
95+ return [];
9596 }
9697
9798 private function readSQLFile ()
@@ -156,11 +157,9 @@ private function extractKey($line)
156157 {
157158 //todo: split string into single keys
158159 $ needle = '( ' ;
159- $ key_text = \substr ($ line , \strpos ($ line , $ needle, 0 ) + 1 );
160+ $ key_text = \substr ($ line , \strpos ($ line , $ needle ) + 1 );
160161 $ needle = ') ' ;
161- $ key_text = \substr ($ key_text , 0 , \strpos ($ key_text , $ needle , 0 ));
162-
163- return $ key_text ;
162+ return \substr ($ key_text , 0 , \strpos ($ key_text , $ needle ));
164163 }
165164
166165 private function extractField ($ line )
@@ -191,7 +190,7 @@ private function extractField($line)
191190 if (\count ($ params ) > $ counter ) {
192191 if ('default ' == \mb_strtolower ($ params [$ counter ])) {
193192 $ field ['default ' ] = $ params [$ counter ] . ' ' . $ params [$ counter + 1 ];
194- $ counter = $ counter + 2 ;
193+ // $counter = $counter + 2;
195194 }
196195 }
197196
@@ -211,15 +210,15 @@ private function checkTableFields($table, $fields)
211210 $ numRows = $ GLOBALS ['xoopsDB ' ]->getRowsNum ($ check );
212211 if ($ numRows ) {
213212 //field exist
214- $ this ->checkField ($ table , $ field );
213+ $ this ->checkField ($ field );
215214 } else {
216215 if (self ::CHECKTYPE_UPDATE == $ this ->checktype || self ::CHECKTYPE_UPDATE_REPORT == $ this ->checktype ) {
217216 // create new field
218217 $ sql = "ALTER TABLE ` $ table` ADD " . $ field ['sql ' ];
219218 if ('' !== (string )$ field ['after ' ]) {
220219 $ sql .= ' AFTER ` ' . $ field ['after ' ] . '`; ' ;
221220 }
222- if ($ result = $ GLOBALS ['xoopsDB ' ]->queryF ($ sql )) {
221+ if ($ GLOBALS ['xoopsDB ' ]->queryF ($ sql )) {
223222 $ this ->result [] = 'Field added: ' . $ fieldname ;
224223 } else {
225224 \xoops_error ($ GLOBALS ['xoopsDB ' ]->error () . '<br> ' . $ sql );
@@ -234,11 +233,10 @@ private function checkTableFields($table, $fields)
234233 return true ;
235234 }
236235
237- private function checkField ($ table , $ field )
236+ private function checkField ($ field ): void
238237 {
239238 //to be created
240239 $ this ->result [] = 'Field exist: ' . $ field ['name ' ] . ' - no changes ' ;
241240
242- return true ;
243241 }
244242}
0 commit comments