Passed
Push — master ( 1d0b38...a8ee20 )
by Nicolaas
11:41 queued 13s
created
src/Admin/SearchAdmin.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
                 _t(__CLASS__ . '.ReplaceToggle', 'Replace with ... (optional - make a backup first!)'),
91 91
                 [
92 92
                     (new CheckboxField('ApplyReplace', 'Run replace (please make sure to make a backup first!)', $this->applyReplace))
93
-                      ->setDescription('Check this to replace the searched value set above with its replacement value. Note that searches ignore uppercase / lowercase, but replace actions will only search and replace values with the same upper / lowercase.'),
93
+                        ->setDescription('Check this to replace the searched value set above with its replacement value. Note that searches ignore uppercase / lowercase, but replace actions will only search and replace values with the same upper / lowercase.'),
94 94
                     (new TextField('ReplaceWith', 'Replace (optional - careful!)', $this->replace ?? ''))
95 95
                         ->setAttribute('placeholder', 'e.g. contract - make sure to also tick checkbox below'),
96 96
                 ]
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 
58 58
     protected function init()
59 59
     {
60
-        if($this->request->param('Action')) {
61
-            if(empty($this->request->postVars())) {
60
+        if ($this->request->param('Action')) {
61
+            if (empty($this->request->postVars())) {
62 62
                 $this->redirect('/admin/find');
63 63
             }
64 64
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
         if (!$this->getRequest()->requestVar('Keywords')) {
113 113
             $lastResults = $this->lastSearchResults();
114
-            if($lastResults) {
114
+            if ($lastResults) {
115 115
                 $resultsTitle = 'Last Results';
116 116
             } else {
117 117
                 $resultsTitle = 'Last Edited';
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
         Environment::increaseTimeLimitTo(300);
182 182
         Environment::setMemoryLimitMax(-1);
183 183
         Environment::increaseMemoryLimitTo(-1);
184
-        if(empty($this->rawData)) {
184
+        if (empty($this->rawData)) {
185 185
             $lastResults = $this->lastSearchResults();
186
-            if($lastResults) {
186
+            if ($lastResults) {
187 187
                 return $lastResults;
188 188
             }
189 189
         }
@@ -208,18 +208,18 @@  discard block
 block discarded – undo
208 208
             ->setWordsAsString($this->keywords)
209 209
             ->getLinks()
210 210
         ;
211
-        if($results->count() === 1) {
211
+        if ($results->count() === 1) {
212 212
             $result = $results->first();
213
-            if($result->HasCMSEditLink) {
213
+            if ($result->HasCMSEditLink) {
214 214
                 // files do not re-redirect nicely...
215
-                if(!in_array(File::class, ClassInfo::ancestry($result->ClassName), true)) {
215
+                if (!in_array(File::class, ClassInfo::ancestry($result->ClassName), true)) {
216 216
                     $this->redirect($result->CMSEditLink());
217 217
                 }
218 218
             }
219 219
         }
220 220
         // Accessing the session
221 221
         $session = $this->getRequest()->getSession();
222
-        if($session) {
222
+        if ($session) {
223 223
             $session->set('QuickSearchLastResults', serialize($results->toArray()));
224 224
         }
225 225
         return $results;
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
     {
251 251
         // Accessing the session
252 252
         $session = $this->getRequest()->getSession();
253
-        if($this->quickSearchType) {
253
+        if ($this->quickSearchType) {
254 254
             $session->set('QuickSearchType', $this->quickSearchType);
255
-        } elseif($session) {
255
+        } elseif ($session) {
256 256
             $this->quickSearchType = $session->get('QuickSearchType');
257
-            if(isset($_GET['flush'])) {
257
+            if (isset($_GET['flush'])) {
258 258
                 $this->quickSearchType = '';
259 259
                 $session->set('QuickSearchType', '');
260 260
             }
261 261
         }
262
-        if(!$this->quickSearchType) {
262
+        if (!$this->quickSearchType) {
263 263
             $this->quickSearchType = $this->Config()->get('default_quick_search_type');
264 264
         }
265 265
         return (string) $this->quickSearchType;
@@ -269,15 +269,15 @@  discard block
 block discarded – undo
269 269
     {
270 270
         // Accessing the session
271 271
         $session = $this->getRequest()->getSession();
272
-        if($session) {
273
-            if(isset($_GET['flush'])) {
272
+        if ($session) {
273
+            if (isset($_GET['flush'])) {
274 274
                 $session->clear('QuickSearchLastResults');
275 275
             } else {
276 276
                 $data = $session->get('QuickSearchLastResults');
277
-                if($data) {
277
+                if ($data) {
278 278
                     $array = unserialize($data);
279 279
                     $al = ArrayList::create();
280
-                    foreach($array as $item) {
280
+                    foreach ($array as $item) {
281 281
                         $al->push($item);
282 282
                     }
283 283
                     return $al;
Please login to merge, or discard this patch.
src/QuickSearches/QuickSearchBaseClass.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@
 block discarded – undo
52 52
             'limited' => 'Limited search',
53 53
         ];
54 54
         $availableSearchClasses = self::available_quick_searches();
55
-        if(!empty($availableSearchClasses) > 0) {
56
-            foreach($availableSearchClasses as $availableSearchClass) {
55
+        if (!empty($availableSearchClasses) > 0) {
56
+            foreach ($availableSearchClasses as $availableSearchClass) {
57 57
                 $singleton = Injector::inst()->get($availableSearchClass);
58
-                if($singleton->isEnabled()) {
58
+                if ($singleton->isEnabled()) {
59 59
                     $array[$availableSearchClass] = $singleton->getTitle();
60 60
                 }
61 61
             }
Please login to merge, or discard this patch.
src/Helpers/FindClassesAndFields.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
     public static function inst(string $baseClass)
89 89
     {
90
-        if(self::$singleton === null) {
90
+        if (self::$singleton === null) {
91 91
             self::$singleton = Injector::inst()->get(static::class);
92 92
         }
93 93
         self::$singleton->setBaseClass($baseClass);
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
         foreach ($this->cache['AllValidFields'][$className] as $name => $type) {
129 129
             if ($this->isValidFieldType($type, $className, $name)) {
130 130
                 $array[] = $name;
131
-            } elseif(in_array($name, $includedFields, true)) {
131
+            } elseif (in_array($name, $includedFields, true)) {
132 132
                 $array[] = $name;
133 133
             }
134 134
         }
135
-        if(isset($includedClassFieldCombos[$className])) {
136
-            foreach($includedClassFieldCombos[$className] as $name) {
135
+        if (isset($includedClassFieldCombos[$className])) {
136
+            foreach ($includedClassFieldCombos[$className] as $name) {
137 137
                 $array[] = $name;
138 138
             }
139 139
         }
Please login to merge, or discard this patch.
src/Api/SearchApi.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 
113 113
     public function setQuickSearchType(string $nameOrType): SearchApi
114 114
     {
115
-        if($nameOrType === 'all') {
115
+        if ($nameOrType === 'all') {
116 116
             $this->isQuickSearch = false;
117 117
             $this->quickSearchType = '';
118
-        } elseif($nameOrType === 'limited') {
118
+        } elseif ($nameOrType === 'limited') {
119 119
             $this->isQuickSearch = true;
120 120
             $this->quickSearchType = '';
121
-        } elseif(class_exists($nameOrType)) {
121
+        } elseif (class_exists($nameOrType)) {
122 122
             $this->quickSearchType = $nameOrType;
123 123
             $object = Injector::inst()->get($nameOrType);
124 124
             $this->setIncludedClasses($object->getClassesToSearch());
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function setBaseClass(string $class): SearchApi
151 151
     {
152
-        if(class_exists($class)) {
152
+        if (class_exists($class)) {
153 153
             $this->baseClass = $class;
154 154
         }
155 155
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
     public function buildCache(?string $word = ''): SearchApi
226 226
     {
227
-        if($this->cacheHasBeenBuilt !== $word) {
227
+        if ($this->cacheHasBeenBuilt !== $word) {
228 228
             $this->getLinksInner($word);
229 229
             $this->cacheHasBeenBuilt = $word;
230 230
         }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     public function doReplacement(string $word, string $replace): int
256 256
     {
257 257
         $count = 0;
258
-        if($word) {
258
+        if ($word) {
259 259
             $this->buildCache($word);
260 260
             $replace = $this->securityCheckInput($replace);
261 261
             foreach ($this->objects as $item) {
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                 if ($item->canEdit()) {
264 264
                     $fields = $this->getAllValidFields($className);
265 265
                     foreach ($fields as $field) {
266
-                        if(!$this->includeFieldTest($className, $field)) {
266
+                        if (!$this->includeFieldTest($className, $field)) {
267 267
                             continue;
268 268
                         }
269 269
                         $new = str_replace($word, $replace, $item->{$field});
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
         $this->workOutInclusionsAndExclusions();
329 329
 
330 330
         // important to do this first
331
-        if($word) {
331
+        if ($word) {
332 332
             $this->setWordsAsString($word);
333 333
         }
334 334
         $this->workOutWordsForSearching();
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         if (count($this->words)) {
342 342
             foreach ($this->getAllDataObjects() as $className) {
343 343
 
344
-                if(!$this->includeClassTest($className)) {
344
+                if (!$this->includeClassTest($className)) {
345 345
                     continue;
346 346
                 }
347 347
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                 $fields = $this->getAllValidFields($className);
350 350
                 $filterAny = [];
351 351
                 foreach ($fields as $field) {
352
-                    if(!$this->includeFieldTest($className, $field)) {
352
+                    if (!$this->includeFieldTest($className, $field)) {
353 353
                         continue;
354 354
                     }
355 355
                     $filterAny[$field . ':PartialMatch'] = $this->words;
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                         DB::alteration_message(' ... Filter: ' . implode(', ', array_keys($filterAny)));
364 364
                     }
365 365
                     $defaultList = $this->getDefaultList($className);
366
-                    if(empty($defaultList)) {
366
+                    if (empty($defaultList)) {
367 367
                         $array[$className] = $className::get();
368 368
                     }
369 369
                     $array[$className] = $array[$className]->filter(['ClassName' => $className]);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
         $array = [];
407 407
         $classNames = $this->getAllDataObjects();
408 408
         foreach ($classNames as $className) {
409
-            if($this->includeClassTest($className)) {
409
+            if ($this->includeClassTest($className)) {
410 410
                 $array[$className] = $className::get()
411 411
                     ->filter('LastEdited:GreaterThan', date('Y-m-d H:i:s', $threshold))
412 412
                     ->sort(['LastEdited' => 'DESC'])
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
                         ->limit($limit)
455 455
                     ;
456 456
                     foreach ($items as $item) {
457
-                        if(isset($fullListCheck[$item->ClassName][$item->ID])) {
457
+                        if (isset($fullListCheck[$item->ClassName][$item->ID])) {
458 458
                             continue;
459 459
                         }
460 460
                         if ($item->canView()) {
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
         $items = $this->turnArrayIntoObjects($matches);
489 489
         foreach ($items as $item) {
490
-            if($item->canView()) {
490
+            if ($item->canView()) {
491 491
                 $link = $finder->getLink($item, $this->excludedClasses);
492 492
                 $cmsEditLink = $item->canEdit() ? $finder->getCMSEditLink($item) : '';
493 493
                 $list->push(
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         }
512 512
         $finder->saveCache();
513 513
 
514
-        if(!empty($this->sortOverride)) {
514
+        if (!empty($this->sortOverride)) {
515 515
             return $list->sort($this->sortOverride);
516 516
         } else {
517 517
             return $list->sort(['SiteWideSearchSortValue' => 'ASC']);
@@ -664,13 +664,13 @@  discard block
 block discarded – undo
664 664
 
665 665
     protected function includeClassTest(string $className): bool
666 666
     {
667
-        if(count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) {
667
+        if (count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) {
668 668
             if ($this->debug) {
669 669
                 DB::alteration_message(' ... Skipping as not included ' . $className);
670 670
             }
671 671
             return false;
672 672
         }
673
-        if(count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) {
673
+        if (count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) {
674 674
             if ($this->debug) {
675 675
                 DB::alteration_message(' ... Skipping as excluded ' . $className);
676 676
             }
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
 
686 686
     protected function includeFieldTest(string $className, string $field): bool
687 687
     {
688
-        if(isset($this->includedClassFieldCombos[$className][$field])) {
688
+        if (isset($this->includedClassFieldCombos[$className][$field])) {
689 689
             return true;
690
-        } elseif(count($this->includedFields)) {
690
+        } elseif (count($this->includedFields)) {
691 691
             return in_array($field, $this->includedFields, true);
692 692
         } elseif (count($this->excludedFields)) {
693 693
             return in_array($field, $this->includedFields, true) ? false : true;
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
     protected function includeSubClasses(array $classes): array
700 700
     {
701 701
         $toAdd = [];
702
-        foreach($classes as $class) {
702
+        foreach ($classes as $class) {
703 703
             $toAdd = array_merge($toAdd, ClassInfo::subclassesFor($class, false));
704 704
         }
705 705
         return array_unique(array_merge($classes, $toAdd));
Please login to merge, or discard this patch.
src/Helpers/FindEditableObjects.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
 
247 247
             if (!isset($this->relationTypesCovered[$relType])) {
248 248
                 $rels = null;
249
-                if($dataObject->hasMethod($relationName)) {
249
+                if ($dataObject->hasMethod($relationName)) {
250 250
                     $rels = $dataObject->{$relationName}();
251 251
                 } else {
252 252
                     user_error('Relation ' . print_r($relationName, 1) . ' does not exist on ' . $dataObject->ClassName . ' Relations are: ' . print_r($this->getRelations($dataObject), 1), E_USER_NOTICE);
253 253
                 }
254 254
                 if ($rels) {
255 255
                     if ($rels instanceof DataList) {
256
-                        if(!$rels instanceof UnsavedRelationList) {
256
+                        if (!$rels instanceof UnsavedRelationList) {
257 257
                             $rels = $rels->first();
258 258
                         }
259 259
                     }
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
      */
309 309
     protected function classCanBeIncluded(string $dataObjectClassName): bool
310 310
     {
311
-        if(count($this->excludedClasses)) {
312
-            if(!class_exists($dataObjectClassName)) {
311
+        if (count($this->excludedClasses)) {
312
+            if (!class_exists($dataObjectClassName)) {
313 313
                 return false;
314 314
             }
315 315
             return !in_array($dataObjectClassName, $this->excludedClasses, true);
Please login to merge, or discard this patch.