mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-17 17:47:13 +00:00
* Add phpstorm meta hints * composer fix-style * Use php-templates from vs-code * Fix view instance * composer fix-style * Add translations * composer fix-style * map to string * composer fix-style * Fix test --------- Co-authored-by: laravel-ide-helper <[email protected]>
62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
|
|
function vsCodeFindBladeFiles($path)
|
|
{
|
|
$paths = [];
|
|
|
|
if (!is_dir($path)) {
|
|
return $paths;
|
|
}
|
|
|
|
foreach (
|
|
Symfony\Component\Finder\Finder::create()
|
|
->files()
|
|
->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', '')
|
|
->ltrim(DIRECTORY_SEPARATOR)
|
|
->replace(DIRECTORY_SEPARATOR, '.'),
|
|
];
|
|
}
|
|
|
|
return $paths;
|
|
}
|
|
$paths = collect(
|
|
app('view')
|
|
->getFinder()
|
|
->getPaths()
|
|
)->flatMap(function ($path) {
|
|
return vsCodeFindBladeFiles($path);
|
|
});
|
|
|
|
$hints = collect(
|
|
app('view')
|
|
->getFinder()
|
|
->getHints()
|
|
)->flatMap(function ($paths, $key) {
|
|
return collect($paths)->flatMap(function ($path) use ($key) {
|
|
return collect(vsCodeFindBladeFiles($path))->map(function ($value) use (
|
|
$key
|
|
) {
|
|
return array_merge($value, ['key' => "{$key}::{$value['key']}"]);
|
|
});
|
|
});
|
|
});
|
|
|
|
[$local, $vendor] = $paths
|
|
->merge($hints)
|
|
->values()
|
|
->partition(function ($v) {
|
|
return !$v['isVendor'];
|
|
});
|
|
|
|
return $local
|
|
->sortBy('key', SORT_NATURAL)
|
|
->merge($vendor->sortBy('key', SORT_NATURAL));
|