@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $filters = array_keys($twig->getFilters()); |
249 | 249 | foreach ($filters as $filter) { |
250 | 250 | $docs = self::FILTER_DOCS[$filter] ?? ''; |
251 | - $docs = str_replace('(#', '(' . self::CRAFT_FILTER_DOCS_URL . '#', $docs); |
|
251 | + $docs = str_replace('(#', '('.self::CRAFT_FILTER_DOCS_URL.'#', $docs); |
|
252 | 252 | CompleteItem::create() |
253 | 253 | ->label($filter) |
254 | 254 | ->insertText($filter) |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | // Twig Functions |
261 | 261 | $functions = array_keys($twig->getFunctions()); |
262 | 262 | foreach ($functions as $function) { |
263 | - $functionLabel = $function . '()'; |
|
263 | + $functionLabel = $function.'()'; |
|
264 | 264 | $docs = self::FUNCTION_DOCS[$function] ?? ''; |
265 | - $docs = str_replace('(#', '(' . self::CRAFT_FUNCTION_DOCS_URL . '#', $docs); |
|
265 | + $docs = str_replace('(#', '('.self::CRAFT_FUNCTION_DOCS_URL.'#', $docs); |
|
266 | 266 | CompleteItem::create() |
267 | 267 | ->label($functionLabel) |
268 | 268 | ->insertText($functionLabel) |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $tags = array_keys($twig->getTokenParsers()); |
276 | 276 | foreach ($tags as $tag) { |
277 | 277 | $docs = self::TAG_DOCS[$tag] ?? ''; |
278 | - $docs = str_replace('(#', '(' . self::CRAFT_TAG_DOCS_URL . '#', $docs); |
|
278 | + $docs = str_replace('(#', '('.self::CRAFT_TAG_DOCS_URL.'#', $docs); |
|
279 | 279 | CompleteItem::create() |
280 | 280 | ->label($tag) |
281 | 281 | ->insertText($tag) |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | $name = $autocomplete->name; |
112 | 112 | // Set up the cache parameters |
113 | 113 | $cache = Craft::$app->getCache(); |
114 | - $cacheKey = $this->cacheKeyPrefix . $name; |
|
114 | + $cacheKey = $this->cacheKeyPrefix.$name; |
|
115 | 115 | $dependency = new TagDependency([ |
116 | 116 | 'tags' => [ |
117 | 117 | self::AUTOCOMPLETE_CACHE_TAG, |
118 | - self::AUTOCOMPLETE_CACHE_TAG . $name, |
|
118 | + self::AUTOCOMPLETE_CACHE_TAG.$name, |
|
119 | 119 | ], |
120 | 120 | ]); |
121 | 121 | // Get the autocompletes from the cache, or generate them if they aren't cached |
122 | - $autocompleteItems[$name] = $cache->getOrSet($cacheKey, static function () use ($name, $autocomplete) { |
|
122 | + $autocompleteItems[$name] = $cache->getOrSet($cacheKey, static function() use ($name, $autocomplete) { |
|
123 | 123 | $autocomplete->generateCompleteItems(); |
124 | 124 | return [ |
125 | 125 | 'name' => $name, |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | public function clearAutocompleteCache(string $autocompleteName = ''): void |
143 | 143 | { |
144 | 144 | $cache = Craft::$app->getCache(); |
145 | - TagDependency::invalidate($cache, self::AUTOCOMPLETE_CACHE_TAG . $autocompleteName); |
|
145 | + TagDependency::invalidate($cache, self::AUTOCOMPLETE_CACHE_TAG.$autocompleteName); |
|
146 | 146 | Craft::info('Twigfield caches invalidated', __METHOD__); |
147 | 147 | } |
148 | 148 |
@@ -102,7 +102,7 @@ discard block |
||
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 |
||
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 | }); |
@@ -41,7 +41,7 @@ |
||
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); |
@@ -71,7 +71,7 @@ |
||
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 | ]); |
@@ -62,7 +62,7 @@ |
||
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 | } |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | $value = json_encode(array_keys($value)); |
148 | 148 | } |
149 | 149 | $this->addCompleteItem(new CompleteItem([ |
150 | - 'detail' => (string)$value, |
|
150 | + 'detail' => (string) $value, |
|
151 | 151 | 'kind' => $kind, |
152 | - 'label' => (string)$key, |
|
153 | - 'insertText' => (string)$key, |
|
152 | + 'label' => (string) $key, |
|
153 | + 'insertText' => (string) $key, |
|
154 | 154 | ]), $path); |
155 | 155 | break; |
156 | 156 | } |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | } |
223 | 223 | } |
224 | 224 | $this->addCompleteItem(new CompleteItem([ |
225 | - 'detail' => (string)$className, |
|
226 | - 'documentation' => (string)$docs, |
|
225 | + 'detail' => (string) $className, |
|
226 | + 'documentation' => (string) $docs, |
|
227 | 227 | 'kind' => CompleteItemKind::ClassKind, |
228 | - 'label' => (string)$name, |
|
229 | - 'insertText' => (string)$name, |
|
228 | + 'label' => (string) $name, |
|
229 | + 'insertText' => (string) $name, |
|
230 | 230 | ]), $path); |
231 | 231 | } |
232 | 232 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | // Exclude some properties |
277 | 277 | $propertyAllowed = true; |
278 | 278 | foreach (self::EXCLUDED_PROPERTY_REGEXES as $excludePattern) { |
279 | - $pattern = '`' . $excludePattern . '`i'; |
|
279 | + $pattern = '`'.$excludePattern.'`i'; |
|
280 | 280 | if (preg_match($pattern, $propertyName) === 1) { |
281 | 281 | $propertyAllowed = false; |
282 | 282 | } |
@@ -346,12 +346,12 @@ discard block |
||
346 | 346 | $thisPath = trim(implode('.', [$path, $propertyName]), '.'); |
347 | 347 | $label = $propertyName; |
348 | 348 | $this->addCompleteItem(new CompleteItem([ |
349 | - 'detail' => (string)$detail, |
|
350 | - 'documentation' => (string)$docs, |
|
349 | + 'detail' => (string) $detail, |
|
350 | + 'documentation' => (string) $docs, |
|
351 | 351 | 'kind' => $customField ? CompleteItemKind::FieldKind : CompleteItemKind::PropertyKind, |
352 | - 'label' => (string)$label, |
|
353 | - 'insertText' => (string)$label, |
|
354 | - 'sortText' => (string)$sortPrefix . (string)$label, |
|
352 | + 'label' => (string) $label, |
|
353 | + 'insertText' => (string) $label, |
|
354 | + 'sortText' => (string) $sortPrefix.(string) $label, |
|
355 | 355 | ]), $thisPath); |
356 | 356 | // Recurse through if this is an object |
357 | 357 | if (isset($object->$propertyName) && is_object($object->$propertyName)) { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | // Exclude some properties |
382 | 382 | $methodAllowed = true; |
383 | 383 | foreach (self::EXCLUDED_METHOD_REGEXES as $excludePattern) { |
384 | - $pattern = '`' . $excludePattern . '`i'; |
|
384 | + $pattern = '`'.$excludePattern.'`i'; |
|
385 | 385 | if (preg_match($pattern, $methodName) === 1) { |
386 | 386 | $methodAllowed = false; |
387 | 387 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | } |
404 | 404 | } |
405 | 405 | } |
406 | - $detail = $methodName . '('; |
|
406 | + $detail = $methodName.'('; |
|
407 | 407 | $params = $reflectionMethod->getParameters(); |
408 | 408 | $paramList = []; |
409 | 409 | foreach ($params as $param) { |
@@ -413,20 +413,20 @@ discard block |
||
413 | 413 | $unionTypes = $reflectionType->getTypes(); |
414 | 414 | $typeName = ''; |
415 | 415 | foreach ($unionTypes as $unionType) { |
416 | - $typeName .= '|' . $unionType->getName(); |
|
416 | + $typeName .= '|'.$unionType->getName(); |
|
417 | 417 | } |
418 | 418 | $typeName = trim($typeName, '|'); |
419 | - $paramList[] = $typeName . ': ' . '$' . $param->getName(); |
|
419 | + $paramList[] = $typeName.': '.'$'.$param->getName(); |
|
420 | 420 | } else { |
421 | - $paramList[] = $param->getType()->getName() . ': ' . '$' . $param->getName(); |
|
421 | + $paramList[] = $param->getType()->getName().': '.'$'.$param->getName(); |
|
422 | 422 | } |
423 | 423 | } else { |
424 | - $paramList[] = '$' . $param->getName(); |
|
424 | + $paramList[] = '$'.$param->getName(); |
|
425 | 425 | } |
426 | 426 | } |
427 | - $detail .= implode(', ', $paramList) . ')'; |
|
427 | + $detail .= implode(', ', $paramList).')'; |
|
428 | 428 | $thisPath = trim(implode('.', [$path, $methodName]), '.'); |
429 | - $label = $methodName . '()'; |
|
429 | + $label = $methodName.'()'; |
|
430 | 430 | $docsPreamble = ''; |
431 | 431 | // Figure out the type |
432 | 432 | if ($docblock) { |
@@ -434,18 +434,18 @@ discard block |
||
434 | 434 | if ($tags) { |
435 | 435 | $docsPreamble = "Parameters:\n\n"; |
436 | 436 | foreach ($tags as $tag) { |
437 | - $docsPreamble .= $tag . "\n"; |
|
437 | + $docsPreamble .= $tag."\n"; |
|
438 | 438 | } |
439 | 439 | $docsPreamble .= "\n"; |
440 | 440 | } |
441 | 441 | } |
442 | 442 | $this->addCompleteItem(new CompleteItem([ |
443 | - 'detail' => (string)$detail, |
|
444 | - 'documentation' => (string)$docsPreamble . (string)$docs, |
|
443 | + 'detail' => (string) $detail, |
|
444 | + 'documentation' => (string) $docsPreamble.(string) $docs, |
|
445 | 445 | 'kind' => CompleteItemKind::MethodKind, |
446 | - 'label' => (string)$label, |
|
447 | - 'insertText' => (string)$label, |
|
448 | - 'sortText' => '~~~' . (string)$label, |
|
446 | + 'label' => (string) $label, |
|
447 | + 'insertText' => (string) $label, |
|
448 | + 'sortText' => '~~~'.(string) $label, |
|
449 | 449 | ]), $thisPath); |
450 | 450 | } |
451 | 451 | } |