@@ -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 | } |
@@ -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) |
@@ -98,7 +98,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | $className = $reflectionClass->getName(); |
| 155 | 155 | $docs = $this->getDocs($reflectionClass, $factory); |
| 156 | 156 | CompleteItem::create() |
| 157 | - ->detail((string)$className) |
|
| 158 | - ->documentation((string)$docs) |
|
| 157 | + ->detail((string) $className) |
|
| 158 | + ->documentation((string) $docs) |
|
| 159 | 159 | ->kind(CompleteItemKind::ClassKind) |
| 160 | - ->label((string)$name) |
|
| 161 | - ->insertText((string)$name) |
|
| 160 | + ->label((string) $name) |
|
| 161 | + ->insertText((string) $name) |
|
| 162 | 162 | ->add($this, $path); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | // Exclude some properties |
| 209 | 209 | $propertyAllowed = true; |
| 210 | 210 | foreach (self::EXCLUDED_PROPERTY_REGEXES as $excludePattern) { |
| 211 | - $pattern = '`' . $excludePattern . '`i'; |
|
| 211 | + $pattern = '`'.$excludePattern.'`i'; |
|
| 212 | 212 | if (preg_match($pattern, $propertyName) === 1) { |
| 213 | 213 | $propertyAllowed = false; |
| 214 | 214 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $value = json_encode($value); |
| 263 | 263 | } |
| 264 | 264 | if (!empty($value)) { |
| 265 | - $detail = (string)$value; |
|
| 265 | + $detail = (string) $value; |
|
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | } |
@@ -270,12 +270,12 @@ discard block |
||
| 270 | 270 | $thisPath = trim(implode('.', [$path, $propertyName]), '.'); |
| 271 | 271 | $label = $propertyName; |
| 272 | 272 | CompleteItem::create() |
| 273 | - ->detail((string)$detail) |
|
| 274 | - ->documentation((string)$docs) |
|
| 273 | + ->detail((string) $detail) |
|
| 274 | + ->documentation((string) $docs) |
|
| 275 | 275 | ->kind($customField ? CompleteItemKind::FieldKind : CompleteItemKind::PropertyKind) |
| 276 | - ->label((string)$label) |
|
| 277 | - ->insertText((string)$label) |
|
| 278 | - ->sortText((string)$sortPrefix . (string)$label) |
|
| 276 | + ->label((string) $label) |
|
| 277 | + ->insertText((string) $label) |
|
| 278 | + ->sortText((string) $sortPrefix.(string) $label) |
|
| 279 | 279 | ->add($this, $thisPath); |
| 280 | 280 | // Recurse through if this is an object |
| 281 | 281 | if (isset($object->$propertyName) && is_object($object->$propertyName)) { |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | // Exclude some properties |
| 306 | 306 | $methodAllowed = true; |
| 307 | 307 | foreach (self::EXCLUDED_METHOD_REGEXES as $excludePattern) { |
| 308 | - $pattern = '`' . $excludePattern . '`i'; |
|
| 308 | + $pattern = '`'.$excludePattern.'`i'; |
|
| 309 | 309 | if (preg_match($pattern, $methodName) === 1) { |
| 310 | 310 | $methodAllowed = false; |
| 311 | 311 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | if ($methodAllowed && $reflectionMethod->isPublic()) { |
| 315 | 315 | $docblock = null; |
| 316 | 316 | $docs = $this->getDocs($reflectionMethod, $factory); |
| 317 | - $detail = $methodName . '('; |
|
| 317 | + $detail = $methodName.'('; |
|
| 318 | 318 | $params = $reflectionMethod->getParameters(); |
| 319 | 319 | $paramList = []; |
| 320 | 320 | foreach ($params as $param) { |
@@ -324,20 +324,20 @@ discard block |
||
| 324 | 324 | $unionTypes = $reflectionType->getTypes(); |
| 325 | 325 | $typeName = ''; |
| 326 | 326 | foreach ($unionTypes as $unionType) { |
| 327 | - $typeName .= '|' . $unionType->getName(); |
|
| 327 | + $typeName .= '|'.$unionType->getName(); |
|
| 328 | 328 | } |
| 329 | 329 | $typeName = trim($typeName, '|'); |
| 330 | - $paramList[] = $typeName . ': ' . '$' . $param->getName(); |
|
| 330 | + $paramList[] = $typeName.': '.'$'.$param->getName(); |
|
| 331 | 331 | } else { |
| 332 | - $paramList[] = $param->getType()->getName() . ': ' . '$' . $param->getName(); |
|
| 332 | + $paramList[] = $param->getType()->getName().': '.'$'.$param->getName(); |
|
| 333 | 333 | } |
| 334 | 334 | } else { |
| 335 | - $paramList[] = '$' . $param->getName(); |
|
| 335 | + $paramList[] = '$'.$param->getName(); |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | - $detail .= implode(', ', $paramList) . ')'; |
|
| 338 | + $detail .= implode(', ', $paramList).')'; |
|
| 339 | 339 | $thisPath = trim(implode('.', [$path, $methodName]), '.'); |
| 340 | - $label = $methodName . '()'; |
|
| 340 | + $label = $methodName.'()'; |
|
| 341 | 341 | $docsPreamble = ''; |
| 342 | 342 | // Figure out the type |
| 343 | 343 | if ($docblock) { |
@@ -345,18 +345,18 @@ discard block |
||
| 345 | 345 | if ($tags) { |
| 346 | 346 | $docsPreamble = "Parameters:\n\n"; |
| 347 | 347 | foreach ($tags as $tag) { |
| 348 | - $docsPreamble .= $tag . "\n"; |
|
| 348 | + $docsPreamble .= $tag."\n"; |
|
| 349 | 349 | } |
| 350 | 350 | $docsPreamble .= "\n"; |
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | CompleteItem::create() |
| 354 | - ->detail((string)$detail) |
|
| 355 | - ->documentation((string)$docsPreamble . (string)$docs) |
|
| 354 | + ->detail((string) $detail) |
|
| 355 | + ->documentation((string) $docsPreamble.(string) $docs) |
|
| 356 | 356 | ->kind(CompleteItemKind::MethodKind) |
| 357 | - ->label((string)$label) |
|
| 358 | - ->insertText((string)$label) |
|
| 359 | - ->sortText($this->methodSortPrefix . (string)$label) |
|
| 357 | + ->label((string) $label) |
|
| 358 | + ->insertText((string) $label) |
|
| 359 | + ->sortText($this->methodSortPrefix.(string) $label) |
|
| 360 | 360 | ->add($this, $thisPath); |
| 361 | 361 | } |
| 362 | 362 | } |