diff --git a/app/Console/Commands/UserCreate.php b/app/Console/Commands/UserCreate.php index 2bf8d40..cedc773 100644 --- a/app/Console/Commands/UserCreate.php +++ b/app/Console/Commands/UserCreate.php @@ -29,35 +29,35 @@ class UserCreate extends Command /** * The first name of the new user. * - * @var string + * @var string|null */ protected $first_name; /** * The last name of the new user. * - * @var string + * @var string|null */ protected $last_name; /** * The email of the new user. * - * @var string + * @var string|null */ protected $email; /** * The password of the new user. * - * @var string + * @var string|null */ protected $password; /** * The role of the new user. * - * @var string + * @var string|null */ protected $role; @@ -226,7 +226,7 @@ class UserCreate extends Command $this->role = $tmp; } catch (ValidationException $e) { $this->error(sprintf( - 'Please choose from the selection', + 'Please choose from the selection %s', \implode(',', collect($e->errors())->flatten()->all()) )); continue; diff --git a/app/Enums/ActivityLogs/ActivityLogsEventEnum.php b/app/Enums/ActivityLogs/ActivityLogsEventEnum.php index ebb098c..df94759 100644 --- a/app/Enums/ActivityLogs/ActivityLogsEventEnum.php +++ b/app/Enums/ActivityLogs/ActivityLogsEventEnum.php @@ -15,6 +15,8 @@ enum ActivityLogsEventEnum: int /** * Optionnal labels definition + * + * @phpstan-ignore-next-line */ private const LABELS = [ self::created->name => 'Création', diff --git a/app/Enums/Country.php b/app/Enums/Country.php index 7d0c40b..4a09295 100644 --- a/app/Enums/Country.php +++ b/app/Enums/Country.php @@ -260,6 +260,8 @@ enum Country: int /** * Optionnal labels definition + * + * @phpstan-ignore-next-line */ private const LABELS = [ self::afghanistan->name => 'Afghanistan', diff --git a/app/Enums/StaticPageType.php b/app/Enums/StaticPageType.php index 060203b..89fec57 100644 --- a/app/Enums/StaticPageType.php +++ b/app/Enums/StaticPageType.php @@ -14,6 +14,8 @@ enum StaticPageType: int /** * Optionnal labels definition. + * + * @phpstan-ignore-next-line */ private const LABELS = [ self::contact->name => 'Contact', diff --git a/app/Enums/Theme/BootstrapThemeEnum.php b/app/Enums/Theme/BootstrapThemeEnum.php index a9683e8..f1e8f7e 100644 --- a/app/Enums/Theme/BootstrapThemeEnum.php +++ b/app/Enums/Theme/BootstrapThemeEnum.php @@ -13,6 +13,8 @@ enum BootstrapThemeEnum: int /** * Optionnal labels definition + * + * @phpstan-ignore-next-line */ private const LABELS = [ self::light->name => 'enums.bootstrap-theme.light', diff --git a/app/Enums/Users/RoleEnum.php b/app/Enums/Users/RoleEnum.php index 94d0471..5f1f327 100644 --- a/app/Enums/Users/RoleEnum.php +++ b/app/Enums/Users/RoleEnum.php @@ -14,6 +14,8 @@ enum RoleEnum: int /** * Optionnal labels definition. + * + * @phpstan-ignore-next-line */ private const LABELS = [ self::conceptor->name => 'enums.user-role.conceptor', diff --git a/app/Http/Controllers/Bo/ActivityLogController.php b/app/Http/Controllers/Bo/ActivityLogController.php index ba7b375..97d6605 100644 --- a/app/Http/Controllers/Bo/ActivityLogController.php +++ b/app/Http/Controllers/Bo/ActivityLogController.php @@ -51,7 +51,7 @@ class ActivityLogController extends Controller /** * Show the form for editing the specified resource. * - * @param App\Models\ActivityLog $activity_log + * @param \App\Models\ActivityLog $activity_log * @return \Illuminate\Contracts\View\View */ public function show(ActivityLog $activity_log): \Illuminate\Contracts\View\View diff --git a/app/Http/Controllers/Bo/StaticPageController.php b/app/Http/Controllers/Bo/StaticPageController.php index 55775dc..9b92073 100644 --- a/app/Http/Controllers/Bo/StaticPageController.php +++ b/app/Http/Controllers/Bo/StaticPageController.php @@ -56,7 +56,7 @@ class StaticPageController extends Controller /** * Show the form for editing the specified resource. * - * @param App\Models\StaticPage $static_page + * @param \App\Models\StaticPage $static_page * @return \Illuminate\Contracts\View\View */ public function edit(StaticPage $static_page): \Illuminate\Contracts\View\View diff --git a/app/Http/Controllers/Bo/UserController.php b/app/Http/Controllers/Bo/UserController.php index a723403..2055644 100644 --- a/app/Http/Controllers/Bo/UserController.php +++ b/app/Http/Controllers/Bo/UserController.php @@ -102,7 +102,7 @@ class UserController extends Controller /** * Show the form for editing the specified resource. * - * @param App\Models\User $user + * @param \App\Models\User $user * @return \Illuminate\Contracts\View\View */ public function edit(User $user): \Illuminate\Contracts\View\View diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 768c25f..2ae462d 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -94,7 +94,7 @@ class Controller extends BaseController return $query; } // Get models with relation's name/label. - if (Str::endsWith($field, '_id') && $query->getModel()->has(Str::remove('_id', $field))) { + if (Str::endsWith($field, '_id')) { $query->orWhereHas(Str::remove('_id', $field), function ($queryRelation) use ($field, $search) { if (Schema::hasColumn(Str::remove('_id', $field) . 's', 'name')) { $queryRelation->where('name', 'like', '%' . $search . '%'); @@ -122,12 +122,15 @@ class Controller extends BaseController */ protected function getSearchValue(Builder $query, string $search, string $field): string|array { + $cast = $query->getModel()->getCasts()[$field] ?? null; if ( count($query->getModel()->getCasts()) and // Check if the model has casts. - isset($query->getModel()->getCasts()[$field]) and // Check if there is cast about specific field. - enum_exists($query->getModel()->getCasts()[$field]) // Check if the cast is an enum. + $cast and // Check if there is cast about specific field. + enum_exists($cast) // Check if the cast is an enum. ) { - $cases = collect($query->getModel()->getCasts()[$field]::toArray()); + /** @var \App\Traits\Enums $cast */ + // @phpstan-ignore-next-line + $cases = collect($cast::toArray()); $enum = $cases->filter(function ($item) use ($search) { return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label)); }); @@ -148,12 +151,12 @@ class Controller extends BaseController { $rName = request()->route()->getName(); $table = $query->getModel()->getTable(); - if (request()->sort_col) { - Session::put("$rName.sort_col", request()->sort_col); + if (request()->input('sort_col')) { + Session::put("$rName.sort_col", request()->input('sort_col')); Session::put("$rName.sorted", true); } - if (request()->sort_way) { - Session::put("$rName.sort_way", request()->sort_way); + if (request()->input('sort_way')) { + Session::put("$rName.sort_way", request()->input('sort_way')); Session::put("$rName.sorted", true); } if (request()->rst) { @@ -161,12 +164,16 @@ class Controller extends BaseController Session::remove("$rName.sort_col"); Session::remove("$rName.sort_way"); } - if (request()->sort_col and request()->sort_way and Schema::hasColumn($table, request()->sort_col)) { - if ( - !isset($ignore) or - (isset($ignore) and !in_array(request()->sort_col, $ignore)) - ) { - $query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way); + if ( + request()->input('sort_col') and + request()->input('sort_way') and + Schema::hasColumn($table, request()->input('sort_col')) + ) { + if (!in_array(request()->input('sort_col'), $ignore)) { + $query = $query->orderBy( + \sprintf("$table.%s", request()->input('sort_col')), + request()->input('sort_way') + ); } } elseif (Schema::hasColumn($table, 'order')) { $query = $query->orderBy('order', 'ASC'); diff --git a/app/Http/Requests/Bo/UpdateMiniCrudRequest.php b/app/Http/Requests/Bo/UpdateMiniCrudRequest.php index ac3d1d0..6af3b82 100644 --- a/app/Http/Requests/Bo/UpdateMiniCrudRequest.php +++ b/app/Http/Requests/Bo/UpdateMiniCrudRequest.php @@ -108,7 +108,7 @@ abstract class UpdateMiniCrudRequest extends FormRequest $rules = array_merge($rules, [ "data.$iptName.value" => [ function (string $attribute, $value, callable $fail) use ($sizes) { - return ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes); + ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes); } ], $this->compileValidate( diff --git a/app/Http/Requests/Bo/Users/UpdateUserRequest.php b/app/Http/Requests/Bo/Users/UpdateUserRequest.php index bdd2489..6c587c9 100644 --- a/app/Http/Requests/Bo/Users/UpdateUserRequest.php +++ b/app/Http/Requests/Bo/Users/UpdateUserRequest.php @@ -28,9 +28,9 @@ class UpdateUserRequest extends StoreUserRequest $this->merge([ 'published' => $this->boolean('published'), 'password' => $this->input('password') ?? - $this->route('user')->password, + \optional($this->route('user'))->password, 'password_confirmation' => $this->input('password_confirmation') ?? - $this->route('user')->password + \optional($this->route('user'))->password ]); } @@ -45,7 +45,7 @@ class UpdateUserRequest extends StoreUserRequest 'email' => [ 'required', 'email:rfc,strict,dns,spoof,filter', - Rule::unique('users', 'email')->ignore($this->route('user')->getRouteKey()) + Rule::unique('users', 'email')->ignore(\optional($this->route('user'))->getRouteKey()) ], 'password' => [ 'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8) diff --git a/app/Lib/Helpers/ExceptionsHelper.php b/app/Lib/Helpers/ExceptionsHelper.php index 4813275..30deb54 100644 --- a/app/Lib/Helpers/ExceptionsHelper.php +++ b/app/Lib/Helpers/ExceptionsHelper.php @@ -145,7 +145,7 @@ class ExceptionsHelper $traceStr .= self::handleArgs($stack); } $traceStr .= ")\n"; - } elseif (isset($stack['function'])) { + } else { $traceStr .= "{$stack['function']}("; if (isset($stack['args'])) { $traceStr .= self::handleArgs($stack); diff --git a/app/Lib/Helpers/FileStorageHelper.php b/app/Lib/Helpers/FileStorageHelper.php index 22ddf64..f66386b 100644 --- a/app/Lib/Helpers/FileStorageHelper.php +++ b/app/Lib/Helpers/FileStorageHelper.php @@ -322,8 +322,7 @@ class FileStorageHelper $folderPath = self::getStoragePath( $private ? 'app/private/modelfiles' : 'app/public/modelfiles', $tableName, - $filename, - $private + $filename ); $filename = self::getFileUniqueName($folderPath, $filename); return "{$folderPath}/{$filename}"; @@ -418,7 +417,7 @@ class FileStorageHelper $filename = Str::of($filename)->ltrim('.-'); // * Optional beautification if ($beautify) { - $filename = static::beautifyFilename($filename); + $filename = self::beautifyFilename($filename); } // * Maximize filename length to 255 bytes http://serverfault.com/a/9548/44086 /** @var string */ diff --git a/app/Lib/Helpers/ToolboxHelper.php b/app/Lib/Helpers/ToolboxHelper.php index 17db496..2672f4a 100644 --- a/app/Lib/Helpers/ToolboxHelper.php +++ b/app/Lib/Helpers/ToolboxHelper.php @@ -205,11 +205,10 @@ class ToolboxHelper $url = $match; try { $request = Request::create($url); - // If a route is match then it do not throws exception. - if ( - \parse_url(config('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST) && - $routes->match($request) - ) { + // Assert route matches existing routes. + $routes->match($request); + // ? Is url internal ? + if (\parse_url(config('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST)) { // Removes the matched url. throw ValidationException::withMessages([ $field => trans( @@ -235,14 +234,14 @@ class ToolboxHelper * @param array|string $replace * @param array|string $subject * @param integer $count - * @return array|string + * @return array|string|false */ public static function mbReplace( array|string $search, array|string $replace, array|string $subject, int &$count = 0 - ): array|string { + ): array|string|false { if (!is_array($search) && is_array($replace)) { return false; } @@ -320,11 +319,15 @@ class ToolboxHelper { if ( \in_array('Spatie\Translatable\HasTranslations', \class_uses_recursive($model)) and + // @phpstan-ignore-next-line $model->isTranslatableAttribute($attribute) ) { + // @phpstan-ignore-next-line return $model->getTranslation( $attribute, + // @phpstan-ignore-next-line $model->getLocale(), + // @phpstan-ignore-next-line $model->useFallbackLocale() ); } @@ -394,47 +397,45 @@ class ToolboxHelper /** * Convert deeply an object to array * - * @param array|object $input + * @param mixed $input * @return array * @throws \RuntimeException If $input var is a scalar value. */ - public static function objectToArray($input): array + public static function objectToArray(mixed $input): array { // Only process if it's an object or array being passed to the function. - if (is_object($input) or is_array($input)) { - $ret = (array)$input; - foreach ($ret as &$item) { - // Recursively process EACH element only if not scalar. - $item = (is_object($item) or is_array($item)) ? - self::objectToArray($item) : $item; - } - return $ret; - } else { + if (!(is_object($input) or is_array($input))) { throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input)); } + $ret = (array)$input; + foreach ($ret as &$item) { + // Recursively process EACH element only if not scalar. + $item = (is_object($item) or is_array($item)) ? + self::objectToArray($item) : $item; + } + return $ret; } /** * Convert deeply an array to object * - * @param array|object $input + * @param mixed $input * @return object * @throws \RuntimeException If $input var is a scalar value. */ - public static function arrayToObject($input): object + public static function arrayToObject(mixed $input): object { // Only process if it's an object or array being passed to the function. - if (is_object($input) or is_array($input)) { - $ret = (object)$input; - foreach ($ret as &$item) { - // Recursively process EACH element only if not scalar. - $item = (is_object($item) or is_array($item)) ? - self::arrayToObject($item) : $item; - } - return $ret; - } else { + if (!(is_object($input) or is_array($input))) { throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input)); } + $ret = (object)$input; + foreach ($ret as &$item) { + // Recursively process EACH element only if not scalar. + $item = (is_object($item) or is_array($item)) ? + self::arrayToObject($item) : $item; + } + return $ret; } /** @@ -442,11 +443,11 @@ class ToolboxHelper * * @param string $attribute * @param string|null $value - * @param callback $fail + * @param callable $fail * @param object $sizes * @return void */ - public static function validatePicture(string $attribute, string|null $value, callable $fail, object $sizes) + public static function validatePicture(string $attribute, string|null $value, callable $fail, object $sizes): void { if (!($useStorage = Storage::exists($value)) and !File::exists($value)) { $fail(trans(':attribute n\'existe pas dans le système de fichier', [ @@ -454,7 +455,6 @@ class ToolboxHelper ])); return; } - /** @var string */ $fileFullPath = self::getUploadedFileFullPath($value, $useStorage); if ( !\in_array(self::getUploadedFileMimeType($value, $useStorage), [ @@ -465,7 +465,7 @@ class ToolboxHelper 'attribute' => $attribute ])); } - if (!($dimensions = \getimagesize($fileFullPath)) or !isset($dimensions[0]) or !isset($dimensions[1])) { + if (!($dimensions = \getimagesize($fileFullPath))) { $fail(trans(':attribute impossible de valider les dimensions', [ 'attribute' => $attribute ])); diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index 0eca06b..3d44694 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -3,18 +3,17 @@ namespace App\Models; use App\Enums\ActivityLogs\ActivityLogsEventEnum; -use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; use Illuminate\Support\Facades\Schema; /** - * @property string $model Target model. - * @property string $model_id Id of the target model. - * @property string $event Event of this activity (ActivityLogsEventEnum). - * @property string $data Changes. - * @property-read \Illuminate\Support\Carbon $created_at Created date. + * @property string $model Target model. + * @property string $model_id Id of the target model. + * @property \App\Enums\ActivityLogs\ActivityLogsEventEnum $event Event of this activity (ActivityLogsEventEnum). + * @property array $data Changes. + * @property-read \Illuminate\Support\Carbon $created_at Created date. * * @property-read \App\Models\User $user User BelongsTo relation. */ @@ -82,19 +81,20 @@ class ActivityLog extends Model $activity->model_id = $model->getKey(); $activity->event = $eventEnum; $activity->data = static::getChangedColumns($activity, $model, $eventEnum); - $activity->created_at = Carbon::now(); + // @phpstan-ignore-next-line + $activity->created_at = now(); $activity->saveOrFail(); } /** * Get old, new columns that has changed. * - * @param \self $activity + * @param self $activity * @param \Illuminate\Database\Eloquent\Model $model * @param \App\Enums\ActivityLogs\ActivityLogsEventEnum $eventEnum - * @return array|null + * @return array */ - public static function getChangedColumns(self $activity, Model $model, ActivityLogsEventEnum $eventEnum): array|null + public static function getChangedColumns(self $activity, Model $model, ActivityLogsEventEnum $eventEnum): array { $modelClassName = $activity->model_class; /** Get type of each fields of the target model */ @@ -109,10 +109,11 @@ class ActivityLog extends Model return Schema::getColumnType($targetModel->getTable(), $fieldIndex); })->toArray(); // phpcs:enable + /** Return old, new and type of values changed */ + return ($eventEnum === ActivityLogsEventEnum::updated) ? + array_intersect_key($targetModelTypes, $model->getChanges()) : []; } - /** Return old, new and type of values changed */ - return ($eventEnum === ActivityLogsEventEnum::updated) ? - array_intersect_key($targetModelTypes, $model->getChanges()) : null; + return []; } // * RELATIONS diff --git a/app/Models/StaticPage.php b/app/Models/StaticPage.php index 1639079..204758e 100644 --- a/app/Models/StaticPage.php +++ b/app/Models/StaticPage.php @@ -54,14 +54,14 @@ class StaticPage extends Model { static::creating(function (self $model) { // * ASSERTIONS - static::assertTitleIsUnique($model->title); + self::assertTitleIsUnique($model->title); // * CHANGES $model->slug = Str::slug($model->title); }); static::updating(function (self $model) { // * ASSERTIONS - static::assertTitleIsUnique($model->title, $model->id); + self::assertTitleIsUnique($model->title, $model->id); // * CHANGES $model->slug = Str::slug($model->title); diff --git a/app/Models/User.php b/app/Models/User.php index d4d8763..8dc7ebd 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -74,7 +74,7 @@ class User extends Authenticatable protected static function booted(): void { static::creating(function (self $model) { - static::updatePassword($model); + self::updatePassword($model); // * Prevent user elevation privileges throw_if( auth('backend')->user() and auth('backend')->user()->role->value() > $model->role->value(), @@ -82,7 +82,7 @@ class User extends Authenticatable ); }); static::updating(function (self $model) { - static::updatePassword($model); + self::updatePassword($model); if (optional(auth('backend')->user())->getKey() === $model->getKey()) { \validator( ['published' => $model->published], diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 3b6f2ff..e2e4129 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -80,9 +80,9 @@ class RouteServiceProvider extends ServiceProvider } // * Flatten if needed $cspReport = collect(request()->json('csp-report')) - ->flatMap(function ($v, $k) { - return [$k => is_array($v) ? collect($v)->flatten()->implode(', ') : $v]; - })->all(); + ->flatMap(function ($v, $k) { + return [$k => is_array($v) ? collect($v)->flatten()->implode(', ') : $v]; + })->all(); // * Filter array keys $cspReport = collect(array_intersect_key($cspReport, [ 'blocked-uri' => '', 'document-uri' => '', 'original-policy' => '', diff --git a/app/Providers/TranslationServiceProvider.php b/app/Providers/TranslationServiceProvider.php index 9e57b48..9b3029f 100644 --- a/app/Providers/TranslationServiceProvider.php +++ b/app/Providers/TranslationServiceProvider.php @@ -47,6 +47,8 @@ class TranslationServiceProvider extends ServiceProvider */ private function collectLocalesStrings(): Collection { + // * En dur dans ->keys array. + // @phpstan-ignore-next-line return collect(File::allFiles(resource_path('lang/')))->flatMap(function (SplFileInfo $file) { if ($file->getRelativePath() and \strpos($file->getRelativePath(), 'vendor') !== 0) { return [$file->getRelativePath() => '']; diff --git a/app/Traits/Controllers/ChangesModelOrder.php b/app/Traits/Controllers/ChangesModelOrder.php index 30476a8..235f2fb 100644 --- a/app/Traits/Controllers/ChangesModelOrder.php +++ b/app/Traits/Controllers/ChangesModelOrder.php @@ -37,8 +37,6 @@ trait ChangesModelOrder throw new \RuntimeException("The {$className} doesn't match second last binded param."); } - /** @var \Illuminate\Database\Eloquent\Model $model */ - /** @var \Illuminate\Database\Eloquent\Model|null */ $model = $className::query()->where($model->getRouteKeyName(), $model->getRouteKey())->first(); @@ -48,18 +46,16 @@ trait ChangesModelOrder return DB::transaction(function () use ($request, $className, $model) { /** @var \Illuminate\Database\Eloquent\Model|null */ - $tmp = $className::query()->where('order', $request->direction ? '<' : '>', $model->order) + $tmp = $className::where('order', $request->direction ? '<' : '>', $model->getOriginal('order')) ->orderBy('order', $request->direction ? 'DESC' : 'ASC')->first(); if (!$tmp) { return back()->with('error', trans('crud.messages.order_not_changed')); } - $newOrder = $tmp->order; - $tmp->order = $model->order; - $model->order = $newOrder; - $tmp->saveOrFail(); - $model->saveOrFail(); + $newOrder = $tmp->getOriginal('order'); + $tmp->update(['order' => $model->getOriginal('order')]); + $model->update(['order' => $newOrder]); Session::flash('success', trans('crud.messages.order_changed')); return back(); diff --git a/app/Traits/Controllers/UpdateModelPublished.php b/app/Traits/Controllers/UpdateModelPublished.php index 4ca47df..05691b1 100644 --- a/app/Traits/Controllers/UpdateModelPublished.php +++ b/app/Traits/Controllers/UpdateModelPublished.php @@ -19,8 +19,7 @@ trait UpdateModelPublished */ public function changePublished(Model $model) { - $model->published = !$model->published; - $model->saveOrFail(); + $model->update(['published' => !$model->getOriginal('published')]); return redirect()->back()->with('success', trans(__('crud.messages.publish_status_saved'))); } } diff --git a/app/Traits/Enums/BaseEnum.php b/app/Traits/Enums/BaseEnum.php index 559b1ee..d6016cb 100644 --- a/app/Traits/Enums/BaseEnum.php +++ b/app/Traits/Enums/BaseEnum.php @@ -118,9 +118,9 @@ trait BaseEnum /** * Fetch enum using value. * - * @param \App\Traits\Enums\BaseEnum|integer|string $value - * @param string $field - * @return \App\Traits\Enums\BaseEnum|null + * @param self|integer|string $value + * @param string $field + * @return self|null */ public static function make(self|int|string $value, string $field = 'value'): self|null { diff --git a/app/Traits/Models/IsCachedAsCollection.php b/app/Traits/Models/IsCachedAsCollection.php index f8ede85..b1f3f36 100644 --- a/app/Traits/Models/IsCachedAsCollection.php +++ b/app/Traits/Models/IsCachedAsCollection.php @@ -10,7 +10,8 @@ use Illuminate\Support\Facades\Cache; /** * ! Use this only on limited elements, (not on tags, or products, or posts for ex.) * - * @property private static array $cacheConditions Eloquent condition to cache elements (to be used in where statement). + * @property array $cacheConditions + * Eloquent condition to cache elements (to be used in where statement). */ trait IsCachedAsCollection { diff --git a/composer.json b/composer.json index 366c78e..fd3dfc1 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "fakerphp/faker": "^1.9.1", "kitloong/laravel-migrations-generator": "^6.8", "krlove/eloquent-model-generator": "dev-l10-compatibility", + "larastan/larastan": "^2.6", "laravel-lang/common": "^4.0", "laravel/pint": "^1.0", "laravel/sail": "^1.18", diff --git a/composer.lock b/composer.lock index ffb664b..d982679 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f6f8667757d8be0e48544e0bc4e250e5", + "content-hash": "75b92f490be12ee8374198d536fedef3", "packages": [ { "name": "brick/math", @@ -8313,6 +8313,102 @@ }, "time": "2023-01-30T20:15:06+00:00" }, + { + "name": "larastan/larastan", + "version": "v2.6.4", + "source": { + "type": "git", + "url": "https://github.com/larastan/larastan.git", + "reference": "6c5e8820f3db6397546f3ce48520af9d312aed27" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/larastan/larastan/zipball/6c5e8820f3db6397546f3ce48520af9d312aed27", + "reference": "6c5e8820f3db6397546f3ce48520af9d312aed27", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/console": "^9.47.0 || ^10.0.0", + "illuminate/container": "^9.47.0 || ^10.0.0", + "illuminate/contracts": "^9.47.0 || ^10.0.0", + "illuminate/database": "^9.47.0 || ^10.0.0", + "illuminate/http": "^9.47.0 || ^10.0.0", + "illuminate/pipeline": "^9.47.0 || ^10.0.0", + "illuminate/support": "^9.47.0 || ^10.0.0", + "php": "^8.0.2", + "phpmyadmin/sql-parser": "^5.6.0", + "phpstan/phpstan": "~1.10.6" + }, + "require-dev": { + "nikic/php-parser": "^4.15.2", + "orchestra/testbench": "^7.19.0 || ^8.0.0", + "phpunit/phpunit": "^9.5.27" + }, + "suggest": { + "orchestra/testbench": "Using Larastan for analysing a package needs Testbench" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "NunoMaduro\\Larastan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "larastan", + "laravel", + "package", + "php", + "static analysis" + ], + "support": { + "issues": "https://github.com/larastan/larastan/issues", + "source": "https://github.com/larastan/larastan/tree/v2.6.4" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/canvural", + "type": "github" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2023-07-29T12:13:13+00:00" + }, { "name": "laravel-lang/attributes", "version": "v2.4.1", @@ -9260,6 +9356,93 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpmyadmin/sql-parser", + "version": "5.8.2", + "source": { + "type": "git", + "url": "https://github.com/phpmyadmin/sql-parser.git", + "reference": "f1720ae19abe6294cb5599594a8a57bc3c8cc287" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/f1720ae19abe6294cb5599594a8a57bc3c8cc287", + "reference": "f1720ae19abe6294cb5599594a8a57bc3c8cc287", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-php80": "^1.16" + }, + "conflict": { + "phpmyadmin/motranslator": "<3.0" + }, + "require-dev": { + "phpbench/phpbench": "^1.1", + "phpmyadmin/coding-standard": "^3.0", + "phpmyadmin/motranslator": "^4.0 || ^5.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.9.12", + "phpstan/phpstan-phpunit": "^1.3.3", + "phpunit/php-code-coverage": "*", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "^0.16.1", + "vimeo/psalm": "^4.11", + "zumba/json-serializer": "~3.0.2" + }, + "suggest": { + "ext-mbstring": "For best performance", + "phpmyadmin/motranslator": "Translate messages to your favorite locale" + }, + "bin": [ + "bin/highlight-query", + "bin/lint-query", + "bin/tokenize-query" + ], + "type": "library", + "autoload": { + "psr-4": { + "PhpMyAdmin\\SqlParser\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "The phpMyAdmin Team", + "email": "developers@phpmyadmin.net", + "homepage": "https://www.phpmyadmin.net/team/" + } + ], + "description": "A validating SQL lexer and parser with a focus on MySQL dialect.", + "homepage": "https://github.com/phpmyadmin/sql-parser", + "keywords": [ + "analysis", + "lexer", + "parser", + "query linter", + "sql", + "sql lexer", + "sql linter", + "sql parser", + "sql syntax highlighter", + "sql tokenizer" + ], + "support": { + "issues": "https://github.com/phpmyadmin/sql-parser/issues", + "source": "https://github.com/phpmyadmin/sql-parser" + }, + "funding": [ + { + "url": "https://www.phpmyadmin.net/donate/", + "type": "other" + } + ], + "time": "2023-09-19T12:34:29+00:00" + }, { "name": "phpstan/phpdoc-parser", "version": "1.24.0", @@ -9307,6 +9490,68 @@ }, "time": "2023-09-07T20:46:32+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.10.56", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "27816a01aea996191ee14d010f325434c0ee76fa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/27816a01aea996191ee14d010f325434c0ee76fa", + "reference": "27816a01aea996191ee14d010f325434c0ee76fa", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2024-01-15T10:43:00+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "10.1.5", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..df74d87 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +includes: + - vendor/larastan/larastan/extension.neon + +parameters: + + paths: + - app/ + + # Level 9 is the highest level + level: 5