From 68688b98fae6d380847c34e92e05a91cfbf83a63 Mon Sep 17 00:00:00 2001 From: laravel-ide-helper Date: Sun, 29 Dec 2024 18:19:34 +0000 Subject: [PATCH] composer fix-style --- php-templates/configs.php | 63 ++++++++++++++++---------------- php-templates/routes.php | 20 +++++----- php-templates/views.php | 31 ++++++++-------- src/Console/MetaCommand.php | 4 +- src/IdeHelperServiceProvider.php | 4 -- 5 files changed, 59 insertions(+), 63 deletions(-) diff --git a/php-templates/configs.php b/php-templates/configs.php index de7f4d9..9f6c4be 100644 --- a/php-templates/configs.php +++ b/php-templates/configs.php @@ -1,40 +1,41 @@ merge(glob(config_path("**/*.php"))) +$local = collect(glob(config_path('/*.php'))) + ->merge(glob(config_path('**/*.php'))) ->map(fn ($path) => [ - (string) \Illuminate\Support\Str::of($path) - ->replace([config_path("/"), ".php"], "") - ->replace("/", "."), - $path + (string) Illuminate\Support\Str::of($path) + ->replace([config_path('/'), '.php'], '') + ->replace('/', '.'), + $path, ]); -$vendor = collect(glob(base_path("vendor/**/**/config/*.php")))->map(fn ( +$vendor = collect(glob(base_path('vendor/**/**/config/*.php')))->map(fn ( $path ) => [ - (string) \Illuminate\Support\Str::of($path) - ->afterLast("/config/") - ->replace(".php", "") - ->replace("/", "."), - $path + (string) Illuminate\Support\Str::of($path) + ->afterLast('/config/') + ->replace('.php', '') + ->replace('/', '.'), + $path, ]); $configPaths = $local ->merge($vendor) ->groupBy(0) - ->map(fn ($items)=>$items->pluck(1)); + ->map(fn ($items) => $items->pluck(1)); $cachedContents = []; $cachedParsed = []; -function vsCodeGetConfigValue($value, $key, $configPaths) { - $parts = explode(".", $key); +function vsCodeGetConfigValue($value, $key, $configPaths) +{ + $parts = explode('.', $key); $toFind = $key; $found = null; while (count($parts) > 0) { array_pop($parts); - $toFind = implode(".", $parts); + $toFind = implode('.', $parts); if ($configPaths->has($toFind)) { $found = $toFind; @@ -56,22 +57,22 @@ function vsCodeGetConfigValue($value, $key, $configPaths) { $cachedContents[$path] ??= file_get_contents($path); $cachedParsed[$path] ??= token_get_all($cachedContents[$path]); - $keysToFind = \Illuminate\Support\Str::of($key) - ->replaceFirst($found, "") - ->ltrim(".") - ->explode("."); + $keysToFind = Illuminate\Support\Str::of($key) + ->replaceFirst($found, '') + ->ltrim('.') + ->explode('.'); if (is_numeric($keysToFind->last())) { $index = $keysToFind->pop(); - if ($index !== "0") { + if ($index !== '0') { return null; } - $key = collect(explode(".", $key)); + $key = collect(explode('.', $key)); $key->pop(); - $key = $key->implode("."); - $value = "array(...)"; + $key = $key->implode('.'); + $value = 'array(...)'; } $nextKey = $keysToFind->shift(); @@ -80,11 +81,11 @@ function vsCodeGetConfigValue($value, $key, $configPaths) { $depth = 0; foreach ($cachedParsed[$path] as $token) { - if ($token === "[") { + if ($token === '[') { $depth++; } - if ($token === "]") { + if ($token === ']') { $depth--; } @@ -117,14 +118,14 @@ function vsCodeGetConfigValue($value, $key, $configPaths) { } return [ - "name" => $key, - "value" => $value, - "file" => $file === null ? null : str_replace(base_path('/'), '', $file), - "line" => $line + 'name' => $key, + 'value' => $value, + 'file' => $file === null ? null : str_replace(base_path('/'), '', $file), + 'line' => $line, ]; } -return collect(\Illuminate\Support\Arr::dot(config()->all())) +return collect(Illuminate\Support\Arr::dot(config()->all())) ->map(fn ($value, $key) => vsCodeGetConfigValue($value, $key, $configPaths)) ->filter() ->values(); diff --git a/php-templates/routes.php b/php-templates/routes.php index bb4a1d0..ea5ace2 100644 --- a/php-templates/routes.php +++ b/php-templates/routes.php @@ -1,22 +1,22 @@ getActionName() === 'Closure') { - return new \ReflectionFunction($route->getAction()['uses']); + return new ReflectionFunction($route->getAction()['uses']); } if (!str_contains($route->getActionName(), '@')) { - return new \ReflectionClass($route->getActionName()); + return new ReflectionClass($route->getActionName()); } try { - return new \ReflectionMethod($route->getControllerClass(), $route->getActionMethod()); - } catch (\Throwable $e) { - $namespace = app(\Illuminate\Routing\UrlGenerator::class)->getRootControllerNamespace() + return new ReflectionMethod($route->getControllerClass(), $route->getActionMethod()); + } catch (Throwable $e) { + $namespace = app(Illuminate\Routing\UrlGenerator::class)->getRootControllerNamespace() ?? (app()->getNamespace() . 'Http\Controllers'); - return new \ReflectionMethod( + return new ReflectionMethod( $namespace . '\\' . ltrim($route->getControllerClass(), '\\'), $route->getActionMethod(), ); @@ -24,10 +24,10 @@ function vsCodeGetRouterReflection(\Illuminate\Routing\Route $route) } return collect(app('router')->getRoutes()->getRoutes()) - ->map(function (\Illuminate\Routing\Route $route) { + ->map(function (Illuminate\Routing\Route $route) { try { $reflection = vsCodeGetRouterReflection($route); - } catch (\Throwable $e) { + } catch (Throwable $e) { $reflection = null; } @@ -43,4 +43,4 @@ return collect(app('router')->getRoutes()->getRoutes()) 'line' => $reflection ? $reflection->getStartLine() : null, ]; }) - ; +; diff --git a/php-templates/views.php b/php-templates/views.php index 36a9ad1..5df54b1 100644 --- a/php-templates/views.php +++ b/php-templates/views.php @@ -9,27 +9,26 @@ function vsCodeFindBladeFiles($path) } foreach ( - \Symfony\Component\Finder\Finder::create() + Symfony\Component\Finder\Finder::create() ->files() - ->name("*.blade.php") - ->in($path) - as $file + ->name('*.blade.php') + ->in($path) as $file ) { $paths[] = [ - "path" => str_replace(base_path(DIRECTORY_SEPARATOR), '', $file->getRealPath()), - "isVendor" => str_contains($file->getRealPath(), base_path("vendor")), - "key" => \Illuminate\Support\Str::of($file->getRealPath()) - ->replace(realpath($path), "") - ->replace(".blade.php", "") + 'path' => str_replace(base_path(DIRECTORY_SEPARATOR), '', $file->getRealPath()), + 'isVendor' => str_contains($file->getRealPath(), base_path('vendor')), + 'key' => Illuminate\Support\Str::of($file->getRealPath()) + ->replace(realpath($path), '') + ->replace('.blade.php', '') ->ltrim(DIRECTORY_SEPARATOR) - ->replace(DIRECTORY_SEPARATOR, ".") + ->replace(DIRECTORY_SEPARATOR, '.'), ]; } return $paths; } $paths = collect( - app("view") + app('view') ->getFinder() ->getPaths() )->flatMap(function ($path) { @@ -37,7 +36,7 @@ $paths = collect( }); $hints = collect( - app("view") + app('view') ->getFinder() ->getHints() )->flatMap(function ($paths, $key) { @@ -45,7 +44,7 @@ $hints = collect( return collect(vsCodeFindBladeFiles($path))->map(function ($value) use ( $key ) { - return array_merge($value, ["key" => "{$key}::{$value["key"]}"]); + return array_merge($value, ['key' => "{$key}::{$value['key']}"]); }); }); }); @@ -54,9 +53,9 @@ $hints = collect( ->merge($hints) ->values() ->partition(function ($v) { - return !$v["isVendor"]; + return !$v['isVendor']; }); return $local - ->sortBy("key", SORT_NATURAL) - ->merge($vendor->sortBy("key", SORT_NATURAL)); + ->sortBy('key', SORT_NATURAL) + ->merge($vendor->sortBy('key', SORT_NATURAL)); diff --git a/src/Console/MetaCommand.php b/src/Console/MetaCommand.php index cc878cd..06d5538 100644 --- a/src/Console/MetaCommand.php +++ b/src/Console/MetaCommand.php @@ -192,7 +192,7 @@ class MetaCommand extends Command 'configs' => $this->loadTemplate('configs')->pluck('name')->filter(), 'routes' => $this->loadTemplate('routes')->pluck('name')->filter(), 'views' => $this->loadTemplate('views')->pluck('key')->filter(), - + ]; } @@ -229,7 +229,7 @@ class MetaCommand extends Command protected function loadTemplate($name) { if (!isset($this->templates[$name])) { - $file = __DIR__ . '/../../php-templates/' . basename($name) .'.php'; + $file = __DIR__ . '/../../php-templates/' . basename($name) . '.php'; $this->templates[$name] = $this->files->requireOnce($file); } diff --git a/src/IdeHelperServiceProvider.php b/src/IdeHelperServiceProvider.php index 143e29b..acc8692 100644 --- a/src/IdeHelperServiceProvider.php +++ b/src/IdeHelperServiceProvider.php @@ -20,10 +20,6 @@ use Illuminate\Console\Events\CommandFinished; use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Database\Events\MigrationsEnded; use Illuminate\Support\ServiceProvider; -use Illuminate\View\Engines\EngineResolver; -use Illuminate\View\Engines\PhpEngine; -use Illuminate\View\Factory; -use Illuminate\View\FileViewFinder; class IdeHelperServiceProvider extends ServiceProvider implements DeferrableProvider {