Completed
Push — master ( df3033...0bd286 )
by Damian
02:20
created
code/SQLite3Database.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,6 +183,7 @@  discard block
 block discarded – undo
183 183
      * Gets pragma value.
184 184
      * 
185 185
      * @param string pragma name
186
+     * @param string $pragma
186 187
      * @return string the pragma value
187 188
      */
188 189
     public function getPragma($pragma)
@@ -238,7 +239,7 @@  discard block
 block discarded – undo
238 239
      * for now we use the MySQL implementation with the MATCH()AGAINST() uglily replaced with LIKE
239 240
      * 
240 241
      * @param string $keywords Keywords as a space separated string
241
-     * @return object DataObjectSet of result pages
242
+     * @return PaginatedList DataObjectSet of result pages
242 243
      */
243 244
     public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC",
244 245
         $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
         // Ensure database name is set
98 98
         if (empty($parameters['database'])) {
99
-            $parameters['database'] = 'database' . self::database_extension();
99
+            $parameters['database'] = 'database'.self::database_extension();
100 100
         }
101 101
         $dbName = $parameters['database'];
102 102
         if (!self::is_valid_database_name($dbName)) {
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
         } else {
113 113
             // Ensure path is given
114 114
             if (empty($parameters['path'])) {
115
-                $parameters['path'] = ASSETS_PATH . '/.sqlitedb';
115
+                $parameters['path'] = ASSETS_PATH.'/.sqlitedb';
116 116
             }
117 117
 
118 118
             //assumes that the path to dbname will always be provided:
119
-            $file = $parameters['path'] . '/' . $dbName;
119
+            $file = $parameters['path'].'/'.$dbName;
120 120
             if (!file_exists($parameters['path'])) {
121 121
                 SQLiteDatabaseConfigurationHelper::create_db_dir($parameters['path']);
122 122
                 SQLiteDatabaseConfigurationHelper::secure_db_dir($parameters['path']);
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
             $extraFilters['File'] .= " AND ShowInSearch <> 0";
268 268
         }
269 269
 
270
-        $limit = $start . ", " . (int) $pageLength;
270
+        $limit = $start.", ".(int) $pageLength;
271 271
 
272 272
         $notMatch = $invertedMatch ? "NOT " : "";
273 273
         if ($keywords) {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         $baseClasses = array('SiteTree' => '', 'File' => '');
292 292
         $queries = array();
293 293
         foreach ($classesToSearch as $class) {
294
-            $queries[$class] = DataList::create($class)->where($notMatch . $match[$class] . $extraFilters[$class], "")->dataQuery()->query();
294
+            $queries[$class] = DataList::create($class)->where($notMatch.$match[$class].$extraFilters[$class], "")->dataQuery()->query();
295 295
             $fromArr = $queries[$class]->getFrom();
296 296
             $baseClasses[$class] = reset($fromArr);
297 297
         }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
             $totalCount += $query->unlimitedRowCount();
354 354
         }
355 355
 
356
-        $fullQuery = implode(" UNION ", $querySQLs) . " ORDER BY $sortBy LIMIT $limit";
356
+        $fullQuery = implode(" UNION ", $querySQLs)." ORDER BY $sortBy LIMIT $limit";
357 357
         // Get records
358 358
         $records = $this->preparedQuery($fullQuery, $queryParameters);
359 359
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
                 $comp = 'LIKE';
441 441
             }
442 442
             if ($negate) {
443
-                $comp = 'NOT ' . $comp;
443
+                $comp = 'NOT '.$comp;
444 444
             }
445 445
         }
446 446
 
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
         preg_match_all('/%(.)/', $format, $matches);
457 457
         foreach ($matches[1] as $match) {
458 458
             if (array_search($match, array('Y', 'm', 'd', 'H', 'i', 's', 'U')) === false) {
459
-                user_error('formattedDatetimeClause(): unsupported format character %' . $match, E_USER_WARNING);
459
+                user_error('formattedDatetimeClause(): unsupported format character %'.$match, E_USER_WARNING);
460 460
             }
461 461
         }
462 462
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
             $date = "'$date'";
482 482
         }
483 483
 
484
-        $modifier = empty($modifiers) ? '' : ", '" . implode("', '", $modifiers) . "'";
484
+        $modifier = empty($modifiers) ? '' : ", '".implode("', '", $modifiers)."'";
485 485
         return "strftime('$format', $date$modifier)";
486 486
     }
487 487
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
             $date = "'$date'";
499 499
         }
500 500
 
501
-        $modifier = empty($modifiers) ? '' : ", '" . implode("', '", $modifiers) . "'";
501
+        $modifier = empty($modifiers) ? '' : ", '".implode("', '", $modifiers)."'";
502 502
         return "datetime($date$modifier, '$interval')";
503 503
     }
504 504
 
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
             $date2 = "'$date2'";
527 527
         }
528 528
 
529
-        $modifier1 = empty($modifiers1) ? '' : ", '" . implode("', '", $modifiers1) . "'";
530
-        $modifier2 = empty($modifiers2) ? '' : ", '" . implode("', '", $modifiers2) . "'";
529
+        $modifier1 = empty($modifiers1) ? '' : ", '".implode("', '", $modifiers1)."'";
530
+        $modifier2 = empty($modifiers2) ? '' : ", '".implode("', '", $modifiers2)."'";
531 531
 
532 532
         return "strftime('%s', $date1$modifier1) - strftime('%s', $date2$modifier2)";
533 533
     }
Please login to merge, or discard this patch.
code/SQLite3Query.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function seek($row)
44 44
     {
45 45
         $this->handle->reset();
46
-        $i=0;
46
+        $i = 0;
47 47
         while ($i < $row && $row = @$this->handle->fetchArray()) {
48 48
             $i++;
49 49
         }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function numRecords()
57 57
     {
58
-        $c=0;
58
+        $c = 0;
59 59
         while ($this->handle->fetchArray()) {
60 60
             $c++;
61 61
         }
Please login to merge, or discard this patch.
code/SQLiteDatabaseConfigurationHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                 self::create_db_dir($databaseConfig['path']);
27 27
                 self::secure_db_dir($databaseConfig['path']);
28 28
             }
29
-            $file = $databaseConfig['path'] . '/' . $databaseConfig['database'];
29
+            $file = $databaseConfig['path'].'/'.$databaseConfig['database'];
30 30
             $conn = null;
31 31
         
32 32
             switch ($databaseConfig['type']) {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     public static function secure_db_dir($path)
214 214
     {
215
-        return (is_writeable($path)) ? file_put_contents($path . '/.htaccess', 'deny from all') : false;
215
+        return (is_writeable($path)) ? file_put_contents($path.'/.htaccess', 'deny from all') : false;
216 216
     }
217 217
     
218 218
     public function requireDatabaseAlterPermissions($databaseConfig)
Please login to merge, or discard this patch.
code/SQLite3SchemaManager.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
          
45 45
         // If using file based database ensure any existing file is removed
46 46
         $parameters = $this->database->getParameters();
47
-        $fullpath = $parameters['path'] . '/' . $name;
47
+        $fullpath = $parameters['path'].'/'.$name;
48 48
         if (is_writable($fullpath)) {
49 49
             unlink($fullpath);
50 50
         }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     public function alterField($tableName, $fieldName, $fieldSpec)
243 243
     {
244 244
         $oldFieldList = $this->fieldList($tableName);
245
-        $fieldNameList = '"' . implode('","', array_keys($oldFieldList)) . '"';
245
+        $fieldNameList = '"'.implode('","', array_keys($oldFieldList)).'"';
246 246
 
247 247
         if (!empty($_REQUEST['avoidConflict']) && Director::isDev()) {
248 248
             $fieldSpec = preg_replace('/\snot null\s/i', ' NOT NULL ON CONFLICT REPLACE ', $fieldSpec);
@@ -256,12 +256,12 @@  discard block
 block discarded – undo
256 256
         // Update field spec
257 257
         $newColsSpec = array();
258 258
         foreach ($oldFieldList as $name => $oldSpec) {
259
-            $newColsSpec[] = "\"$name\" " . ($name == $fieldName ? $fieldSpec : $oldSpec);
259
+            $newColsSpec[] = "\"$name\" ".($name == $fieldName ? $fieldSpec : $oldSpec);
260 260
         }
261 261
 
262 262
         $queries = array(
263 263
             "BEGIN TRANSACTION",
264
-            "CREATE TABLE \"{$tableName}_alterfield_{$fieldName}\"(" . implode(',', $newColsSpec) . ")",
264
+            "CREATE TABLE \"{$tableName}_alterfield_{$fieldName}\"(".implode(',', $newColsSpec).")",
265 265
             "INSERT INTO \"{$tableName}_alterfield_{$fieldName}\" SELECT {$fieldNameList} FROM \"$tableName\"",
266 266
             "DROP TABLE \"$tableName\"",
267 267
             "ALTER TABLE \"{$tableName}_alterfield_{$fieldName}\" RENAME TO \"$tableName\"",
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
         $oldCols = array();
296 296
         $newColsSpec = array();
297 297
         foreach ($oldFieldList as $name => $spec) {
298
-            $oldCols[] = "\"$name\"" . (($name == $oldName) ? " AS $newName" : '');
299
-            $newColsSpec[] = "\"" . (($name == $oldName) ? $newName : $name) . "\" $spec";
298
+            $oldCols[] = "\"$name\"".(($name == $oldName) ? " AS $newName" : '');
299
+            $newColsSpec[] = "\"".(($name == $oldName) ? $newName : $name)."\" $spec";
300 300
         }
301 301
 
302 302
         // SQLite doesn't support direct renames through ALTER TABLE
303 303
         $queries = array(
304 304
             "BEGIN TRANSACTION",
305
-            "CREATE TABLE \"{$tableName}_renamefield_{$oldName}\" (" . implode(',', $newColsSpec) . ")",
306
-            "INSERT INTO \"{$tableName}_renamefield_{$oldName}\" SELECT " . implode(',', $oldCols) . " FROM \"$tableName\"",
305
+            "CREATE TABLE \"{$tableName}_renamefield_{$oldName}\" (".implode(',', $newColsSpec).")",
306
+            "INSERT INTO \"{$tableName}_renamefield_{$oldName}\" SELECT ".implode(',', $oldCols)." FROM \"$tableName\"",
307 307
             "DROP TABLE \"$tableName\"",
308 308
             "ALTER TABLE \"{$tableName}_renamefield_{$oldName}\" RENAME TO \"$tableName\"",
309 309
             "COMMIT"
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
      */
456 456
     public function boolean($values)
457 457
     {
458
-        $default = empty($values['default']) ? 0 : (int)$values['default'];
458
+        $default = empty($values['default']) ? 0 : (int) $values['default'];
459 459
         return "BOOL NOT NULL DEFAULT $default";
460 460
     }
461 461
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      */
500 500
     public function enum($values)
501 501
     {
502
-        $tablefield = $values['table'] . '.' . $values['name'];
502
+        $tablefield = $values['table'].'.'.$values['name'];
503 503
         $enumValues = implode(',', $values['enums']);
504 504
         
505 505
         // Ensure the cache table exists
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
      */
570 570
     public function int($values, $asDbValue = false)
571 571
     {
572
-        return "INTEGER({$values['precision']}) " . strtoupper($values['null']) . " DEFAULT " . (int)$values['default'];
572
+        return "INTEGER({$values['precision']}) ".strtoupper($values['null'])." DEFAULT ".(int) $values['default'];
573 573
     }
574 574
 
575 575
     /**
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 
645 645
     public function hasTable($tableName)
646 646
     {
647
-        return (bool)$this->preparedQuery(
647
+        return (bool) $this->preparedQuery(
648 648
             'SELECT name FROM sqlite_master WHERE type = ? AND name = ?',
649 649
             array('table', $tableName)
650 650
         )->first();
Please login to merge, or discard this patch.
code/SQLite3QueryBuilder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             $rowParts[] = implode(', ', $parts);
50 50
         }
51 51
         $columnSQL = implode(', ', $columns);
52
-        $sql = "INSERT INTO {$into}{$nl}($columnSQL){$nl}SELECT " . implode("{$nl}UNION ALL SELECT ", $rowParts);
52
+        $sql = "INSERT INTO {$into}{$nl}($columnSQL){$nl}SELECT ".implode("{$nl}UNION ALL SELECT ", $rowParts);
53 53
         
54 54
         return $sql;
55 55
     }
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
         }
73 73
 
74 74
         // For literal values return this as the limit SQL
75
-        if (! is_array($limit)) {
75
+        if (!is_array($limit)) {
76 76
             return "{$nl}LIMIT $limit";
77 77
         }
78 78
 
79 79
         // Assert that the array version provides the 'limit' key
80
-        if (! array_key_exists('limit', $limit) || ($limit['limit'] !== null && ! is_numeric($limit['limit']))) {
80
+        if (!array_key_exists('limit', $limit) || ($limit['limit'] !== null && !is_numeric($limit['limit']))) {
81 81
             throw new InvalidArgumentException(
82
-                'SQLite3QueryBuilder::buildLimitSQL(): Wrong format for $limit: '. var_export($limit, true)
82
+                'SQLite3QueryBuilder::buildLimitSQL(): Wrong format for $limit: '.var_export($limit, true)
83 83
             );
84 84
         }
85 85
 
Please login to merge, or discard this patch.