Passed
Push — develop ( 3e842e...5cf17c )
by Andrew
04:26
created
src/Twigfield.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         // Translation category
103 103
         $i18n = Craft::$app->getI18n();
104 104
         /** @noinspection UnSafeIsSetOverArrayInspection */
105
-        if (!isset($i18n->translations[$this->id]) && !isset($i18n->translations[$this->id . '*'])) {
105
+        if (!isset($i18n->translations[$this->id]) && !isset($i18n->translations[$this->id.'*'])) {
106 106
             $i18n->translations[$this->id] = [
107 107
                 'class' => PhpMessageSource::class,
108 108
                 'sourceLanguage' => 'en-US',
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
     public function registerEventHandlers(): void
137 137
     {
138 138
         // Base CP templates directory
139
-        Event::on(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, function (RegisterTemplateRootsEvent $e) {
140
-            if (is_dir($baseDir = $this->getBasePath() . DIRECTORY_SEPARATOR . 'templates')) {
139
+        Event::on(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, function(RegisterTemplateRootsEvent $e) {
140
+            if (is_dir($baseDir = $this->getBasePath().DIRECTORY_SEPARATOR.'templates')) {
141 141
                 $e->roots[$this->id] = $baseDir;
142 142
             }
143 143
         });
144 144
         // Base Site templates directory
145 145
         if (self::$settings->allowFrontendAccess) {
146
-            Event::on(View::class, View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS, function (RegisterTemplateRootsEvent $e) {
147
-                if (is_dir($baseDir = $this->getBasePath() . DIRECTORY_SEPARATOR . 'templates')) {
146
+            Event::on(View::class, View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS, function(RegisterTemplateRootsEvent $e) {
147
+                if (is_dir($baseDir = $this->getBasePath().DIRECTORY_SEPARATOR.'templates')) {
148 148
                     $e->roots[$this->id] = $baseDir;
149 149
                 }
150 150
             });
Please login to merge, or discard this patch.
src/helpers/Config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
         $fileName .= self::PHP_SUFFIX;
42 42
         $currentEnv = Craft::$app->getConfig()->env;
43 43
         // Try craft/config first
44
-        $path = Craft::getAlias('@config/' . $fileName, false);
44
+        $path = Craft::getAlias('@config/'.$fileName, false);
45 45
         if ($path === false || !file_exists($path)) {
46 46
             // Now try our own internal config
47 47
             $path = Craft::getAlias('@nystudio107/twigfield/config.php', false);
Please login to merge, or discard this patch.
src/base/Autocomplete.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
             $path = $item->label;
72 72
         }
73 73
         ArrayHelper::setValue($this->completeItems, $path, [
74
-            self::COMPLETION_KEY => array_filter($item->toArray(), static function ($v) {
74
+            self::COMPLETION_KEY => array_filter($item->toArray(), static function($v) {
75 75
                 return !is_null($v);
76 76
             })
77 77
         ]);
Please login to merge, or discard this patch.
src/autocompletes/EnvironmentVariableAutocomplete.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
                     ->filterText($trimmedName)
63 63
                     ->detail($item['hint'])
64 64
                     ->kind(CompleteItemKind::ConstantKind)
65
-                    ->sortText('~' . $name)
65
+                    ->sortText('~'.$name)
66 66
                     ->add($this);
67 67
             }
68 68
         }
Please login to merge, or discard this patch.
src/autocompletes/CraftApiAutocomplete.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -120,10 +120,10 @@
 block discarded – undo
120 120
                             $value = json_encode(array_keys($value));
121 121
                         }
122 122
                         CompleteItem::create()
123
-                            ->detail((string)$value)
123
+                            ->detail((string) $value)
124 124
                             ->kind($kind)
125
-                            ->label((string)$key)
126
-                            ->insertText((string)$key)
125
+                            ->label((string) $key)
126
+                            ->insertText((string) $key)
127 127
                             ->add($this, $path);
128 128
                         break;
129 129
                 }
Please login to merge, or discard this patch.
src/base/ObjectParserAutocomplete.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
         $className = $reflectionClass->getName();
106 106
         $docs = $this->getDocs($reflectionClass, $factory);
107 107
         CompleteItem::create()
108
-            ->detail((string)$className)
109
-            ->documentation((string)$docs)
108
+            ->detail((string) $className)
109
+            ->documentation((string) $docs)
110 110
             ->kind(CompleteItemKind::ClassKind)
111
-            ->label((string)$name)
112
-            ->insertText((string)$name)
111
+            ->label((string) $name)
112
+            ->insertText((string) $name)
113 113
             ->add($this, $path);
114 114
     }
115 115
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             // Exclude some properties
160 160
             $propertyAllowed = true;
161 161
             foreach (self::EXCLUDED_PROPERTY_REGEXES as $excludePattern) {
162
-                $pattern = '`' . $excludePattern . '`i';
162
+                $pattern = '`'.$excludePattern.'`i';
163 163
                 if (preg_match($pattern, $propertyName) === 1) {
164 164
                     $propertyAllowed = false;
165 165
                 }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                                 $value = json_encode($value);
214 214
                             }
215 215
                             if (!empty($value)) {
216
-                                $detail = (string)$value;
216
+                                $detail = (string) $value;
217 217
                             }
218 218
                         }
219 219
                     }
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
                 $thisPath = trim(implode('.', [$path, $propertyName]), '.');
222 222
                 $label = $propertyName;
223 223
                 CompleteItem::create()
224
-                    ->detail((string)$detail)
225
-                    ->documentation((string)$docs)
224
+                    ->detail((string) $detail)
225
+                    ->documentation((string) $docs)
226 226
                     ->kind($customField ? CompleteItemKind::FieldKind : CompleteItemKind::PropertyKind)
227
-                    ->label((string)$label)
228
-                    ->insertText((string)$label)
229
-                    ->sortText((string)$sortPrefix . (string)$label)
227
+                    ->label((string) $label)
228
+                    ->insertText((string) $label)
229
+                    ->sortText((string) $sortPrefix.(string) $label)
230 230
                     ->add($this, $thisPath);
231 231
                 // Recurse through if this is an object
232 232
                 if (isset($object->$propertyName) && is_object($object->$propertyName)) {
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
             // Exclude some properties
257 257
             $methodAllowed = true;
258 258
             foreach (self::EXCLUDED_METHOD_REGEXES as $excludePattern) {
259
-                $pattern = '`' . $excludePattern . '`i';
259
+                $pattern = '`'.$excludePattern.'`i';
260 260
                 if (preg_match($pattern, $methodName) === 1) {
261 261
                     $methodAllowed = false;
262 262
                 }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             if ($methodAllowed && $reflectionMethod->isPublic()) {
266 266
                 $docblock = null;
267 267
                 $docs = $this->getDocs($reflectionMethod, $factory);
268
-                $detail = $methodName . '(';
268
+                $detail = $methodName.'(';
269 269
                 $params = $reflectionMethod->getParameters();
270 270
                 $paramList = [];
271 271
                 foreach ($params as $param) {
@@ -275,20 +275,20 @@  discard block
 block discarded – undo
275 275
                             $unionTypes = $reflectionType->getTypes();
276 276
                             $typeName = '';
277 277
                             foreach ($unionTypes as $unionType) {
278
-                                $typeName .= '|' . $unionType->getName();
278
+                                $typeName .= '|'.$unionType->getName();
279 279
                             }
280 280
                             $typeName = trim($typeName, '|');
281
-                            $paramList[] = $typeName . ': ' . '$' . $param->getName();
281
+                            $paramList[] = $typeName.': '.'$'.$param->getName();
282 282
                         } else {
283
-                            $paramList[] = $param->getType()->getName() . ': ' . '$' . $param->getName();
283
+                            $paramList[] = $param->getType()->getName().': '.'$'.$param->getName();
284 284
                         }
285 285
                     } else {
286
-                        $paramList[] = '$' . $param->getName();
286
+                        $paramList[] = '$'.$param->getName();
287 287
                     }
288 288
                 }
289
-                $detail .= implode(', ', $paramList) . ')';
289
+                $detail .= implode(', ', $paramList).')';
290 290
                 $thisPath = trim(implode('.', [$path, $methodName]), '.');
291
-                $label = $methodName . '()';
291
+                $label = $methodName.'()';
292 292
                 $docsPreamble = '';
293 293
                 // Figure out the type
294 294
                 if ($docblock) {
@@ -296,18 +296,18 @@  discard block
 block discarded – undo
296 296
                     if ($tags) {
297 297
                         $docsPreamble = "Parameters:\n\n";
298 298
                         foreach ($tags as $tag) {
299
-                            $docsPreamble .= $tag . "\n";
299
+                            $docsPreamble .= $tag."\n";
300 300
                         }
301 301
                         $docsPreamble .= "\n";
302 302
                     }
303 303
                 }
304 304
                 CompleteItem::create()
305
-                    ->detail((string)$detail)
306
-                    ->documentation((string)$docsPreamble . (string)$docs)
305
+                    ->detail((string) $detail)
306
+                    ->documentation((string) $docsPreamble.(string) $docs)
307 307
                     ->kind(CompleteItemKind::MethodKind)
308
-                    ->label((string)$label)
309
-                    ->insertText((string)$label)
310
-                    ->sortText(self::METHOD_SORT_PREFIX . (string)$label)
308
+                    ->label((string) $label)
309
+                    ->insertText((string) $label)
310
+                    ->sortText(self::METHOD_SORT_PREFIX.(string) $label)
311 311
                     ->add($this, $thisPath);
312 312
             }
313 313
         }
Please login to merge, or discard this patch.
src/autocompletes/TwigLanguageAutocomplete.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         $filters = array_keys($twig->getFilters());
265 265
         foreach ($filters as $filter) {
266 266
             $docs = self::FILTER_DOCS[$filter] ?? '';
267
-            $docs = str_replace('(#', '(' . self::CRAFT_FILTER_DOCS_URL . '#', $docs);
267
+            $docs = str_replace('(#', '('.self::CRAFT_FILTER_DOCS_URL.'#', $docs);
268 268
             CompleteItem::create()
269 269
                 ->label($filter)
270 270
                 ->insertText($filter)
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
         // Twig Functions
277 277
         $functions = array_keys($twig->getFunctions());
278 278
         foreach ($functions as $function) {
279
-            $functionLabel = $function . '()';
279
+            $functionLabel = $function.'()';
280 280
             $docs = self::FUNCTION_DOCS[$function] ?? '';
281
-            $docs = str_replace('(#', '(' . self::CRAFT_FUNCTION_DOCS_URL . '#', $docs);
281
+            $docs = str_replace('(#', '('.self::CRAFT_FUNCTION_DOCS_URL.'#', $docs);
282 282
             CompleteItem::create()
283 283
                 ->label($functionLabel)
284 284
                 ->insertText($functionLabel)
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         $tags = array_merge(self::ADDITIONAL_TAGS, array_keys($twig->getTokenParsers()));
292 292
         foreach ($tags as $tag) {
293 293
             $docs = self::TAG_DOCS[$tag] ?? '';
294
-            $docs = str_replace('(#', '(' . self::CRAFT_TAG_DOCS_URL . '#', $docs);
294
+            $docs = str_replace('(#', '('.self::CRAFT_TAG_DOCS_URL.'#', $docs);
295 295
             CompleteItem::create()
296 296
                 ->label($tag)
297 297
                 ->insertText($tag)
Please login to merge, or discard this patch.
src/services/AutocompleteService.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             $this->cacheDuration = 1;
99 99
         }
100 100
         // Invalidate any SectionShorthandFieldsAutocomplete caches whenever any section is edited
101
-        Event::on(Sections::class, Sections::EVENT_AFTER_SAVE_SECTION, function (SectionEvent $e) {
101
+        Event::on(Sections::class, Sections::EVENT_AFTER_SAVE_SECTION, function(SectionEvent $e) {
102 102
             $this->clearAutocompleteCache(SectionShorthandFieldsAutocomplete::class);
103 103
         });
104 104
     }
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
             $dependency = new TagDependency([
137 137
                 'tags' => [
138 138
                     self::AUTOCOMPLETE_CACHE_TAG,
139
-                    self::AUTOCOMPLETE_CACHE_TAG . $name,
140
-                    self::AUTOCOMPLETE_CACHE_TAG . $autocomplete::class,
139
+                    self::AUTOCOMPLETE_CACHE_TAG.$name,
140
+                    self::AUTOCOMPLETE_CACHE_TAG.$autocomplete::class,
141 141
                 ],
142 142
             ]);
143 143
             // Get the autocompletes from the cache, or generate them if they aren't cached
144
-            $autocompleteItems[$name] = $cache->getOrSet($cacheKey, static function () use ($name, $autocomplete) {
144
+            $autocompleteItems[$name] = $cache->getOrSet($cacheKey, static function() use ($name, $autocomplete) {
145 145
                 $autocomplete->generateCompleteItems();
146 146
                 return [
147 147
                     'name' => $name,
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     public function clearAutocompleteCache(string $autocompleteName = ''): void
166 166
     {
167 167
         $cache = Craft::$app->getCache();
168
-        TagDependency::invalidate($cache, self::AUTOCOMPLETE_CACHE_TAG . $autocompleteName);
168
+        TagDependency::invalidate($cache, self::AUTOCOMPLETE_CACHE_TAG.$autocompleteName);
169 169
         Craft::info('Twigfield caches invalidated', __METHOD__);
170 170
     }
171 171
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function getAutocompleteCacheKey(AutocompleteInterface $autocomplete, array $config): string
180 180
     {
181
-        return $this->cacheKeyPrefix . $autocomplete->name . md5(serialize($config));
181
+        return $this->cacheKeyPrefix.$autocomplete->name.md5(serialize($config));
182 182
     }
183 183
 
184 184
     // Protected Methods
Please login to merge, or discard this patch.