Passed
Push — master ( 3ce8fa...d0cec0 )
by Nicolaas
04:01
created
src/Helpers/FindEditableObjects.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                     $outcome = null;
214 214
                     if ($dataObject->hasMethod($validMethod)) {
215 215
                         $outcome = $dataObject->{$validMethod}();
216
-                    } elseif (! empty($dataObject->{$validMethod})) {
216
+                    } elseif (!empty($dataObject->{$validMethod})) {
217 217
                         $outcome = $dataObject->{$validMethod};
218 218
                     }
219 219
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
                 continue;
244 244
             }
245 245
 
246
-            if (! isset($this->relationTypesCovered[$relType])) {
246
+            if (!isset($this->relationTypesCovered[$relType])) {
247 247
                 $rels = null;
248 248
                 if ($dataObject->hasMethod($relationName)) {
249 249
                     $rels = $dataObject->{$relationName}();
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                     user_error('Relation ' . print_r($relationName, 1) . ' does not exist on ' . $dataObject->ClassName . ' Relations are: ' . print_r($this->getRelations($dataObject), 1), E_USER_NOTICE);
252 252
                 }
253 253
                 if ($rels) {
254
-                    if ($rels instanceof DataList && ! $rels instanceof UnsavedRelationList) {
254
+                    if ($rels instanceof DataList && !$rels instanceof UnsavedRelationList) {
255 255
                         $rels = $rels->first();
256 256
                     }
257 257
                     if ($rels && $rels instanceof DataObject && $rels->exists()) {
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
     protected function getRelations($dataObject): array
272 272
     {
273
-        if (! isset($this->cache['rels'][$dataObject->ClassName])) {
273
+        if (!isset($this->cache['rels'][$dataObject->ClassName])) {
274 274
             $this->cache['rels'][$dataObject->ClassName] = array_merge(
275 275
                 Config::inst()->get($dataObject->ClassName, 'belongs_to'),
276 276
                 Config::inst()->get($dataObject->ClassName, 'has_one'),
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                 Config::inst()->get($dataObject->ClassName, 'many_many')
280 280
             );
281 281
             foreach ($this->cache['rels'][$dataObject->ClassName] as $key => $value) {
282
-                if (! (is_string($value) && class_exists($value) && $this->classCanBeIncluded($value))) {
282
+                if (!(is_string($value) && class_exists($value) && $this->classCanBeIncluded($value))) {
283 283
                     unset($this->cache['rels'][$dataObject->ClassName][$key]);
284 284
                 }
285 285
             }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 
291 291
     protected function getValidMethods(string $type): array
292 292
     {
293
-        if (! isset($this->cache['validMethods'][$type])) {
293
+        if (!isset($this->cache['validMethods'][$type])) {
294 294
             $this->cache['validMethods'][$type] = $this->Config()->get($type);
295 295
         }
296 296
 
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
     protected function classCanBeIncluded(string $dataObjectClassName): bool
304 304
     {
305 305
         if (count($this->excludedClasses) > 0) {
306
-            if (! class_exists($dataObjectClassName)) {
306
+            if (!class_exists($dataObjectClassName)) {
307 307
                 return false;
308 308
             }
309
-            return ! in_array($dataObjectClassName, $this->excludedClasses, true);
309
+            return !in_array($dataObjectClassName, $this->excludedClasses, true);
310 310
         }
311 311
         user_error('Please set excludedClasses', E_USER_NOTICE);
312 312
         return false;
Please login to merge, or discard this patch.
src/Admin/SearchAdmin.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             )->setHeadingLevel(4)
104 104
         );
105 105
 
106
-        if (! $this->getRequest()->requestVar('Keywords')) {
106
+        if (!$this->getRequest()->requestVar('Keywords')) {
107 107
             $lastResults = $this->lastSearchResults();
108 108
             $resultsTitle = $lastResults instanceof \SilverStripe\ORM\ArrayList ? 'Last Results' : 'Last Edited';
109 109
             $this->listHTML = $this->renderWith(self::class . '_Results');
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         if ($results->count() === 1) {
202 202
             $result = $results->first();
203 203
             // files do not re-redirect nicely...
204
-            if ($result->HasCMSEditLink && $result->CMSEditLink && ! in_array(File::class, ClassInfo::ancestry($result->ClassName), true)) {
204
+            if ($result->HasCMSEditLink && $result->CMSEditLink && !in_array(File::class, ClassInfo::ancestry($result->ClassName), true)) {
205 205
                 // this is a variable, not a method!
206 206
                 $this->redirect($result->CMSEditLink);
207 207
             }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
     protected function workOutBoolean(string $fieldName, ?array $data = null, ?bool $default = false): bool
218 218
     {
219
-        return (bool) (isset($data['IsSubmitHiddenField']) ? ! empty($data[$fieldName]) : $default);
219
+        return (bool) (isset($data['IsSubmitHiddenField']) ? !empty($data[$fieldName]) : $default);
220 220
     }
221 221
 
222 222
     protected function workOutString(string $fieldName, ?array $data = null, ?string $default = ''): string
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                 $session->set('QuickSearchType', '');
249 249
             }
250 250
         }
251
-        if (! $this->quickSearchType) {
251
+        if (!$this->quickSearchType) {
252 252
             $this->quickSearchType = $this->Config()->get('default_quick_search_type');
253 253
         }
254 254
         return (string) $this->quickSearchType;
Please login to merge, or discard this patch.
src/Helpers/FindClassesAndFields.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
     public function getAllDataObjects(): array
103 103
     {
104
-        if (! isset($this->cache['AllDataObjects'][$this->baseClass])) {
104
+        if (!isset($this->cache['AllDataObjects'][$this->baseClass])) {
105 105
             $this->cache['AllDataObjects'][$this->baseClass] = array_values(
106 106
                 ClassInfo::subclassesFor($this->baseClass, false)
107 107
             );
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
     public function getAllValidFields(string $className, ?bool $isQuickSearch = false, ?array $includedFields = [], ?array $includedClassFieldCombos = []): array
115 115
     {
116
-        if (! isset($this->cache['AllValidFields'][$className])) {
116
+        if (!isset($this->cache['AllValidFields'][$className])) {
117 117
             $this->cache['AllValidFields'][$className] = Config::inst()->get($className, 'db') ?? [];
118 118
             $this->cache['AllValidFields'][$className] = array_merge(
119 119
                 $this->cache['AllValidFields'][$className],
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
     protected function getAllIndexedFields(string $className, array $dbFields): array
150 150
     {
151
-        if (! isset($this->cache['AllIndexedFields'][$className])) {
151
+        if (!isset($this->cache['AllIndexedFields'][$className])) {
152 152
             $this->cache['AllIndexedFields'][$className] = [];
153 153
             $indexes = Config::inst()->get($className, 'indexes');
154 154
             if (is_array($indexes)) {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                                 }
172 172
                             }
173 173
                         }
174
-                    } elseif(isset($dbFields[$key])) {
174
+                    } elseif (isset($dbFields[$key])) {
175 175
                         $this->cache['AllIndexedFields'][$className][$key] = $key;
176 176
                     }
177 177
                 }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     protected function isValidFieldType(string $type, string $className, string $fieldName): bool
188 188
     {
189
-        if (! isset($this->cache['AllValidFieldTypes'][$type])) {
189
+        if (!isset($this->cache['AllValidFieldTypes'][$type])) {
190 190
             $this->cache['AllValidFieldTypes'][$type] = false;
191 191
             $singleton = Injector::inst()->get($className);
192 192
             $field = $singleton->dbObject($fieldName);
Please login to merge, or discard this patch.
src/QuickSearches/QuickSearchBaseClass.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
             'limited' => 'Quick search (limited search)',
71 71
         ];
72 72
         $availableSearchClasses = self::available_quick_searches();
73
-        if (! empty($availableSearchClasses) > 0) {
73
+        if (!empty($availableSearchClasses) > 0) {
74 74
             foreach ($availableSearchClasses as $availableSearchClass) {
75 75
                 $singleton = Injector::inst()->get($availableSearchClass);
76 76
                 if ($singleton->isEnabled()) {
Please login to merge, or discard this patch.
src/Tasks/SiteWideSearch.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
         Environment::increaseMemoryLimitTo(-1);
26 26
         $debug = $request->postVar('debug') ? 'checked="checked"' : '';
27 27
         $word = $request->requestVar('word');
28
-        if (! is_string($word)) {
28
+        if (!is_string($word)) {
29 29
             $word = '';
30 30
         }
31 31
 
32 32
         $replace = trim($request->requestVar('replace'));
33
-        if (! is_string($replace)) {
33
+        if (!is_string($replace)) {
34 34
             $replace = '';
35 35
         }
36 36
 
Please login to merge, or discard this patch.
src/Api/SearchApi.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
     public function setBypassCanMethods(bool $b): SearchApi
172 172
     {
173
-        if (! Director::is_cli()) {
173
+        if (!Director::is_cli()) {
174 174
             user_error('setBypassCanMethods() is only available in CLI mode. Use with caution as it will bypass all canView() and canEdit() checks.', E_USER_WARNING);
175 175
         } else {
176 176
             $this->bypassCanMethods = $b;
@@ -301,13 +301,13 @@  discard block
 block discarded – undo
301 301
                     $className = $item->ClassName;
302 302
                     $fields = $this->getAllValidFields($className);
303 303
                     foreach ($fields as $field) {
304
-                        if (! $item->{$field} || ! is_string($item->{$field})) {
304
+                        if (!$item->{$field} || !is_string($item->{$field})) {
305 305
                             continue;
306 306
                         }
307 307
                         if (strpos($item->{$field}, $word) === false) {
308 308
                             continue;
309 309
                         }
310
-                        if (! $this->includeFieldTest($className, $field)) {
310
+                        if (!$this->includeFieldTest($className, $field)) {
311 311
                             continue;
312 312
                         }
313 313
                         if ($type === 'url') {
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                         if ($this->showReplacements) {
329 329
                             DB::alteration_message(
330 330
                                 '.... .... ' . $dryRunNote .
331
-                                    $item->ClassName . '.' .  $item->ID .
331
+                                    $item->ClassName . '.' . $item->ID .
332 332
                                     ' replace ' . $word . ' with ' . $replace .
333 333
                                     ' (' . $type . ') in field ' . $field,
334 334
                                 'changed'
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
             $myStage = Versioned::get_stage();
372 372
             Versioned::set_stage(Versioned::DRAFT);
373 373
             // is it on live and is live the same as draft
374
-            $canBePublished = $item->isPublished() && ! $item->isModifiedOnDraft();
374
+            $canBePublished = $item->isPublished() && !$item->isModifiedOnDraft();
375 375
             $item->writeToStage(Versioned::DRAFT);
376 376
             if ($canBePublished) {
377 377
                 $item->publishSingle();
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 
405 405
         if (count($this->words) > 0) {
406 406
             foreach ($this->getAllDataObjects() as $className) {
407
-                if (! $this->includeClassTest($className)) {
407
+                if (!$this->includeClassTest($className)) {
408 408
                     continue;
409 409
                 }
410 410
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
                 $fields = $this->getAllValidFields($className);
413 413
                 $filterAny = [];
414 414
                 foreach ($fields as $field) {
415
-                    if (! $this->includeFieldTest($className, $field)) {
415
+                    if (!$this->includeFieldTest($className, $field)) {
416 416
                         continue;
417 417
                     }
418 418
                     $filterAny[$field . ':PartialMatch'] = $this->words;
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
         $back = $this->config()->get('hours_back_for_recent') ?: 24;
462 462
         $limit = $this->Config()->get('limit_per_class_for_recent') ?: 5;
463 463
         $threshold = strtotime('-' . $back . ' hours', DBDatetime::now()->getTimestamp());
464
-        if (! $threshold) {
464
+        if (!$threshold) {
465 465
             $threshold = time() - 86400;
466 466
         }
467 467
 
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
         }
568 568
         $finder->saveCache();
569 569
 
570
-        if (! empty($this->sortOverride)) {
570
+        if (!empty($this->sortOverride)) {
571 571
             return $list->sort($this->sortOverride);
572 572
         } else {
573 573
             return $list->sort(['SiteWideSearchSortValue' => 'ASC']);
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
             $testWords = array_unique($testWords);
598 598
             foreach ($testWords as $wordKey => $word) {
599 599
                 //match a exact field to full words / one word
600
-                $fullWords = ! (bool) $wordKey;
600
+                $fullWords = !(bool) $wordKey;
601 601
                 if (false === $done) {
602 602
                     $count = 0;
603 603
                     foreach ($fieldValues as $fieldValue) {
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 
716 716
     protected function includeClassTest(string $className): bool
717 717
     {
718
-        if (count($this->includedClassesWithSubClassess) && ! in_array($className, $this->includedClassesWithSubClassess, true)) {
718
+        if (count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) {
719 719
             if ($this->debug) {
720 720
                 DB::alteration_message(' ... Skipping as not included ' . $className);
721 721
             }
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         } elseif (count($this->includedFields) > 0) {
742 742
             return in_array($field, $this->includedFields, true);
743 743
         } elseif (count($this->excludedFields) > 0) {
744
-            return ! in_array($field, $this->includedFields, true);
744
+            return !in_array($field, $this->includedFields, true);
745 745
         } else {
746 746
             return false;
747 747
         }
Please login to merge, or discard this patch.