Merge "Handle null data return in HTMLForm"
[lhc/web/wiklou.git] / maintenance / sqlite.inc
index 08188ca..33ca0ff 100644 (file)
@@ -40,26 +40,26 @@ class Sqlite {
         * Checks given files for correctness of SQL syntax. MySQL DDL will be converted to
         * SQLite-compatible during processing.
         * Will throw exceptions on SQL errors
-        * @param $files
+        * @param array|string $files
         * @throws MWException
-        * @return mixed true if no error or error string in case of errors
+        * @return bool True if no error or error string in case of errors
         */
        public static function checkSqlSyntax( $files ) {
                if ( !Sqlite::isPresent() ) {
                        throw new MWException( "Can't check SQL syntax: SQLite not found" );
                }
                if ( !is_array( $files ) ) {
-                       $files = array( $files );
+                       $files = [ $files ];
                }
 
-               $allowedTypes = array_flip( array(
+               $allowedTypes = array_flip( [
                        'integer',
                        'real',
                        'text',
                        'blob', // NULL type is omitted intentionally
-               ) );
+               ] );
 
-               $db = new DatabaseSqliteStandalone( ':memory:' );
+               $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
                try {
                        foreach ( $files as $file ) {
                                $err = $db->sourceFile( $file );
@@ -78,6 +78,7 @@ class Sqlite {
                                foreach ( $columns as $col ) {
                                        if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
                                                $db->close();
+
                                                return "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'";
                                        }
                                }
@@ -86,6 +87,7 @@ class Sqlite {
                        return $e->getMessage();
                }
                $db->close();
+
                return true;
        }
-};
+}