From 01eef8d1a4dd92cabf08935e8f5d1f17b54ee180 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 23 Nov 2022 16:21:21 +0000 Subject: [PATCH] Apply Laravel coding style Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions. You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root. For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style). --- app/Console/Commands/GenerateSiteMap.php | 3 +- app/Console/Kernel.php | 2 +- app/Docs.php | 21 ++-- app/View/Components/Backers.php | 2 +- app/View/Components/DocsAnchors.php | 12 +- app/View/Components/DocsContent.php | 7 +- app/View/Components/DocsMenu.php | 5 +- config/cagilo.php | 8 +- config/export.php | 4 +- config/services.php | 5 +- config/site.php | 140 +++++++++++------------ public/index.php | 4 +- routes/web.php | 11 +- server.php | 6 +- 14 files changed, 108 insertions(+), 122 deletions(-) diff --git a/app/Console/Commands/GenerateSiteMap.php b/app/Console/Commands/GenerateSiteMap.php index 07bcdd041..1c9417e78 100644 --- a/app/Console/Commands/GenerateSiteMap.php +++ b/app/Console/Commands/GenerateSiteMap.php @@ -2,9 +2,9 @@ namespace App\Console\Commands; +use Carbon\Carbon; use Illuminate\Console\Command; use Illuminate\Support\Str; -use Carbon\Carbon; use Spatie\Sitemap\Sitemap; use Spatie\Sitemap\Tags\Url; @@ -48,7 +48,6 @@ public function handle() $sitemap->add($url); }); - $sitemap->writeToDisk($disk, 'sitemap.xml'); return 0; diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e1d9417be..d8bc1d29f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -25,7 +25,7 @@ protected function schedule(Schedule $schedule) */ protected function commands() { - $this->load(__DIR__ . '/Commands'); + $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } diff --git a/app/Docs.php b/app/Docs.php index 1576fd24c..3c20994b0 100644 --- a/app/Docs.php +++ b/app/Docs.php @@ -20,8 +20,8 @@ class Docs protected $path; /** - * @param string $locale - * @param string $path + * @param string $locale + * @param string $path */ public function __construct(string $locale, string $path) { @@ -32,9 +32,9 @@ public function __construct(string $locale, string $path) } /** - * @param string $view - * + * @param string $view * @return \Illuminate\Contracts\View\View + * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function view(string $view) @@ -47,7 +47,7 @@ public function view(string $view) $all = collect()->merge($variables)->merge([ 'content' => Str::of($page)->after('---')->after('---')->markdown(), - 'edit' => $this->editLinkGitHub(), + 'edit' => $this->editLinkGitHub(), ]); return view($view, $all); @@ -62,8 +62,7 @@ protected function editLinkGitHub() } /** - * @param string $locale - * + * @param string $locale * @return string */ public static function ahref(string $locale) @@ -71,15 +70,15 @@ public static function ahref(string $locale) $pattern = "/$locale/"; $url = str_ireplace([ - config('app.url') . '/ru', - config('app.url') . '/en', + config('app.url').'/ru', + config('app.url').'/en', ], $pattern, URL::current()); - if (!Str::contains($url, $pattern)) { + if (! Str::contains($url, $pattern)) { $url .= $pattern; } - $url = config('app.url') . str_replace('//', '/', parse_url($url, PHP_URL_PATH)); + $url = config('app.url').str_replace('//', '/', parse_url($url, PHP_URL_PATH)); return Str::finish($url, '/'); } diff --git a/app/View/Components/Backers.php b/app/View/Components/Backers.php index 348f09683..6577d6a87 100644 --- a/app/View/Components/Backers.php +++ b/app/View/Components/Backers.php @@ -21,7 +21,7 @@ public function render() }); return view('components.backers', [ - 'backers' => $backers + 'backers' => $backers, ]); } } diff --git a/app/View/Components/DocsAnchors.php b/app/View/Components/DocsAnchors.php index 41e040499..7afe83508 100644 --- a/app/View/Components/DocsAnchors.php +++ b/app/View/Components/DocsAnchors.php @@ -27,6 +27,7 @@ public function __construct(string $content) * Get the view / contents that represent the component. * * @return \Illuminate\Contracts\View\View|\Closure|string + * * @throws \DOMException */ public function render() @@ -36,11 +37,10 @@ public function render() ]); } - /** * @param $contents - * * @return array + * * @throws \DOMException */ private function findAnchors() @@ -59,20 +59,18 @@ private function findAnchors() $text = $node->textContent; $id = Str::slug($text); $anchors[] = [ - 'text' => $text, + 'text' => $text, 'level' => $node->tagName, - 'id' => $id, + 'id' => $id, ]; while ($node->hasChildNodes()) { $node->removeChild($node->firstChild); } $node->appendChild(new \DOMElement('a', $text)); - $node->firstChild->setAttribute('href', '#' . $id); + $node->firstChild->setAttribute('href', '#'.$id); $node->firstChild->setAttribute('name', $id); }); - return $anchors; } - } diff --git a/app/View/Components/DocsContent.php b/app/View/Components/DocsContent.php index 2167db13e..1a85672e4 100644 --- a/app/View/Components/DocsContent.php +++ b/app/View/Components/DocsContent.php @@ -29,6 +29,7 @@ public function __construct(string $content) * Get the view / contents that represent the component. * * @return \App\View\Components\DocsContent + * * @throws \DOMException */ public function render() @@ -38,8 +39,8 @@ public function render() /** * @param $contents - * * @return string + * * @throws \DOMException */ private function detectAnchors() @@ -76,7 +77,6 @@ private function detectAnchors() $crawler ->filter('p,li') ->each(function (Crawler $elm) use ($fixer) { - $content = $elm->html(); $paragraph = $fixer->fix($content); @@ -84,13 +84,12 @@ private function detectAnchors() $this->content = Str::of($this->content)->replace($content, $paragraph); }); - return $this->content; } - /** * @return string + * * @throws \DOMException */ public function toHtml(): string diff --git a/app/View/Components/DocsMenu.php b/app/View/Components/DocsMenu.php index 990a53e6f..39efd5d5a 100644 --- a/app/View/Components/DocsMenu.php +++ b/app/View/Components/DocsMenu.php @@ -2,9 +2,8 @@ namespace App\View\Components; - -use Illuminate\Contracts\Foundation\Application; use Illuminate\Config\Repository; +use Illuminate\Contracts\Foundation\Application; use Illuminate\View\Component; class DocsMenu extends Component @@ -34,7 +33,7 @@ public function __construct(Application $application, Repository $config) public function render() { return view('components.docs-menu', [ - 'menu' => $this->menu + 'menu' => $this->menu, ]); } } diff --git a/config/cagilo.php b/config/cagilo.php index ef393d3e5..cae623143 100644 --- a/config/cagilo.php +++ b/config/cagilo.php @@ -16,12 +16,12 @@ */ 'components' => [ - 'alert' => Components\Alert::class, + 'alert' => Components\Alert::class, 'device' => Components\Device::class, - 'error' => Components\Error::class, - 'icon' => Components\Icon::class, + 'error' => Components\Error::class, + 'icon' => Components\Icon::class, 'logout' => Components\Logout::class, - 'meta' => Components\Meta::class, + 'meta' => Components\Meta::class, 'submit' => Components\Submit::class, ], diff --git a/config/export.php b/config/export.php index 91490f0f3..aa229f8d0 100644 --- a/config/export.php +++ b/config/export.php @@ -16,7 +16,7 @@ */ 'paths' => [ '/en', - '/ru' + '/ru', ], /* @@ -69,7 +69,7 @@ * You can skip these by adding a `--skip-{name}` flag to the command. */ 'after' => [ - 'sitemap' => 'php artisan make:sitemap', + 'sitemap' => 'php artisan make:sitemap', ], ]; diff --git a/config/services.php b/config/services.php index 6df1c3901..f4495f14f 100644 --- a/config/services.php +++ b/config/services.php @@ -30,8 +30,7 @@ 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], - 'github' => [ - 'token' => env('GITHUB_TOKEN') - ] + 'token' => env('GITHUB_TOKEN'), + ], ]; diff --git a/config/site.php b/config/site.php index 522226d0d..4625de3d4 100644 --- a/config/site.php +++ b/config/site.php @@ -9,116 +9,116 @@ 'navigation' => [ 'en' => [ 'Get Started' => [ - 'Introduction' => '/en/docs', - 'Installation' => '/en/docs/installation', + 'Introduction' => '/en/docs', + 'Installation' => '/en/docs/installation', 'Configuration' => '/en/docs/configuration', 'Upgrade Guide' => '/en/docs/upgrade', ], - 'Tutorials' => [ - 'Quick Start' => '/en/docs/quickstart', - 'Data Management' => '/en/docs/quickstart-crud', - 'Manage Attachments' => '/en/docs/quickstart-files', + 'Tutorials' => [ + 'Quick Start' => '/en/docs/quickstart', + 'Data Management' => '/en/docs/quickstart-crud', + 'Manage Attachments' => '/en/docs/quickstart-files', 'Sorting and Filtering' => '/en/docs/quickstart-sort-filter-table', ], - 'Concepts' => [ - 'Screens' => '/en/docs/screens', + 'Concepts' => [ + 'Screens' => '/en/docs/screens', 'Form Elements' => '/en/docs/field', - 'Navigation' => '/en/docs/menu', - 'Permissions' => '/en/docs/access', - 'Filtration' => '/en/docs/filters', - 'Attachments' => '/en/docs/attachments', + 'Navigation' => '/en/docs/menu', + 'Permissions' => '/en/docs/access', + 'Filtration' => '/en/docs/filters', + 'Attachments' => '/en/docs/attachments', 'Notifications' => '/en/docs/alert', ], - 'Layouts' => [ - 'Rows' => '/en/docs/rows', - 'Table' => '/en/docs/table', - 'Legend' => '/en/docs/legend', - 'Charts' => '/en/docs/charts', - 'Modals' => '/en/docs/modals', - 'Listener' => '/en/docs/listener', - 'Grouping' => '/en/docs/grouping', + 'Layouts' => [ + 'Rows' => '/en/docs/rows', + 'Table' => '/en/docs/table', + 'Legend' => '/en/docs/legend', + 'Charts' => '/en/docs/charts', + 'Modals' => '/en/docs/modals', + 'Listener' => '/en/docs/listener', + 'Grouping' => '/en/docs/grouping', //'Display elements' => '/en/docs/display-elements', 'Custom Template' => '/en/docs/custom-template', ], - 'Extra' => [ - 'Branding' => '/en/docs/brand', - 'Icons' => '/en/docs/icons', + 'Extra' => [ + 'Branding' => '/en/docs/brand', + 'Icons' => '/en/docs/icons', 'Scout Search' => '/en/docs/global-search', - 'Presenters' => '/en/docs/presenters', - 'Using JS' => '/en/docs/javascript', + 'Presenters' => '/en/docs/presenters', + 'Using JS' => '/en/docs/javascript', 'Form Builder' => '/en/docs/builder', - 'Testing' => '/en/docs/testing', - 'Controllers' => '/en/docs/controllers', + 'Testing' => '/en/docs/testing', + 'Controllers' => '/en/docs/controllers', 'Authentication' => '/en/docs/authentication', //'Recipes' => '/en/recipes', ], - 'Packages' => [ - 'CRUD' => '/en/docs/packages/crud', + 'Packages' => [ + 'CRUD' => '/en/docs/packages/crud', 'Fortify' => 'https://github.com/orchidsoftware/fortify', ], - 'Community' => [ + 'Community' => [ 'Code of Conduct' => '/en/community/code-of-conduct', - 'Contribution' => '/en/community/contributors', + 'Contribution' => '/en/community/contributors', 'Promote Project' => '/en/community/promote', - 'License' => '/en/community/license', - 'Change Log' => 'https://github.com/orchidsoftware/platform/blob/master/CHANGELOG.md', + 'License' => '/en/community/license', + 'Change Log' => 'https://github.com/orchidsoftware/platform/blob/master/CHANGELOG.md', ], ], 'ru' => [ - 'Начало работы' => [ - 'Введение в проект' => '/ru/docs', - 'Установка платформы' => '/ru/docs/installation', - 'Обзор параметров' => '/ru/docs/configuration', + 'Начало работы' => [ + 'Введение в проект' => '/ru/docs', + 'Установка платформы' => '/ru/docs/installation', + 'Обзор параметров' => '/ru/docs/configuration', 'Руководство по обновлению' => '/ru/docs/upgrade', ], - 'Учебные пособия' => [ - 'Быстрый старт' => '/ru/docs/quickstart', - 'Управление данными' => '/ru/docs/quickstart-crud', - 'Работа с файлами' => '/ru/docs/quickstart-files', + 'Учебные пособия' => [ + 'Быстрый старт' => '/ru/docs/quickstart', + 'Управление данными' => '/ru/docs/quickstart-crud', + 'Работа с файлами' => '/ru/docs/quickstart-files', 'Сортировка и фильтрация' => '/ru/docs/quickstart-sort-filter-table', ], 'Основные концепции' => [ - 'Экраны' => '/ru/docs/screens', - 'Элементы формы' => '/ru/docs/field', - 'Меню панели' => '/ru/docs/menu', - 'Права доступа' => '/ru/docs/access', - 'Фильтрация' => '/ru/docs/filters', + 'Экраны' => '/ru/docs/screens', + 'Элементы формы' => '/ru/docs/field', + 'Меню панели' => '/ru/docs/menu', + 'Права доступа' => '/ru/docs/access', + 'Фильтрация' => '/ru/docs/filters', 'Вложенные файлы' => '/ru/docs/attachments', - 'Уведомления' => '/ru/docs/alert', + 'Уведомления' => '/ru/docs/alert', ], - 'Макеты' => [ - 'Строки' => '/ru/docs/rows', - 'Таблицы' => '/ru/docs/table', - 'Легенда' => '/ru/docs/legend', - 'Графики' => '/ru/docs/charts', - 'Модальные окна' => '/ru/docs/modals', - 'Слушатель' => '/ru/docs/listener', + 'Макеты' => [ + 'Строки' => '/ru/docs/rows', + 'Таблицы' => '/ru/docs/table', + 'Легенда' => '/ru/docs/legend', + 'Графики' => '/ru/docs/charts', + 'Модальные окна' => '/ru/docs/modals', + 'Слушатель' => '/ru/docs/listener', 'Макеты группировки' => '/ru/docs/grouping', //'Макеты отображения' => '/ru/docs/display-elements', - 'Универсальные' => '/ru/docs/custom-template', + 'Универсальные' => '/ru/docs/custom-template', ], - 'Дополнительно' => [ - 'Брендирование' => '/ru/docs/brand', - 'Иконки' => '/ru/docs/icons', - 'Scout поиск' => '/ru/docs/global-search', - 'Presenters' => '/ru/docs/presenters', + 'Дополнительно' => [ + 'Брендирование' => '/ru/docs/brand', + 'Иконки' => '/ru/docs/icons', + 'Scout поиск' => '/ru/docs/global-search', + 'Presenters' => '/ru/docs/presenters', 'Использование JS' => '/ru/docs/javascript', - 'Строитель форм' => '/ru/docs/builder', - 'Тестирование' => '/ru/docs/testing', - 'Контроллеры' => '/ru/docs/controllers', + 'Строитель форм' => '/ru/docs/builder', + 'Тестирование' => '/ru/docs/testing', + 'Контроллеры' => '/ru/docs/controllers', //'Настройки' => '/ru/docs/settings', deprecation ], - 'Packages' => [ - 'CRUD' => '/ru/docs/packages/crud', + 'Packages' => [ + 'CRUD' => '/ru/docs/packages/crud', 'Fortify' => 'https://github.com/orchidsoftware/fortify', ], - 'Сообщество' => [ - 'Кодекс поведения' => '/ru/community/code-of-conduct', + 'Сообщество' => [ + 'Кодекс поведения' => '/ru/community/code-of-conduct', 'Участие в разработке' => '/ru/community/contributors', - 'Содействие проекту' => '/ru/community/promote', - 'Лицензия' => '/ru/community/license', - 'История изменений' => 'https://github.com/orchidsoftware/platform/blob/master/CHANGELOG.md', + 'Содействие проекту' => '/ru/community/promote', + 'Лицензия' => '/ru/community/license', + 'История изменений' => 'https://github.com/orchidsoftware/platform/blob/master/CHANGELOG.md', ], ], ], diff --git a/public/index.php b/public/index.php index b30e636f0..002ee24d2 100644 --- a/public/index.php +++ b/public/index.php @@ -31,7 +31,7 @@ | */ -require __DIR__ . '/../vendor/autoload.php'; +require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- @@ -44,7 +44,7 @@ | */ -$app = require_once __DIR__ . '/../bootstrap/app.php'; +$app = require_once __DIR__.'/../bootstrap/app.php'; $kernel = $app->make(Kernel::class); diff --git a/routes/web.php b/routes/web.php index 0d45f6dcb..d0bf66fa5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,34 +13,29 @@ | */ - Route::get('/{locale?}', function (string $locale = 'en') { app()->setLocale($locale); return view('welcome'); })->where('locale', 'en|ru'); - Route::get('/{locale}/{type}/icons', function (string $locale, string $type) { - $icons = collect(scandir(\Orchid\IconPack\Path::getFolder())) ->filter(function ($value) { - return !($value === '.' || $value === '..'); + return ! ($value === '.' || $value === '..'); }) ->filter(function (string $icon) { - return file_exists(Orchid\IconPack\Path::getFolder() . "/$icon"); + return file_exists(Orchid\IconPack\Path::getFolder()."/$icon"); }) ->mapWithKeys(function ($icon) { - return [str_replace('.svg', '', $icon) => file_get_contents(Orchid\IconPack\Path::getFolder() . "/$icon")]; + return [str_replace('.svg', '', $icon) => file_get_contents(Orchid\IconPack\Path::getFolder()."/$icon")]; }); return (new App\Docs($locale, "$type/icons")) ->view('icons') ->with('icons', $icons); - })->where('locale', 'en|ru'); - Route::get('/{locale}/{type}/{page?}', function (string $locale, string $type, string $page = 'index') { return (new App\Docs($locale, "$type/$page"))->view('docs'); })->where('locale', 'en|ru') diff --git a/server.php b/server.php index bca84cdc5..b07fa44b3 100644 --- a/server.php +++ b/server.php @@ -3,10 +3,8 @@ /** * Laravel - A PHP Framework For Web Artisans * - * @package Laravel * @author Taylor Otwell */ - $uri = urldecode( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ); @@ -14,8 +12,8 @@ // This file allows us to emulate Apache's "mod_rewrite" functionality from the // built-in PHP web server. This provides a convenient way to test a Laravel // application without having installed a "real" web server software here. -if ($uri !== '/' && file_exists(__DIR__ . '/public' .$uri)) { +if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { return false; } -require_once __DIR__ . '/public/index.php'; +require_once __DIR__.'/public/index.php';