diff --git a/app/Actions/GetPathFromVaultNode.php b/app/Actions/GetPathFromVaultNode.php index 7ddbeb0..d2279dc 100644 --- a/app/Actions/GetPathFromVaultNode.php +++ b/app/Actions/GetPathFromVaultNode.php @@ -25,7 +25,7 @@ final class GetPathFromVaultNode * @phpstan-ignore-next-line larastan.noUnnecessaryCollectionCall */ $fullPath = $node->parent->ancestorsAndSelf()->get()->last()->full_path; - $relativePath = $fullPath.'/'; + $relativePath = $fullPath . '/'; } $path = sprintf( @@ -36,7 +36,7 @@ final class GetPathFromVaultNode ); if ($includeSelf) { - $path .= $node->name.($node->is_file ? '.'.$node->extension : ''); + $path .= $node->name . ($node->is_file ? '.' . $node->extension : ''); } return $path; diff --git a/app/Actions/GetUrlFromVaultNode.php b/app/Actions/GetUrlFromVaultNode.php index 7422228..12ff21c 100644 --- a/app/Actions/GetUrlFromVaultNode.php +++ b/app/Actions/GetUrlFromVaultNode.php @@ -17,6 +17,6 @@ final class GetUrlFromVaultNode */ $fullPath = $node->ancestorsAndSelf()->get()->last()->full_path; - return '/files/'.$node->vault_id.'?path='.$fullPath.'.'.$node->extension; + return '/files/' . $node->vault_id . '?path=' . $fullPath . '.' . $node->extension; } } diff --git a/app/Actions/ProcessImportedFile.php b/app/Actions/ProcessImportedFile.php index 77fe58c..9989242 100644 --- a/app/Actions/ProcessImportedFile.php +++ b/app/Actions/ProcessImportedFile.php @@ -19,7 +19,7 @@ final class ProcessImportedFile $name = $pathInfo['filename']; $extension = $pathInfo['extension'] ?? ''; - if (! in_array($extension, VaultFile::extensions())) { + if (!in_array($extension, VaultFile::extensions())) { abort(400); } @@ -51,7 +51,7 @@ final class ProcessImportedFile ); natcasesort($nodes); $name .= count($nodes) && preg_match('/-(\d+)$/', end($nodes), $matches) === 1 ? - '-'.((int) $matches[1] + 1) : + '-' . ((int) $matches[1] + 1) : '-1'; } diff --git a/app/Actions/ProcessImportedVault.php b/app/Actions/ProcessImportedVault.php index 27276a9..697580e 100644 --- a/app/Actions/ProcessImportedVault.php +++ b/app/Actions/ProcessImportedVault.php @@ -36,7 +36,7 @@ final class ProcessImportedVault ); natcasesort($vaults); $vaultName .= count($vaults) && preg_match('/-(\d+)$/', end($vaults), $matches) === 1 ? - '-'.((int) $matches[1] + 1) : + '-' . ((int) $matches[1] + 1) : '-1'; } @@ -50,17 +50,17 @@ final class ProcessImportedVault for ($i = 0, $zipCount = $zip->count(); $i < $zipCount; $i++) { $entryName = $zip->getNameIndex($i); - if (! $entryName) { + if (!$entryName) { continue; } - $isFile = ! str_ends_with($entryName, '/'); + $isFile = !str_ends_with($entryName, '/'); $flags = $isFile ? PATHINFO_FILENAME : PATHINFO_BASENAME; $name = pathinfo($entryName, $flags); $extension = null; $content = null; - if (! $isFile) { + if (!$isFile) { // ZipArchive folder paths end with a / that should // be removed in order for pathinfo() return the correct dirname $entryDirName = mb_rtrim($entryName, '/'); @@ -72,7 +72,7 @@ final class ProcessImportedVault $extension = $pathInfo['extension'] ?? ''; $parentId = $nodeIds[$entryDirName]; - if (! in_array($extension, VaultFile::extensions())) { + if (!in_array($extension, VaultFile::extensions())) { continue; } @@ -99,7 +99,7 @@ final class ProcessImportedVault Storage::disk('local')->makeDirectory($relativePath); } - if (! array_key_exists($entryDirName, $nodeIds)) { + if (!array_key_exists($entryDirName, $nodeIds)) { $nodeIds[$entryDirName] = $node->id; } } diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php index 251b5e3..dfce130 100644 --- a/app/Http/Controllers/FileController.php +++ b/app/Http/Controllers/FileController.php @@ -23,14 +23,14 @@ final class FileController extends Controller { Gate::authorize('view', $request->vault); - if (! $request->has('path')) { + if (!$request->has('path')) { abort(404); } /** @var string $path */ $path = $request->path; - if (! str_starts_with($path, '/') && $request->has('node')) { + if (!str_starts_with($path, '/') && $request->has('node')) { /** @var VaultNode $node */ $node = $vault->nodes()->findOrFail($request->node); diff --git a/app/Livewire/Auth/OAuthLoginCallback.php b/app/Livewire/Auth/OAuthLoginCallback.php index fecc976..b082580 100644 --- a/app/Livewire/Auth/OAuthLoginCallback.php +++ b/app/Livewire/Auth/OAuthLoginCallback.php @@ -25,7 +25,7 @@ final class OAuthLoginCallback extends Component return; } - if (! filter_var($providerUser->getEmail(), FILTER_VALIDATE_EMAIL)) { + if (!filter_var($providerUser->getEmail(), FILTER_VALIDATE_EMAIL)) { session()->flash('error', __('No email address found.')); $this->redirect('/login', true); diff --git a/app/Livewire/Auth/ResetPassword.php b/app/Livewire/Auth/ResetPassword.php index 1e95904..c2a79a9 100644 --- a/app/Livewire/Auth/ResetPassword.php +++ b/app/Livewire/Auth/ResetPassword.php @@ -24,7 +24,7 @@ final class ResetPassword extends Component public function send(): void { - if (! $this->form->resetPassword()) { + if (!$this->form->resetPassword()) { return; } diff --git a/app/Livewire/Forms/LoginForm.php b/app/Livewire/Forms/LoginForm.php index 76b5116..724971c 100644 --- a/app/Livewire/Forms/LoginForm.php +++ b/app/Livewire/Forms/LoginForm.php @@ -36,7 +36,7 @@ final class LoginForm extends Form /** @var array $credentials */ $credentials = $this->only('email', 'password'); - if (! Auth::attempt($credentials, $this->remember)) { + if (!Auth::attempt($credentials, $this->remember)) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ @@ -52,7 +52,7 @@ final class LoginForm extends Form */ private function ensureIsNotRateLimited(): void { - if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { + if (!RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { return; } @@ -73,6 +73,6 @@ final class LoginForm extends Form */ private function throttleKey(): string { - return Str::transliterate(Str::lower($this->email).'|'.request()->ip()); + return Str::transliterate(Str::lower($this->email) . '|' . request()->ip()); } } diff --git a/app/Livewire/Forms/RegisterForm.php b/app/Livewire/Forms/RegisterForm.php index af9f607..fe32d4c 100644 --- a/app/Livewire/Forms/RegisterForm.php +++ b/app/Livewire/Forms/RegisterForm.php @@ -28,7 +28,7 @@ final class RegisterForm extends Form { return [ 'name' => ['required', 'string', 'max:255'], - 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class], + 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:' . User::class], 'password' => ['required', 'string', 'confirmed', Rules\Password::defaults()], ]; } diff --git a/app/Livewire/Vault/Index.php b/app/Livewire/Vault/Index.php index c235171..2ef20ec 100644 --- a/app/Livewire/Vault/Index.php +++ b/app/Livewire/Vault/Index.php @@ -37,7 +37,7 @@ final class Index extends Component { $this->authorize('view', $vault); $zip = new ZipArchive; - $zipFileName = $vault->id.'.zip'; + $zipFileName = $vault->id . '.zip'; $nodes = $vault->nodes()->whereNull('parent_id')->get(); if ($zip->open(public_path($zipFileName), ZipArchive::CREATE) !== true) { @@ -49,7 +49,7 @@ final class Index extends Component $this->exportNodes($zip, $nodes); $zip->close(); - return response()->download(public_path($zipFileName), $vault->name.'.zip')->deleteFileAfterSend(true); + return response()->download(public_path($zipFileName), $vault->name . '.zip')->deleteFileAfterSend(true); } public function delete(Vault $vault): void diff --git a/app/Livewire/Vault/Last.php b/app/Livewire/Vault/Last.php index 492a044..b099623 100644 --- a/app/Livewire/Vault/Last.php +++ b/app/Livewire/Vault/Last.php @@ -15,7 +15,7 @@ final class Last extends Component $currentUser = auth()->user(); $lastVault = $currentUser->vaults()->orderBy('opened_at', 'desc')->first(); - if (! $lastVault) { + if (!$lastVault) { $this->redirect(route('vaults.index'), navigate: true); return; diff --git a/app/Livewire/Vault/Show.php b/app/Livewire/Vault/Show.php index cc33df5..c9a87d7 100644 --- a/app/Livewire/Vault/Show.php +++ b/app/Livewire/Vault/Show.php @@ -54,7 +54,7 @@ final class Show extends Component if ((int) $this->selectedFile > 0) { $selectedFile = $vault->nodes()->where('id', $this->selectedFile)->first(); - if (! $selectedFile) { + if (!$selectedFile) { $this->selectedFile = null; return; @@ -68,7 +68,7 @@ final class Show extends Component { $this->authorize('view', $node->vault); - if (! $node->vault || ! $node->vault->is($this->vault) || ! $node->is_file) { + if (!$node->vault || !$node->vault->is($this->vault) || !$node->is_file) { return; } @@ -132,7 +132,7 @@ final class Show extends Component public function updated(string $name): void { - if (! str_starts_with($name, 'nodeForm')) { + if (!str_starts_with($name, 'nodeForm')) { return; } @@ -151,7 +151,7 @@ final class Show extends Component { $this->authorize('update', $node->vault); - if (! $node->vault || $this->vault->id !== $node->vault->id || $node->is_file) { + if (!$node->vault || $this->vault->id !== $node->vault->id || $node->is_file) { $this->dispatch('toast', message: __('Something went wrong'), type: 'error'); return; @@ -170,7 +170,7 @@ final class Show extends Component $isTemplate = $node->parent_id === $this->vault->templates_node_id; $fileSelected = (int) $this->selectedFile > 0; - if (! $sameVault || ! $isNote || ! $isTemplate || ! $fileSelected || ! $this->isEditMode) { + if (!$sameVault || !$isNote || !$isTemplate || !$fileSelected || !$this->isEditMode) { $this->dispatch('toast', message: __('Something went wrong'), type: 'error'); return; @@ -186,7 +186,7 @@ final class Show extends Component ); $content = str_contains($content, '{{content}}') ? str_replace('{{content}}', (string) $selectedNode->content, $content) - : $content.PHP_EOL.$selectedNode->content; + : $content . PHP_EOL . $selectedNode->content; $selectedNode->update(['content' => $content]); $this->nodeForm->setNode($selectedNode); $this->dispatch('toast', message: __('Template inserted'), type: 'success'); @@ -195,7 +195,7 @@ final class Show extends Component #[On('templates-refresh')] public function getTemplates(): void { - if (! $this->vault->templatesNode) { + if (!$this->vault->templatesNode) { return; } @@ -222,7 +222,7 @@ final class Show extends Component DB::commit(); $this->dispatch('node-updated'); - $templateDeleted = ! is_null( + $templateDeleted = !is_null( array_find( $this->deletedNodes, fn ($node): bool => $node->parent_id === $this->vault->templates_node_id diff --git a/app/Observers/VaultNodeObserver.php b/app/Observers/VaultNodeObserver.php index ced4115..f517f70 100644 --- a/app/Observers/VaultNodeObserver.php +++ b/app/Observers/VaultNodeObserver.php @@ -35,7 +35,7 @@ final class VaultNodeObserver { $relativePath = new GetPathFromVaultNode()->handle($node, false); - if (Storage::disk('local')->exists($relativePath.$node->name)) { + if (Storage::disk('local')->exists($relativePath . $node->name)) { abort(500); } @@ -43,19 +43,19 @@ final class VaultNodeObserver /** @var string $originalName */ $originalName = $node->getOriginal('name'); $paths = [ - $relativePath.$originalName, - $relativePath.$node->name, + $relativePath . $originalName, + $relativePath . $node->name, ]; if ($node->is_file) { - $paths[0] .= '.'.$node->extension; - $paths[1] .= '.'.$node->extension; + $paths[0] .= '.' . $node->extension; + $paths[1] .= '.' . $node->extension; } Storage::disk('local')->move(...$paths); } if ($node->is_file) { Storage::disk('local')->put( - $relativePath.$node->name.'.'.$node->extension, + $relativePath . $node->name . '.' . $node->extension, $node->content ?? '', ); } diff --git a/app/Observers/VaultObserver.php b/app/Observers/VaultObserver.php index 7dc8659..5b4d92a 100644 --- a/app/Observers/VaultObserver.php +++ b/app/Observers/VaultObserver.php @@ -17,11 +17,11 @@ final class VaultObserver { $relativePath = new GetPathFromUser()->handle(); - if (Storage::disk('local')->exists($relativePath.$vault->name)) { + if (Storage::disk('local')->exists($relativePath . $vault->name)) { abort(500); } - Storage::disk('local')->makeDirectory($relativePath.$vault->name); + Storage::disk('local')->makeDirectory($relativePath . $vault->name); } /** @@ -29,21 +29,21 @@ final class VaultObserver */ public function updating(Vault $vault): void { - if (! $vault->isDirty('name')) { + if (!$vault->isDirty('name')) { return; } $relativePath = new GetPathFromUser()->handle(); - if (Storage::disk('local')->exists($relativePath.$vault->name)) { + if (Storage::disk('local')->exists($relativePath . $vault->name)) { abort(500); } /** @var string $originalName */ $originalName = $vault->getOriginal('name'); Storage::disk('local')->move( - $relativePath.$originalName, - $relativePath.$vault->name, + $relativePath . $originalName, + $relativePath . $vault->name, ); } @@ -53,6 +53,6 @@ final class VaultObserver public function deleting(Vault $vault): void { $relativePath = new GetPathFromUser()->handle(); - Storage::disk('local')->deleteDirectory($relativePath.$vault->name); + Storage::disk('local')->deleteDirectory($relativePath . $vault->name); } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 2aeb7e6..91cf139 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -8,8 +8,8 @@ use Illuminate\Foundation\Configuration\Middleware; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( - web: __DIR__.'/../routes/web.php', - commands: __DIR__.'/../routes/console.php', + web: __DIR__ . '/../routes/web.php', + commands: __DIR__ . '/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { diff --git a/config/cache.php b/config/cache.php index 9f39702..d794318 100644 --- a/config/cache.php +++ b/config/cache.php @@ -105,6 +105,6 @@ return [ | */ - 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache_'), ]; diff --git a/config/database.php b/config/database.php index 3cb08cc..f36d3b3 100644 --- a/config/database.php +++ b/config/database.php @@ -146,7 +146,7 @@ return [ 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'), ], 'default' => [ diff --git a/config/filesystems.php b/config/filesystems.php index 84a27ea..0267e76 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -41,7 +41,7 @@ return [ 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), - 'url' => env('APP_URL').'/storage', + 'url' => env('APP_URL') . '/storage', 'visibility' => 'public', 'throw' => false, ], diff --git a/config/livewire.php b/config/livewire.php index 3867d8a..f53aa49 100644 --- a/config/livewire.php +++ b/config/livewire.php @@ -69,7 +69,7 @@ return [ 'disk' => null, // Example: 'local', 's3' | Default: 'default' 'rules' => [ 'file', - 'max:'.Monolog\Utils::expandIniShorthandBytes(ini_get('upload_max_filesize')), + 'max:' . Monolog\Utils::expandIniShorthandBytes(ini_get('upload_max_filesize')), ], // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB) 'directory' => null, // Example: 'tmp' | Default: 'livewire-tmp' 'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1' diff --git a/config/logging.php b/config/logging.php index 9453a2d..9ee0cf9 100644 --- a/config/logging.php +++ b/config/logging.php @@ -91,7 +91,7 @@ return [ 'handler_with' => [ 'host' => env('PAPERTRAIL_URL'), 'port' => env('PAPERTRAIL_PORT'), - 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), ], 'processors' => [PsrLogMessageProcessor::class], ], diff --git a/config/session.php b/config/session.php index 2d82fa8..99deab4 100644 --- a/config/session.php +++ b/config/session.php @@ -131,7 +131,7 @@ return [ 'cookie' => env( 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_').'_session' + Str::slug(env('APP_NAME', 'laravel'), '_') . '_session' ), /* diff --git a/public/index.php b/public/index.php index d55a3b2..6b9e35e 100644 --- a/public/index.php +++ b/public/index.php @@ -7,13 +7,13 @@ use Illuminate\Http\Request; define('LARAVEL_START', microtime(true)); // Determine if the application is in maintenance mode... -if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) { +if (file_exists($maintenance = __DIR__ . '/../storage/framework/maintenance.php')) { require $maintenance; } // Register the Composer autoloader... -require __DIR__.'/../vendor/autoload.php'; +require __DIR__ . '/../vendor/autoload.php'; // Bootstrap Laravel and handle the request... -(require_once __DIR__.'/../bootstrap/app.php') +(require_once __DIR__ . '/../bootstrap/app.php') ->handleRequest(Request::capture()); diff --git a/rector.php b/rector.php index 26e1c8c..3c1c4ca 100644 --- a/rector.php +++ b/rector.php @@ -6,13 +6,13 @@ use Rector\Config\RectorConfig; return RectorConfig::configure() ->withPaths([ - __DIR__.'/app', - __DIR__.'/bootstrap/app.php', - __DIR__.'/bootstrap/providers.php', - __DIR__.'/database', - __DIR__.'/public', - __DIR__.'/routes', - __DIR__.'/tests', + __DIR__ . '/app', + __DIR__ . '/bootstrap/app.php', + __DIR__ . '/bootstrap/providers.php', + __DIR__ . '/database', + __DIR__ . '/public', + __DIR__ . '/routes', + __DIR__ . '/tests', ]) ->withPreparedSets( deadCode: true,