@@ -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 | } |
@@ -120,10 +120,10 @@ |
||
| 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 | } |
@@ -105,11 +105,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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) |