diff --git a/app/Conductors/AnalyticsConductor.php b/app/Conductors/AnalyticsConductor.php index f957b60..19ed4d6 100644 --- a/app/Conductors/AnalyticsConductor.php +++ b/app/Conductors/AnalyticsConductor.php @@ -19,7 +19,7 @@ class AnalyticsConductor extends Conductor * The Model Class * @var string */ - protected $class = '\App\Models\Analytics'; + protected $class = \App\Models\Analytics::class; /** * The default sorting field @@ -41,7 +41,7 @@ class AnalyticsConductor extends Conductor * @param Model $model The model. * @return boolean Allow model to be visible. */ - public static function viewable(Model $model) + public static function viewable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/analytics') === true); @@ -52,7 +52,7 @@ class AnalyticsConductor extends Conductor * * @return boolean Allow creating model. */ - public static function creatable() + public static function creatable(): bool { return true; } @@ -63,7 +63,7 @@ class AnalyticsConductor extends Conductor * @param Model $model The model. * @return boolean Allow updating model. */ - public static function updatable(Model $model) + public static function updatable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/analytics') === true); @@ -75,7 +75,7 @@ class AnalyticsConductor extends Conductor * @param Model $model The model. * @return boolean Allow deleting model. */ - public static function destroyable(Model $model) + public static function destroyable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/analytics') === true); diff --git a/app/Conductors/ArticleConductor.php b/app/Conductors/ArticleConductor.php index 437c323..2a1a0b5 100644 --- a/app/Conductors/ArticleConductor.php +++ b/app/Conductors/ArticleConductor.php @@ -19,7 +19,7 @@ class ArticleConductor extends Conductor * The Model Class * @var string */ - protected $class = '\App\Models\Article'; + protected $class = \App\Models\Article::class; /** * The default sorting field @@ -39,9 +39,8 @@ class ArticleConductor extends Conductor * Run a scope query on the collection before anything else. * * @param Builder $builder The builder in use. - * @return void */ - public function scope(Builder $builder) + public function scope(Builder $builder): void { $user = auth()->user(); if ($user === null || $user->hasPermission('admin/articles') === false) { @@ -56,7 +55,7 @@ class ArticleConductor extends Conductor * @param Model $model The model. * @return boolean Allow model to be visible. */ - public static function viewable(Model $model) + public static function viewable(Model $model): bool { if (Carbon::parse($model->publish_at)->isFuture() === true) { $user = auth()->user(); @@ -73,7 +72,7 @@ class ArticleConductor extends Conductor * * @return boolean Allow creating model. */ - public static function creatable() + public static function creatable(): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/articles') === true); @@ -85,7 +84,7 @@ class ArticleConductor extends Conductor * @param Model $model The model. * @return boolean Allow updating model. */ - public static function updatable(Model $model) + public static function updatable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/articles') === true); @@ -97,7 +96,7 @@ class ArticleConductor extends Conductor * @param Model $model The model. * @return boolean Allow deleting model. */ - public static function destroyable(Model $model) + public static function destroyable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/articles') === true); @@ -109,7 +108,7 @@ class ArticleConductor extends Conductor * @param array $data The model data to transform. * @return array The transformed model. */ - public function transformFinal(array $data) + public function transformFinal(array $data): array { unset($data['user_id']); return $data; @@ -145,7 +144,7 @@ class ArticleConductor extends Conductor * @param mixed $value The current value. * @return array The new value. */ - public function transformHero(mixed $value) + public function transformHero(mixed $value): array { return MediaConductor::includeModel(request(), 'hero', Media::find($value)); } diff --git a/app/Conductors/Conductor.php b/app/Conductors/Conductor.php index 02fb11e..f25d0a2 100644 --- a/app/Conductors/Conductor.php +++ b/app/Conductors/Conductor.php @@ -81,7 +81,7 @@ class Conductor * @param string $string The string to split. * @return array The split string. */ - private function splitString(string $string) + private function splitString(string $string): array { $parts = []; $start = 0; @@ -143,9 +143,8 @@ class Conductor * * @param Request $request The user request. * @param array|null $limitFields A list of fields to limit the filter request to. - * @return void */ - private function filter(Request $request, array|null $limitFields = null) + private function filter(Request $request, array|null $limitFields = null): void { if (is_array($limitFields) === true && count($limitFields) === 0) { $limitFields = null; @@ -210,10 +209,8 @@ class Conductor /** * Apple the filter array to the collection. - * - * @return void */ - final public function applyFilters() + final public function applyFilters(): void { $parseFunc = function ($filterArray, $query) use (&$parseFunc) { $item = null; @@ -365,7 +362,7 @@ class Conductor * @param Request $request The request data. * @return array The processed and transformed collection | the total rows found. */ - final public static function request(Request $request) + final public static function request(Request $request): array { $conductor_class = get_called_class(); $conductor = new $conductor_class(); @@ -457,7 +454,7 @@ class Conductor * @param Collection $collection The collection. * @return array The processed and transformed model data. */ - final public static function collection(Request $request, Collection $collection) + final public static function collection(Request $request, Collection $collection): array { $conductor_class = get_called_class(); $conductor = new $conductor_class(); @@ -503,9 +500,8 @@ class Conductor * @param Builder $query The custom query. * @param Request $request The request. * @param array|null $limitFields Limit the request to these fields. - * @return Builder */ - public static function filterQuery(Builder $query, Request $request, array|null $limitFields = null) + public static function filterQuery(Builder $query, Request $request, array|null $limitFields = null): Builder { $conductor_class = get_called_class(); $conductor = new $conductor_class(); @@ -525,7 +521,7 @@ class Conductor * @param Model|null $model The model. * @return array The processed and transformed model data. */ - final public static function includeModel(Request $request, string $key, mixed $model) + final public static function includeModel(Request $request, string $key, mixed $model): array { $fields = []; @@ -553,7 +549,7 @@ class Conductor * @param Model|null $model The model. * @return array The processed and transformed model data. */ - final public static function model(mixed $fields, mixed $model) + final public static function model(mixed $fields, mixed $model): array { if ($model === null) { return null; @@ -606,7 +602,7 @@ class Conductor * * @return integer The current collection count. */ - final public function count() + final public function count(): int { if ($this->query !== null) { return $this->query->count(); @@ -619,9 +615,8 @@ class Conductor * Sort the conductor collection. * * @param mixed $fields A field name or array of field names to sort. Supports prefix of +/- to change direction. - * @return void */ - final public function sort(mixed $fields = null) + final public function sort(mixed $fields = null): void { $collectionSort = []; @@ -698,9 +693,8 @@ class Conductor * * @param Model $model The model to append. * @param array $includes The list of includes to include. - * @return void */ - final public function applyIncludes(Model $model, array $includes) + final public function applyIncludes(Model $model, array $includes): void { foreach ($includes as $include) { $includeMethodName = 'include' . Str::studly($include); @@ -718,9 +712,8 @@ class Conductor * Limit the returned fields in the conductor collection. * * @param array $fields An array of field names. - * @return void */ - final public function limitFields(array $fields) + final public function limitFields(array $fields): void { if (empty($fields) !== true) { $this->query->select(array_diff($fields, $this->includes)); @@ -733,9 +726,8 @@ class Conductor * @param string $rawFilter The raw filter string to parse. * @param array|null $limitFields The fields to allow in the filter string. * @param string $outerJoin The join for this filter group. - * @return void */ - final public function appendFilterString(string $rawFilter, array|null $limitFields = null, string $outerJoin = 'OR') + final public function appendFilterString(string $rawFilter, array|null $limitFields = null, string $outerJoin = 'OR'): void { if ($rawFilter === '') { return; @@ -847,9 +839,8 @@ class Conductor * @param string $operator The operator to append. * @param string $value The value to append. * @param string $join The join to append. - * @return void */ - final public function appendFilter(string $field, string $operator, string $value, string $join = 'OR') + final public function appendFilter(string $field, string $operator, string $value, string $join = 'OR'): void { if (count($this->filterArray) !== 0) { $this->filterArray[] = $join; @@ -861,9 +852,8 @@ class Conductor * Run a scope query on the collection before anything else. * * @param Builder $builder The builder in use. - * @return void */ - public function scope(Builder $builder) + public function scope(Builder $builder): void { } @@ -873,7 +863,7 @@ class Conductor * @param Model $model The model in question. * @return array The array of field names. */ - public function fields(Model $model) + public function fields(Model $model): array { $visibleFields = $model->getVisible(); if (empty($visibleFields) === true) { @@ -900,7 +890,7 @@ class Conductor * @param Model $model The model to transform. * @return array The transformed model. */ - protected function transformModel(Model $model) + protected function transformModel(Model $model): array { $result = $this->transform($model); foreach ($result as $key => $value) { @@ -920,7 +910,7 @@ class Conductor * @param Model $model The model to transform. * @return array The transformed model. */ - public function transform(Model $model) + public function transform(Model $model): array { $result = $model->toArray(); @@ -939,7 +929,7 @@ class Conductor * @param array $data The model array to transform. * @return array The transformed model. */ - public function transformFinal(array $data) + public function transformFinal(array $data): array { return $data; } @@ -950,7 +940,7 @@ class Conductor * @param Model $model The model in question. * @return boolean Is the model viewable. */ - public static function viewable(Model $model) + public static function viewable(Model $model): bool { return true; } @@ -960,7 +950,7 @@ class Conductor * * @return boolean Is the model creatable. */ - public static function creatable() + public static function creatable(): bool { return true; } @@ -971,7 +961,7 @@ class Conductor * @param Model $model The model in question. * @return boolean Is the model updatable. */ - public static function updatable(Model $model) + public static function updatable(Model $model): bool { return true; } @@ -982,7 +972,7 @@ class Conductor * @param Model $model The model in question. * @return boolean Is the model destroyable. */ - public static function destroyable(Model $model) + public static function destroyable(Model $model): bool { return true; } diff --git a/app/Conductors/EventConductor.php b/app/Conductors/EventConductor.php index a2b482a..260b547 100644 --- a/app/Conductors/EventConductor.php +++ b/app/Conductors/EventConductor.php @@ -14,7 +14,7 @@ class EventConductor extends Conductor * The Model Class * @var string */ - protected $class = '\App\Models\Event'; + protected $class = \App\Models\Event::class; /** * The default sorting field @@ -33,9 +33,8 @@ class EventConductor extends Conductor * Run a scope query on the collection before anything else. * * @param Builder $builder The builder in use. - * @return void */ - public function scope(Builder $builder) + public function scope(Builder $builder): void { $user = auth()->user(); if ($user === null || $user->hasPermission('admin/events') === false) { @@ -51,7 +50,7 @@ class EventConductor extends Conductor * @param Model $model The model. * @return boolean Allow model to be visible. */ - public static function viewable(Model $model) + public static function viewable(Model $model): bool { if (strtolower($model->status) === 'draft' || Carbon::parse($model->publish_at)->isFuture() === true) { $user = auth()->user(); @@ -68,7 +67,7 @@ class EventConductor extends Conductor * * @return boolean Allow creating model. */ - public static function creatable() + public static function creatable(): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/events') === true); @@ -80,7 +79,7 @@ class EventConductor extends Conductor * @param Model $model The model. * @return boolean Allow updating model. */ - public static function updatable(Model $model) + public static function updatable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/events') === true); @@ -92,7 +91,7 @@ class EventConductor extends Conductor * @param Model $model The model. * @return boolean Allow deleting model. */ - public static function destroyable(Model $model) + public static function destroyable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/events') === true); @@ -121,7 +120,7 @@ class EventConductor extends Conductor * @param mixed $value The current value. * @return array The new value. */ - public function transformHero(mixed $value) + public function transformHero(mixed $value): array { return MediaConductor::includeModel(request(), 'hero', Media::find($value)); } diff --git a/app/Conductors/MediaConductor.php b/app/Conductors/MediaConductor.php index 16abbee..25fd9ee 100644 --- a/app/Conductors/MediaConductor.php +++ b/app/Conductors/MediaConductor.php @@ -12,7 +12,7 @@ class MediaConductor extends Conductor * The Model Class * @var string */ - protected $class = '\App\Models\Media'; + protected $class = \App\Models\Media::class; /** * The default sorting field @@ -43,7 +43,7 @@ class MediaConductor extends Conductor * @param Model $model The model in question. * @return array The array of field names. */ - public function fields(Model $model) + public function fields(Model $model): array { $fields = parent::fields($model); @@ -59,9 +59,8 @@ class MediaConductor extends Conductor * Run a scope query on the collection before anything else. * * @param Builder $builder The builder in use. - * @return void */ - public function scope(Builder $builder) + public function scope(Builder $builder): void { $user = auth()->user(); if ($user === null) { @@ -77,7 +76,7 @@ class MediaConductor extends Conductor * @param Model $model The model. * @return boolean Allow model to be visible. */ - public static function viewable(Model $model) + public static function viewable(Model $model): bool { if ($model->permission !== '') { $user = auth()->user(); @@ -94,7 +93,7 @@ class MediaConductor extends Conductor * * @return boolean Allow creating model. */ - public static function creatable() + public static function creatable(): bool { $user = auth()->user(); return ($user !== null); @@ -106,7 +105,7 @@ class MediaConductor extends Conductor * @param Model $model The model. * @return boolean Allow updating model. */ - public static function updatable(Model $model) + public static function updatable(Model $model): bool { $user = auth()->user(); return ($user !== null && (strcasecmp($model->user_id, $user->id) === 0 || $user->hasPermission('admin/media') === true)); @@ -118,7 +117,7 @@ class MediaConductor extends Conductor * @param Model $model The model. * @return boolean Allow deleting model. */ - public static function destroyable(Model $model) + public static function destroyable(Model $model): bool { $user = auth()->user(); return ($user !== null && ($model->user_id === $user->id || $user->hasPermission('admin/media') === true)); @@ -130,7 +129,7 @@ class MediaConductor extends Conductor * @param array $data The model data to transform. * @return array The transformed model. */ - public function transformFinal(array $data) + public function transformFinal(array $data): array { unset($data['user_id']); return $data; diff --git a/app/Conductors/ShortlinkConductor.php b/app/Conductors/ShortlinkConductor.php index 9a32bcf..457bdde 100644 --- a/app/Conductors/ShortlinkConductor.php +++ b/app/Conductors/ShortlinkConductor.php @@ -12,7 +12,7 @@ class ShortlinkConductor extends Conductor * The Model Class * @var string */ - protected $class = '\App\Models\Shortlink'; + protected $class = \App\Models\Shortlink::class; /** * The default sorting field @@ -26,7 +26,7 @@ class ShortlinkConductor extends Conductor * * @return boolean Allow creating model. */ - public static function creatable() + public static function creatable(): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/shortlinks') === true); @@ -38,7 +38,7 @@ class ShortlinkConductor extends Conductor * @param Model $model The model. * @return boolean Allow updating model. */ - public static function updatable(Model $model) + public static function updatable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/shortlinks') === true); @@ -50,7 +50,7 @@ class ShortlinkConductor extends Conductor * @param Model $model The model. * @return boolean Allow deleting model. */ - public static function destroyable(Model $model) + public static function destroyable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/shortlinks') === true); diff --git a/app/Conductors/SubscriptionConductor.php b/app/Conductors/SubscriptionConductor.php index 191eed6..fe4e35c 100644 --- a/app/Conductors/SubscriptionConductor.php +++ b/app/Conductors/SubscriptionConductor.php @@ -10,7 +10,7 @@ class SubscriptionConductor extends Conductor * The Model Class * @var string */ - protected $class = '\App\Models\Subscription'; + protected $class = \App\Models\Subscription::class; /** @@ -19,7 +19,7 @@ class SubscriptionConductor extends Conductor * @param Model $model The model. * @return boolean Allow updating model. */ - public static function updatable(Model $model) + public static function updatable(Model $model): bool { $user = auth()->user(); return ($user !== null && ((strcasecmp($model->email, $user->email) === 0 && $user->email_verified_at !== null) || $user->hasPermission('admin/subscriptions') === true)); @@ -31,7 +31,7 @@ class SubscriptionConductor extends Conductor * @param Model $model The model. * @return boolean Allow deleting model. */ - public static function destroyable(Model $model) + public static function destroyable(Model $model): bool { $user = auth()->user(); return ($user !== null && ((strcasecmp($model->email, $user->email) === 0 && $user->email_verified_at !== null) || $user->hasPermission('admin/subscriptions') === true)); diff --git a/app/Conductors/UserConductor.php b/app/Conductors/UserConductor.php index 4c21e69..a756a48 100644 --- a/app/Conductors/UserConductor.php +++ b/app/Conductors/UserConductor.php @@ -10,7 +10,7 @@ class UserConductor extends Conductor * The Model Class * @var string */ - protected $class = '\App\Models\User'; + protected $class = \App\Models\User::class; /** @@ -19,7 +19,7 @@ class UserConductor extends Conductor * @param Model $model The model. * @return string[] The fields visible. */ - public function fields(Model $model) + public function fields(Model $model): array { $user = auth()->user(); if ($user === null || $user->hasPermission('admin/users') === false) { @@ -35,7 +35,7 @@ class UserConductor extends Conductor * @param Model $model The model to transform. * @return array The transformed model. */ - public function transform(Model $model) + public function transform(Model $model): array { $user = auth()->user(); $data = $model->toArray(); @@ -56,7 +56,7 @@ class UserConductor extends Conductor * @param Model $model The model. * @return boolean Allow updating model. */ - public static function updatable(Model $model) + public static function updatable(Model $model): bool { $user = auth()->user(); if ($user !== null) { @@ -72,7 +72,7 @@ class UserConductor extends Conductor * @param Model $model The model. * @return boolean Allow deleting model. */ - public static function destroyable(Model $model) + public static function destroyable(Model $model): bool { $user = auth()->user(); return ($user !== null && $user->hasPermission('admin/users') === true); diff --git a/app/Console/Commands/MediaMigrate.php b/app/Console/Commands/MediaMigrate.php index 2df0e40..99103b1 100644 --- a/app/Console/Commands/MediaMigrate.php +++ b/app/Console/Commands/MediaMigrate.php @@ -27,10 +27,8 @@ class MediaMigrate extends Command /** * Configure the command options. - * - * @return void */ - protected function configure() + protected function configure(): void { $this->addOption( 'replace', @@ -42,10 +40,8 @@ class MediaMigrate extends Command /** * Execute the console command. - * - * @return void */ - public function handle() + public function handle(): void { $replace = $this->option('replace'); diff --git a/app/Console/Commands/MediaRebuild.php b/app/Console/Commands/MediaRebuild.php index a60d64a..a37db86 100644 --- a/app/Console/Commands/MediaRebuild.php +++ b/app/Console/Commands/MediaRebuild.php @@ -26,10 +26,8 @@ class MediaRebuild extends Command /** * Configure the command options. - * - * @return void */ - protected function configure() + protected function configure(): void { $this->addOption( 'replace', @@ -48,10 +46,8 @@ class MediaRebuild extends Command /** * Execute the console command. - * - * @return void */ - public function handle() + public function handle(): void { $replace = $this->option('replace'); $all = $this->option('replace'); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c040de1..03e5175 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -11,19 +11,16 @@ class Kernel extends ConsoleKernel * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule The schedule. - * @return void */ - protected function schedule(Schedule $schedule) + protected function schedule(Schedule $schedule): void { // $schedule->command('inspire')->hourly(); } /** * Register the commands for the application. - * - * @return void */ - protected function commands() + protected function commands(): void { $this->load(__DIR__ . '/Commands'); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index de89608..b35c316 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -12,24 +12,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException; class Handler extends ExceptionHandler { - /** - * A list of exception types with their corresponding custom log levels. - * - * @var array, \Psr\Log\LogLevel::*> - */ - protected $levels = [ - // - ]; - - /** - * A list of the exception types that are not reported. - * - * @var array> - */ - protected $dontReport = [ - // - ]; - /** * A list of the inputs that are never flashed to the session on validation exceptions. * @@ -44,10 +26,8 @@ class Handler extends ExceptionHandler /** * Register the exception handling callbacks for the application. - * - * @return void */ - public function register() + public function register(): void { // $this->renderable(function (HttpException $e, $request) { // if ($request->is('api/*')) { diff --git a/app/Filters/SubscriptionFilter.php b/app/Filters/SubscriptionFilter.php index 04d0d8d..8e210d2 100644 --- a/app/Filters/SubscriptionFilter.php +++ b/app/Filters/SubscriptionFilter.php @@ -11,7 +11,7 @@ class SubscriptionFilter extends FilterAbstract * * @var mixed */ - protected $class = '\App\Models\Subscription'; + protected $class = \App\Models\Subscription::class; /** diff --git a/app/Http/Controllers/Api/ApiController.php b/app/Http/Controllers/Api/ApiController.php index f34909b..1c1678d 100644 --- a/app/Http/Controllers/Api/ApiController.php +++ b/app/Http/Controllers/Api/ApiController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Api; +use Illuminate\Http\JsonResponse; use App\Enum\HttpResponseCodes; use App\Http\Controllers\Controller; use Illuminate\Database\Eloquent\Model; @@ -23,9 +24,8 @@ class ApiController extends Controller * @param array $data Response data. * @param integer $respondCode Response status code. * @param array $headers Response headers. - * @return \Illuminate\Http\JsonResponse */ - public function respondJson(array $data, int $respondCode = HttpResponseCodes::HTTP_OK, array $headers = []) + public function respondJson(array $data, int $respondCode = HttpResponseCodes::HTTP_OK, array $headers = []): JsonResponse { return response()->json($data, $respondCode, $headers); } @@ -34,9 +34,8 @@ class ApiController extends Controller * Return forbidden message * * @param string $message Response message. - * @return \Illuminate\Http\JsonResponse */ - public function respondForbidden(string $message = 'You do not have permission to access the resource.') + public function respondForbidden(string $message = 'You do not have permission to access the resource.'): JsonResponse { return response()->json(['message' => $message], HttpResponseCodes::HTTP_FORBIDDEN); } @@ -45,9 +44,8 @@ class ApiController extends Controller * Return forbidden message * * @param string $message Response message. - * @return \Illuminate\Http\JsonResponse */ - public function respondNotFound(string $message = 'The resource was not found.') + public function respondNotFound(string $message = 'The resource was not found.'): JsonResponse { return response()->json(['message' => $message], HttpResponseCodes::HTTP_NOT_FOUND); } @@ -56,36 +54,32 @@ class ApiController extends Controller * Return too large message * * @param string $message Response message. - * @return \Illuminate\Http\JsonResponse */ - public function respondTooLarge(string $message = 'The request entity is too large.') + public function respondTooLarge(string $message = 'The request entity is too large.'): JsonResponse { return response()->json(['message' => $message], HttpResponseCodes::HTTP_REQUEST_ENTITY_TOO_LARGE); } /** * Return no content - * @return \Illuminate\Http\JsonResponse */ - public function respondNoContent() + public function respondNoContent(): JsonResponse { return response()->json([], HttpResponseCodes::HTTP_NO_CONTENT); } /** * Return created - * @return \Illuminate\Http\JsonResponse */ - public function respondCreated() + public function respondCreated(): JsonResponse { return response()->json([], HttpResponseCodes::HTTP_CREATED); } /** * Return accepted - * @return \Illuminate\Http\JsonResponse */ - public function respondAccepted() + public function respondAccepted(): JsonResponse { return response()->json([], HttpResponseCodes::HTTP_ACCEPTED); } @@ -95,9 +89,8 @@ class ApiController extends Controller * * @param string $message Error message. * @param integer $responseCode Resource code. - * @return \Illuminate\Http\JsonResponse */ - public function respondError(string $message, int $responseCode = HttpResponseCodes::HTTP_UNPROCESSABLE_ENTITY) + public function respondError(string $message, int $responseCode = HttpResponseCodes::HTTP_UNPROCESSABLE_ENTITY): JsonResponse { return response()->json([ 'message' => $message @@ -109,9 +102,8 @@ class ApiController extends Controller * * @param array $errors Error messages. * @param integer $responseCode Resource code. - * @return \Illuminate\Http\JsonResponse */ - public function respondWithErrors(array $errors, int $responseCode = HttpResponseCodes::HTTP_UNPROCESSABLE_ENTITY) + public function respondWithErrors(array $errors, int $responseCode = HttpResponseCodes::HTTP_UNPROCESSABLE_ENTITY): JsonResponse { $keys = array_keys($errors); $error = $errors[$keys[0]]; @@ -132,13 +124,12 @@ class ApiController extends Controller * * @param array|Model|Collection $data Resource data. * @param array $options Respond options. - * @return \Illuminate\Http\JsonResponse */ protected function respondAsResource( mixed $data, array $options = [], $validationFn = null - ) { + ): JsonResponse { $isCollection = $options['isCollection'] ?? false; $appendData = $options['appendData'] ?? null; $resourceName = $options['resourceName'] ?? null; diff --git a/app/Http/Controllers/Api/ArticleController.php b/app/Http/Controllers/Api/ArticleController.php index 5562936..f612f4c 100644 --- a/app/Http/Controllers/Api/ArticleController.php +++ b/app/Http/Controllers/Api/ArticleController.php @@ -126,7 +126,7 @@ class ArticleController extends ApiController * @throws BindingResolutionException * @throws InvalidCastException */ - public function getAttachments(Request $request, Article $article) + public function getAttachments(Request $request, Article $article): JsonResponse { if (ArticleConductor::viewable($article) === true) { $medium = $article->attachments->map(function ($attachment) { @@ -148,7 +148,7 @@ class ArticleController extends ApiController * @throws BindingResolutionException * @throws MassAssignmentException */ - public function storeAttachment(Request $request, Article $article) + public function storeAttachment(Request $request, Article $article): JsonResponse { if (ArticleConductor::updatable($article) === true) { if ($request->has("medium") && Media::find($request->medium)) { @@ -167,11 +167,10 @@ class ArticleController extends ApiController * * @param Request $request The user request. * @param Article $article The related model. - * @return JsonResponse * @throws BindingResolutionException * @throws MassAssignmentException */ - public function updateAttachments(Request $request, Article $article) + public function updateAttachments(Request $request, Article $article): JsonResponse { if (ArticleConductor::updatable($article) === true) { $mediaIds = $request->attachments; @@ -216,10 +215,9 @@ class ArticleController extends ApiController * @param Request $request The user request. * @param Article $article The model. * @param Media $medium The attachment medium. - * @return JsonResponse * @throws BindingResolutionException */ - public function deleteAttachment(Request $request, Article $article, Media $medium) + public function deleteAttachment(Request $request, Article $article, Media $medium): JsonResponse { if (ArticleConductor::updatable($article) === true) { $attachments = $article->attachments; diff --git a/app/Http/Controllers/Api/AuthController.php b/app/Http/Controllers/Api/AuthController.php index f14a647..3fab72d 100644 --- a/app/Http/Controllers/Api/AuthController.php +++ b/app/Http/Controllers/Api/AuthController.php @@ -31,9 +31,8 @@ class AuthController extends ApiController * Current User details * * @param Request $request Current request data. - * @return JsonResponse */ - public function me(Request $request) + public function me(Request $request): JsonResponse { $user = $request->user()->makeVisible(['permissions']); return $this->respondAsResource($user); @@ -87,9 +86,8 @@ class AuthController extends ApiController * Logout current user * * @param Request $request Current request data. - * @return JsonResponse */ - public function logout(Request $request) + public function logout(Request $request): JsonResponse { $user = $request->user(); diff --git a/app/Http/Controllers/Api/EventController.php b/app/Http/Controllers/Api/EventController.php index 52be0b2..f057914 100644 --- a/app/Http/Controllers/Api/EventController.php +++ b/app/Http/Controllers/Api/EventController.php @@ -116,7 +116,7 @@ class EventController extends ApiController * @param Event $event The event model. * @return JsonResponse Returns the event attachments. */ - public function getAttachments(Request $request, Event $event) + public function getAttachments(Request $request, Event $event): JsonResponse { if (EventConductor::viewable($event) === true) { $medium = $event->attachments->map(function ($attachment) { @@ -136,7 +136,7 @@ class EventController extends ApiController * @param Event $event The event model. * @return JsonResponse The response. */ - public function storeAttachment(Request $request, Event $event) + public function storeAttachment(Request $request, Event $event): JsonResponse { if (EventConductor::updatable($event) === true) { if ($request->has("medium") === true && Media::find($request->medium) !== null) { @@ -155,9 +155,8 @@ class EventController extends ApiController * * @param Request $request The user request. * @param Event $event The related model. - * @return JsonResponse */ - public function updateAttachments(Request $request, Event $event) + public function updateAttachments(Request $request, Event $event): JsonResponse { if (EventConductor::updatable($event) === true) { $mediaIds = $request->attachments; @@ -203,9 +202,8 @@ class EventController extends ApiController * @param Request $request The user request. * @param Event $event The model. * @param Media $medium The attachment medium. - * @return JsonResponse */ - public function deleteAttachment(Request $request, Event $event, Media $medium) + public function deleteAttachment(Request $request, Event $event, Media $medium): JsonResponse { if (EventConductor::updatable($event) === true) { $attachments = $event->attachments; diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 4b30169..052ae26 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -145,9 +145,8 @@ class UserController extends ApiController * Register a new user * * @param \App\Http\Requests\UserRegisterRequest $request The register user request. - * @return \Illuminate\Http\Response */ - public function register(UserRegisterRequest $request) + public function register(UserRegisterRequest $request): JsonResponse { try { $userData = $request->only([ @@ -286,9 +285,8 @@ class UserController extends ApiController * Resend a new verify email * * @param \App\Http\Requests\UserResendVerifyEmailRequest $request The resend verify email request. - * @return \Illuminate\Http\Response */ - public function resendVerifyEmail(UserResendVerifyEmailRequest $request) + public function resendVerifyEmail(UserResendVerifyEmailRequest $request): JsonResponse { UserCode::clearExpired(); @@ -340,9 +338,8 @@ class UserController extends ApiController * * @param Request $request The http request. * @param User $user The specified user. - * @return JsonResponse */ - public function eventList(Request $request, User $user) + public function eventList(Request $request, User $user): JsonResponse { if ($request->user() !== null && ($request->user() === $user || $request->user()->hasPermission('admin/events') === true)) { $collection = $user->events; diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index ce1176d..f1406be 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -3,13 +3,11 @@ namespace App\Http\Controllers; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; -use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { use AuthorizesRequests; - use DispatchesJobs; use ValidatesRequests; } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index b63ff09..3031207 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -40,7 +40,7 @@ class Kernel extends HttpKernel 'api' => [ // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, - 'throttle:api', + \Illuminate\Routing\Middleware\ThrottleRequests::class . ':api', \Illuminate\Routing\Middleware\SubstituteBindings::class, // \App\Http\Middleware\ForceJsonResponse::class, 'useSanctumGuard', @@ -49,13 +49,13 @@ class Kernel extends HttpKernel ]; /** - * The application's route middleware. + * The application's middleware aliases. * - * These middleware may be assigned to groups or used individually. + * Aliases may be used to conveniently assign middleware to routes and groups. * * @var array */ - protected $routeMiddleware = [ + protected $middlewareAliases = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 3bb5a9e..76a7ff5 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -10,9 +10,8 @@ class Authenticate extends Middleware * Get the path the user should be redirected to when they are not authenticated. * * @param mixed $request Request. - * @return string|null */ - protected function redirectTo(mixed $request) + protected function redirectTo(mixed $request): ?string { if ($request->expectsJson() === false) { return route('login'); diff --git a/app/Http/Middleware/ForceJsonResponse.php b/app/Http/Middleware/ForceJsonResponse.php index 3311198..cdfa47e 100644 --- a/app/Http/Middleware/ForceJsonResponse.php +++ b/app/Http/Middleware/ForceJsonResponse.php @@ -2,6 +2,7 @@ namespace App\Http\Middleware; +use Symfony\Component\HttpFoundation\Response; use Closure; use Illuminate\Http\Request; @@ -10,11 +11,9 @@ class ForceJsonResponse /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next - * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ - public function handle(Request $request, Closure $next) + public function handle(Request $request, Closure $next): Response { $request->headers->set('Accept', 'application/json'); return $next($request); diff --git a/app/Http/Middleware/LogRequest.php b/app/Http/Middleware/LogRequest.php index 1ecc38f..fdd5642 100644 --- a/app/Http/Middleware/LogRequest.php +++ b/app/Http/Middleware/LogRequest.php @@ -2,6 +2,7 @@ namespace App\Http\Middleware; +use Symfony\Component\HttpFoundation\Response; use Closure; use Illuminate\Http\Request; use App\Models\Analytics; @@ -11,11 +12,9 @@ class LogRequest /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next - * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ - public function handle(Request $request, Closure $next) + public function handle(Request $request, Closure $next): Response { // Make it an after middleware $response = $next($request); diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index e51f28c..ddefde7 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -2,6 +2,7 @@ namespace App\Http\Middleware; +use Symfony\Component\HttpFoundation\Response; use App\Providers\RouteServiceProvider; use Closure; use Illuminate\Http\Request; @@ -12,12 +13,11 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param Request $request Request. - * @param Closure(Request): (Response|RedirectResponse) $next Next. - * @param string|null ...$guards Guards. - * @return Response|RedirectResponse + * @param Request $request Request. + * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next + * @param string|null ...$guards Guards. */ - public function handle(Request $request, Closure $next, ...$guards) + public function handle(Request $request, Closure $next, string ...$guards): Response { $guards = empty($guards) === true ? [null] : $guards; diff --git a/app/Http/Middleware/TrustHosts.php b/app/Http/Middleware/TrustHosts.php index 7186414..c9c58bd 100644 --- a/app/Http/Middleware/TrustHosts.php +++ b/app/Http/Middleware/TrustHosts.php @@ -11,7 +11,7 @@ class TrustHosts extends Middleware * * @return array */ - public function hosts() + public function hosts(): array { return [ $this->allSubdomainsOfApplicationUrl(), diff --git a/app/Http/Middleware/UseSanctumGuard.php b/app/Http/Middleware/UseSanctumGuard.php index 4e4e62d..f7abf14 100644 --- a/app/Http/Middleware/UseSanctumGuard.php +++ b/app/Http/Middleware/UseSanctumGuard.php @@ -2,6 +2,7 @@ namespace App\Http\Middleware; +use Symfony\Component\HttpFoundation\Response; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -11,11 +12,9 @@ class UseSanctumGuard /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next - * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ - public function handle(Request $request, Closure $next) + public function handle(Request $request, Closure $next): Response { Auth::shouldUse('sanctum'); return $next($request); diff --git a/app/Http/Requests/AnalyticsRequest.php b/app/Http/Requests/AnalyticsRequest.php index bc90a99..25ee6eb 100644 --- a/app/Http/Requests/AnalyticsRequest.php +++ b/app/Http/Requests/AnalyticsRequest.php @@ -11,7 +11,7 @@ class AnalyticsRequest extends BaseRequest * * @return array */ - public function postRules() + public function postRules(): array { return [ 'type' => 'required|string', @@ -23,7 +23,7 @@ class AnalyticsRequest extends BaseRequest * * @return array */ - public function putRules() + public function putRules(): array { return [ 'type' => 'string', diff --git a/app/Http/Requests/ArticleRequest.php b/app/Http/Requests/ArticleRequest.php index fb2ac4b..2ad76d7 100644 --- a/app/Http/Requests/ArticleRequest.php +++ b/app/Http/Requests/ArticleRequest.php @@ -11,7 +11,7 @@ class ArticleRequest extends BaseRequest * * @return array */ - public function postRules() + public function postRules(): array { return [ 'slug' => 'required|string|min:6|unique:articles', @@ -28,7 +28,7 @@ class ArticleRequest extends BaseRequest * * @return array */ - public function putRules() + public function putRules(): array { return [ 'slug' => [ diff --git a/app/Http/Requests/AuthLoginRequest.php b/app/Http/Requests/AuthLoginRequest.php index 12baa20..f450276 100644 --- a/app/Http/Requests/AuthLoginRequest.php +++ b/app/Http/Requests/AuthLoginRequest.php @@ -11,7 +11,7 @@ class AuthLoginRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'email' => 'required|string|min:6|max:255', diff --git a/app/Http/Requests/BaseRequest.php b/app/Http/Requests/BaseRequest.php index 8f0ab5d..be6c197 100644 --- a/app/Http/Requests/BaseRequest.php +++ b/app/Http/Requests/BaseRequest.php @@ -9,10 +9,8 @@ class BaseRequest extends FormRequest { /** * Determine if the user is authorized to make this request. - * - * @return boolean */ - public function authorize() + public function authorize(): bool { if (request()->isMethod('post') === true && method_exists($this, 'postAuthorize') === true) { return $this->postAuthorize(); @@ -30,7 +28,7 @@ class BaseRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { $rules = []; @@ -54,9 +52,8 @@ class BaseRequest extends FormRequest * * @param array $collection1 The first collection of rules. * @param array $collection2 The second collection of rules to merge. - * @return array */ - private function mergeRules(array $collection1, array $collection2) + private function mergeRules(array $collection1, array $collection2): array { $rules = []; diff --git a/app/Http/Requests/ContactSendRequest.php b/app/Http/Requests/ContactSendRequest.php index 5e24452..fc9881e 100644 --- a/app/Http/Requests/ContactSendRequest.php +++ b/app/Http/Requests/ContactSendRequest.php @@ -12,7 +12,7 @@ class ContactSendRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'name' => 'required|max:255', diff --git a/app/Http/Requests/EventRequest.php b/app/Http/Requests/EventRequest.php index f1bd1f1..5c152d1 100644 --- a/app/Http/Requests/EventRequest.php +++ b/app/Http/Requests/EventRequest.php @@ -11,7 +11,7 @@ class EventRequest extends BaseRequest * * @return array */ - public function baseRules() + public function baseRules(): array { return [ 'title' => 'min:6', @@ -42,7 +42,7 @@ class EventRequest extends BaseRequest * * @return array */ - protected function postRules() + protected function postRules(): array { return [ 'title' => 'required', diff --git a/app/Http/Requests/ShortlinkRequest.php b/app/Http/Requests/ShortlinkRequest.php index 6c62c68..2a3b67c 100644 --- a/app/Http/Requests/ShortlinkRequest.php +++ b/app/Http/Requests/ShortlinkRequest.php @@ -11,7 +11,7 @@ class ShortlinkRequest extends BaseRequest * * @return array */ - public function postRules() + public function postRules(): array { return [ 'code' => 'required|string|max:255|min:2|unique:shortlinks', @@ -24,7 +24,7 @@ class ShortlinkRequest extends BaseRequest * * @return array */ - public function putRules() + public function putRules(): array { $shortlink = $this->route('shortlink'); diff --git a/app/Http/Requests/SubscriptionRequest.php b/app/Http/Requests/SubscriptionRequest.php index 8a02433..387c14a 100644 --- a/app/Http/Requests/SubscriptionRequest.php +++ b/app/Http/Requests/SubscriptionRequest.php @@ -11,7 +11,7 @@ class SubscriptionRequest extends BaseRequest * * @return array */ - public function postRules() + public function postRules(): array { return [ 'email' => 'required|email|unique:subscriptions', @@ -24,7 +24,7 @@ class SubscriptionRequest extends BaseRequest * * @return array */ - public function destroyRules() + public function destroyRules(): array { return [ 'email' => 'required|email', @@ -34,10 +34,8 @@ class SubscriptionRequest extends BaseRequest /** * Get the custom error messages. - * - * @return array */ - public function messages() + public function messages(): array { return [ 'email.unique' => 'This email address has already subscribed', diff --git a/app/Http/Requests/UserForgotPasswordRequest.php b/app/Http/Requests/UserForgotPasswordRequest.php index eaf6ccf..c45d56f 100644 --- a/app/Http/Requests/UserForgotPasswordRequest.php +++ b/app/Http/Requests/UserForgotPasswordRequest.php @@ -12,7 +12,7 @@ class UserForgotPasswordRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'email' => 'required|exists:users,email', diff --git a/app/Http/Requests/UserRegisterRequest.php b/app/Http/Requests/UserRegisterRequest.php index 73148fc..5557663 100644 --- a/app/Http/Requests/UserRegisterRequest.php +++ b/app/Http/Requests/UserRegisterRequest.php @@ -12,7 +12,7 @@ class UserRegisterRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'display_name' => ['required','string','max:255', new Uniqueish('users')], diff --git a/app/Http/Requests/UserRequest.php b/app/Http/Requests/UserRequest.php index 322e098..95e32f0 100644 --- a/app/Http/Requests/UserRequest.php +++ b/app/Http/Requests/UserRequest.php @@ -15,7 +15,7 @@ class UserRequest extends BaseRequest * * @return array */ - public function postRules() + public function postRules(): array { $user = auth()->user(); $isAdminUser = $user->hasPermission('admin/users'); @@ -40,7 +40,7 @@ class UserRequest extends BaseRequest * * @return array */ - public function putRules() + public function putRules(): array { $user = auth()->user(); $ruleUser = $this->route('user'); diff --git a/app/Http/Requests/UserResendVerifyEmailRequest.php b/app/Http/Requests/UserResendVerifyEmailRequest.php index 92d34b2..09e6442 100644 --- a/app/Http/Requests/UserResendVerifyEmailRequest.php +++ b/app/Http/Requests/UserResendVerifyEmailRequest.php @@ -12,7 +12,7 @@ class UserResendVerifyEmailRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'email' => 'required|exists:users,email', diff --git a/app/Http/Requests/UserResetPasswordRequest.php b/app/Http/Requests/UserResetPasswordRequest.php index 99ed434..55141e5 100644 --- a/app/Http/Requests/UserResetPasswordRequest.php +++ b/app/Http/Requests/UserResetPasswordRequest.php @@ -12,7 +12,7 @@ class UserResetPasswordRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'code' => 'required|digits:6', diff --git a/app/Http/Requests/UserVerifyEmailRequest.php b/app/Http/Requests/UserVerifyEmailRequest.php index e2473e7..29c017e 100644 --- a/app/Http/Requests/UserVerifyEmailRequest.php +++ b/app/Http/Requests/UserVerifyEmailRequest.php @@ -12,7 +12,7 @@ class UserVerifyEmailRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'code' => 'required|digits:6', diff --git a/app/Jobs/MoveMediaJob.php b/app/Jobs/MoveMediaJob.php index afb4c04..9c33b57 100644 --- a/app/Jobs/MoveMediaJob.php +++ b/app/Jobs/MoveMediaJob.php @@ -48,10 +48,8 @@ class MoveMediaJob implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // Don't continue if the media is already on the new storage disk if ($this->media->storage === $this->newStorage) { diff --git a/app/Jobs/SendEmailJob.php b/app/Jobs/SendEmailJob.php index 8b045f8..dcbe010 100644 --- a/app/Jobs/SendEmailJob.php +++ b/app/Jobs/SendEmailJob.php @@ -47,10 +47,8 @@ class SendEmailJob implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { Mail::to($this->to)->send($this->mailable); } diff --git a/app/Jobs/StoreUploadedFileJob.php b/app/Jobs/StoreUploadedFileJob.php index b6ffa26..81862af 100644 --- a/app/Jobs/StoreUploadedFileJob.php +++ b/app/Jobs/StoreUploadedFileJob.php @@ -62,10 +62,8 @@ class StoreUploadedFileJob implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { $storageDisk = $this->media->storage; $fileName = $this->media->name; diff --git a/app/Mail/ChangeEmailVerify.php b/app/Mail/ChangeEmailVerify.php index c055bde..0365ee5 100644 --- a/app/Mail/ChangeEmailVerify.php +++ b/app/Mail/ChangeEmailVerify.php @@ -54,10 +54,8 @@ class ChangeEmailVerify extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: '👋🏻 Lets change your email!', @@ -66,10 +64,8 @@ class ChangeEmailVerify extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'emails.user.change_email_verify', diff --git a/app/Mail/ChangedEmail.php b/app/Mail/ChangedEmail.php index d767b85..71dbe36 100644 --- a/app/Mail/ChangedEmail.php +++ b/app/Mail/ChangedEmail.php @@ -54,10 +54,8 @@ class ChangedEmail extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: '👍 Your email has been changed!', @@ -66,10 +64,8 @@ class ChangedEmail extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'emails.user.changed_email', diff --git a/app/Mail/ChangedPassword.php b/app/Mail/ChangedPassword.php index 8c62937..00451c9 100644 --- a/app/Mail/ChangedPassword.php +++ b/app/Mail/ChangedPassword.php @@ -36,10 +36,8 @@ class ChangedPassword extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: '👍 Your password has been changed!', @@ -48,10 +46,8 @@ class ChangedPassword extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'emails.user.changed_password', diff --git a/app/Mail/Contact.php b/app/Mail/Contact.php index d676fb3..cce5a36 100644 --- a/app/Mail/Contact.php +++ b/app/Mail/Contact.php @@ -53,10 +53,8 @@ class Contact extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: config('contact.contact_subject'), @@ -65,10 +63,8 @@ class Contact extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'emails.user.contact', diff --git a/app/Mail/EmailVerify.php b/app/Mail/EmailVerify.php index 32f0dcb..e8b8097 100644 --- a/app/Mail/EmailVerify.php +++ b/app/Mail/EmailVerify.php @@ -45,10 +45,8 @@ class EmailVerify extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: '👋🏻 Welcome to STEMMechanics!', @@ -57,10 +55,8 @@ class EmailVerify extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'emails.user.email_verify', diff --git a/app/Mail/ForgotPassword.php b/app/Mail/ForgotPassword.php index e48af31..52f5370 100644 --- a/app/Mail/ForgotPassword.php +++ b/app/Mail/ForgotPassword.php @@ -45,10 +45,8 @@ class ForgotPassword extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: '🤦 Forgot your password?', @@ -57,10 +55,8 @@ class ForgotPassword extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'emails.user.forgot_password', diff --git a/app/Mail/SubscriptionConfirm.php b/app/Mail/SubscriptionConfirm.php index c896049..6a534ad 100644 --- a/app/Mail/SubscriptionConfirm.php +++ b/app/Mail/SubscriptionConfirm.php @@ -36,10 +36,8 @@ class SubscriptionConfirm extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: '🗞️ You\'re on the mailing list!', @@ -48,10 +46,8 @@ class SubscriptionConfirm extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'emails.user.subscription_confirm', diff --git a/app/Mail/SubscriptionUnsubscribed.php b/app/Mail/SubscriptionUnsubscribed.php index ce8fdaf..bef9bb4 100644 --- a/app/Mail/SubscriptionUnsubscribed.php +++ b/app/Mail/SubscriptionUnsubscribed.php @@ -36,10 +36,8 @@ class SubscriptionUnsubscribed extends Mailable /** * Get the message envelope. - * - * @return \Illuminate\Mail\Mailables\Envelope */ - public function envelope() + public function envelope(): Envelope { return new Envelope( subject: 'You have been unsubscribed', @@ -48,10 +46,8 @@ class SubscriptionUnsubscribed extends Mailable /** * Get the message content definition. - * - * @return \Illuminate\Mail\Mailables\Content */ - public function content() + public function content(): Content { return new Content( view: 'emails.user.subscription_unsubscribed', diff --git a/app/Models/Analytics.php b/app/Models/Analytics.php index f5c400f..988b181 100644 --- a/app/Models/Analytics.php +++ b/app/Models/Analytics.php @@ -22,9 +22,8 @@ class Analytics extends Model * automatically assigning a session value based on previous rows. * * @param array $attributes Model attributes. - * @return static */ - public static function createWithSession(array $attributes) + public static function createWithSession(array $attributes): static { $previousRow = self::where('useragent', $attributes['useragent']) ->where('ip', $attributes['ip']) diff --git a/app/Models/Article.php b/app/Models/Article.php index 4df85b3..5d4f715 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -29,21 +29,17 @@ class Article extends Model /** * Get the article user - * - * @return BelongsTo */ - public function user() + public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Get all of the article's attachments. - * - * @return MorphMany */ - public function attachments() + public function attachments(): MorphMany { - return $this->morphMany('App\Models\Attachment', 'attachable'); + return $this->morphMany(\App\Models\Attachment::class, 'attachable'); } } diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index 0728633..5a9eb1f 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -33,20 +33,16 @@ class Attachment extends Model /** * Get attachments attachable - * - * @return MorphTo */ - public function attachable() + public function attachable(): MorphTo { return $this->morphTo(); } /** * Get the media for this attachment. - * - * @return BelongsTo */ - public function media() + public function media(): BelongsTo { return $this->belongsTo(Media::class); } diff --git a/app/Models/Event.php b/app/Models/Event.php index ebd791c..9d6d5a5 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -38,20 +38,16 @@ class Event extends Model /** * Get all of the article's attachments. - * - * @return MorphMany */ - public function attachments() + public function attachments(): MorphMany { - return $this->morphMany('App\Models\Attachment', 'attachable'); + return $this->morphMany(\App\Models\Attachment::class, 'attachable'); } /** * Get all the associated users. - * - * @return BelongsToMany */ - public function users() + public function users(): BelongsToMany { return $this->belongsToMany(User::class, 'event_user', 'event_id', 'user_id'); } diff --git a/app/Models/EventUsers.php b/app/Models/EventUsers.php index f1ea84b..31a9d1f 100644 --- a/app/Models/EventUsers.php +++ b/app/Models/EventUsers.php @@ -24,20 +24,16 @@ class EventUser extends Model /** * Get the event for this attachment. - * - * @return BelongsTo */ - public function event() + public function event(): BelongsTo { return $this->belongsTo(Event::class); } /** * Get the user for this attachment. - * - * @return BelongsTo */ - public function user() + public function user(): BelongsTo { return $this->belongsTo(User::class); } diff --git a/app/Models/Media.php b/app/Models/Media.php index 46524a7..2ed7936 100644 --- a/app/Models/Media.php +++ b/app/Models/Media.php @@ -100,10 +100,8 @@ class Media extends Model /** * Model Boot - * - * @return void */ - protected static function boot() + protected static function boot(): void { parent::boot(); @@ -136,7 +134,7 @@ class Media extends Model * @param string $type The variant type to get. * @return array The variant data. */ - public static function getTypeVariants(string $type) + public static function getTypeVariants(string $type): array { if (isset(self::$variantTypes[$type]) === true) { return self::$variantTypes[$type]; @@ -151,7 +149,7 @@ class Media extends Model * @param mixed $value The value to mutate. * @return array The mutated value. */ - public function getVariantsAttribute(mixed $value) + public function getVariantsAttribute(mixed $value): array { if (is_string($value) === true) { return json_decode($value, true); @@ -164,9 +162,8 @@ class Media extends Model * Variants Set Mutator. * * @param mixed $value The value to mutate. - * @return void */ - public function setVariantsAttribute(mixed $value) + public function setVariantsAttribute(mixed $value): void { if (is_array($value) !== true) { $value = []; @@ -182,7 +179,7 @@ class Media extends Model * @param string $variant The initial variant. * @return string The previous variant name (or ''). */ - public function getPreviousVariant(string $type, string $variant) + public function getPreviousVariant(string $type, string $variant): string { if (isset(self::$variantTypes[$type]) === false) { return ''; @@ -206,7 +203,7 @@ class Media extends Model * @param string $variant The initial variant. * @return string The next variant name (or ''). */ - public function getNextVariant(string $type, string $variant) + public function getNextVariant(string $type, string $variant): string { if (isset(self::$variantTypes[$type]) === false) { return ''; @@ -230,7 +227,7 @@ class Media extends Model * @param boolean $returnNearest Return the nearest variant if request is not found. * @return string The URL. */ - public function getVariantURL(string $variant, bool $returnNearest = true) + public function getVariantURL(string $variant, bool $returnNearest = true): string { $variants = $this->variants; if (isset($variants[$variant]) === true) { @@ -256,10 +253,8 @@ class Media extends Model /** * Delete file and associated files with the modal. - * - * @return void */ - public function deleteFile() + public function deleteFile(): void { $fileName = $this->name; $baseName = pathinfo($fileName, PATHINFO_FILENAME); @@ -279,10 +274,9 @@ class Media extends Model /** * Invalidate Cloudflare Cache. * - * @return void * @throws InvalidArgumentException Exception. */ - private function invalidateCFCache() + private function invalidateCFCache(): void { $zone_id = env("CLOUDFLARE_ZONE_ID"); $api_key = env("CLOUDFLARE_API_KEY"); @@ -311,10 +305,8 @@ class Media extends Model /** * Get URL path - * - * @return string */ - public function getUrlPath() + public function getUrlPath(): string { $url = config("filesystems.disks.$this->storage.url"); return "$url/"; @@ -322,10 +314,8 @@ class Media extends Model /** * Return the file URL - * - * @return string */ - public function getUrlAttribute() + public function getUrlAttribute(): string { if (isset($this->attributes['name']) === true) { return self::getUrlPath() . $this->name; @@ -336,10 +326,8 @@ class Media extends Model /** * Return the file owner - * - * @return BelongsTo */ - public function user() + public function user(): BelongsTo { return $this->belongsTo(User::class); } @@ -348,9 +336,8 @@ class Media extends Model * Move files to new storage device. * * @param string $storage The storage ID to move to. - * @return void */ - public function moveToStorage(string $storage) + public function moveToStorage(string $storage): void { if ($storage !== $this->storage && Config::has("filesystems.disks.$storage") === true) { $this->status = "Processing media"; @@ -366,7 +353,7 @@ class Media extends Model * @param Illuminate\Http\UploadedFile $file The file. * @return null|Media The result or null if not successful. */ - public static function createFromUploadedFile(Request $request, UploadedFile $file) + public static function createFromUploadedFile(Request $request, UploadedFile $file): ?Media { $request->merge([ 'title' => $request->get('title', ''), @@ -401,7 +388,7 @@ class Media extends Model * @param Illuminate\Http\UploadedFile $file The file. * @return null|Media The media item. */ - public function updateWithUploadedFile(UploadedFile $file) + public function updateWithUploadedFile(UploadedFile $file): ?Media { if ($file === null || $file->isValid() !== true) { throw new \Exception('The file is invalid.', self::INVALID_FILE_ERROR); @@ -494,10 +481,8 @@ class Media extends Model /** * Get the server maximum upload size - * - * @return integer */ - public static function getMaxUploadSize() + public static function getMaxUploadSize(): int { $sizes = [ ini_get('upload_max_filesize'), @@ -561,7 +546,7 @@ class Media extends Model * @param boolean $ignoreCache Ignore the file list cache. * @return boolean If the file exists on any storage disks. */ - public static function fileExistsInStorage(string $fileName, bool $ignoreCache = false) + public static function fileExistsInStorage(string $fileName, bool $ignoreCache = false): bool { $disks = array_keys(Config::get('filesystems.disks')); @@ -608,7 +593,7 @@ class Media extends Model * @param string $fileName The file name to test. * @return boolean If the file name contains the special suffix. */ - public static function fileNameHasSuffix(string $fileName) + public static function fileNameHasSuffix(string $fileName): bool { $suffix = '/(-\d+x\d+|-scaled)$/i'; $fileNameWithoutExtension = pathinfo($fileName, PATHINFO_FILENAME); @@ -620,9 +605,8 @@ class Media extends Model * Sanitize fileName for upload * * @param string $fileName Filename to sanitize. - * @return string */ - private static function sanitizeFilename(string $fileName) + private static function sanitizeFilename(string $fileName): string { /* # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words diff --git a/app/Models/Permission.php b/app/Models/Permission.php index 5c35923..38f3f29 100644 --- a/app/Models/Permission.php +++ b/app/Models/Permission.php @@ -24,10 +24,8 @@ class Permission extends Model /** * Get the User associated with this model - * - * @return BelongsTo */ - public function user() + public function user(): BelongsTo { return $this->belongsTo(User::class); } diff --git a/app/Models/User.php b/app/Models/User.php index e915254..3e8fe41 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -79,20 +79,16 @@ class User extends Authenticatable implements Auditable /** * Get the list of files of the user - * - * @return HasMany */ - public function permissions() + public function permissions(): HasMany { return $this->hasMany(Permission::class); } /** * Get the permission attribute - * - * @return array */ - public function getPermissionsAttribute() + public function getPermissionsAttribute(): array { return $this->permissions()->pluck('permission')->toArray(); } @@ -101,9 +97,8 @@ class User extends Authenticatable implements Auditable * Test if user has permission * * @param string $permission Permission to test. - * @return boolean */ - public function hasPermission(string $permission) + public function hasPermission(string $permission): bool { return ($this->permissions()->where('permission', $permission)->first() !== null); } @@ -112,9 +107,8 @@ class User extends Authenticatable implements Auditable * Give permissions to the user * * @param string|array $permissions The permission(s) to give. - * @return Collection */ - public function givePermission($permissions) + public function givePermission($permissions): Collection { if (is_array($permissions) === false) { $permissions = [$permissions]; @@ -137,9 +131,8 @@ class User extends Authenticatable implements Auditable * Revoke permissions from the user * * @param string|array $permissions The permission(s) to revoke. - * @return integer */ - public function revokePermission($permissions) + public function revokePermission($permissions): int { if (is_array($permissions) === false) { $permissions = [$permissions]; @@ -152,50 +145,40 @@ class User extends Authenticatable implements Auditable /** * Get the list of files of the user - * - * @return HasMany */ - public function media() + public function media(): HasMany { return $this->hasMany(Media::class); } /** * Get the list of files of the user - * - * @return HasMany */ - public function articles() + public function articles(): HasMany { return $this->hasMany(Article::class); } /** * Get associated user codes - * - * @return HasMany */ - public function codes() + public function codes(): HasMany { return $this->hasMany(UserCode::class); } /** * Get the list of logins of the user - * - * @return HasMany */ - public function logins() + public function logins(): HasMany { return $this->hasMany(UserLogins::class); } /** * Get the events associated with the user. - * - * @return BelongsToMany */ - public function events() + public function events(): BelongsToMany { return $this->belongsToMany(Event::class, 'event_user', 'user_id', 'event_id'); } diff --git a/app/Models/UserCode.php b/app/Models/UserCode.php index dcc0f58..aba1b38 100644 --- a/app/Models/UserCode.php +++ b/app/Models/UserCode.php @@ -23,10 +23,8 @@ class UserCode extends Model /** * Boot function from Laravel. - * - * @return void */ - protected static function boot() + protected static function boot(): void { parent::boot(); static::creating(function ($model) { @@ -46,10 +44,8 @@ class UserCode extends Model /** * Generate new code - * - * @return void */ - public function regenerate() + public function regenerate(): void { while (true) { $code = random_int(100000, 999999); @@ -62,20 +58,16 @@ class UserCode extends Model /** * Clear expired user codes - * - * @return void */ - public static function clearExpired() + public static function clearExpired(): void { UserCode::where('updated_at', '<=', now()->subDays(5))->delete(); } /** * Get associated user - * - * @return BelongsTo */ - public function user() + public function user(): BelongsTo { return $this->belongsTo(User::class); } diff --git a/app/Models/UserLogins.php b/app/Models/UserLogins.php index 09c0f4b..8b9a479 100644 --- a/app/Models/UserLogins.php +++ b/app/Models/UserLogins.php @@ -28,10 +28,8 @@ class UserLogins extends Model /** * Get the file user - * - * @return BelongsTo */ - public function user() + public function user(): BelongsTo { return $this->belongsTo(User::class); } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 62c01a6..7c5628a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -16,20 +16,16 @@ class AppServiceProvider extends ServiceProvider { /** * Register any application services. - * - * @return void */ - public function register() + public function register(): void { // } /** * Bootstrap any application services. - * - * @return void */ - public function boot() + public function boot(): void { Storage::macro('public', function ($diskName) { $public = config("filesystems.disks.{$diskName}.public", false); diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 024a84c..8e67de0 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -19,13 +19,9 @@ class AuthServiceProvider extends ServiceProvider /** * Register any authentication / authorization services. - * - * @return void */ - public function boot() + public function boot(): void { - $this->registerPolicies(); - // } } diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 395c518..2be04f5 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -9,10 +9,8 @@ class BroadcastServiceProvider extends ServiceProvider { /** * Bootstrap any application services. - * - * @return void */ - public function boot() + public function boot(): void { Broadcast::routes(); diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 85a5b87..f77570e 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -26,20 +26,16 @@ class EventServiceProvider extends ServiceProvider /** * Register any events for your application. - * - * @return void */ - public function boot() + public function boot(): void { // } /** * Determine if events and listeners should be automatically discovered. - * - * @return boolean */ - public function shouldDiscoverEvents() + public function shouldDiscoverEvents(): bool { return false; } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index de4213d..c255a5e 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -23,12 +23,32 @@ class RouteServiceProvider extends ServiceProvider /** * Define your route model bindings, pattern filters, and other route configuration. - * - * @return void */ - public function boot() + public function boot(): void { - $this->configureRateLimiting(); + // RateLimiter::for('api', function (Request $request) { + // return Limit::perMinute(60)->by($request->user()?->id !== null ?: $request->ip()); + // }); + + $rateLimitEnabled = true; + $user = auth()->user(); + + if (app()->environment('testing')) { + $rateLimitEnabled = false; + } elseif ($user !== null && $user->hasPermission('admin/ratelimit') === true) { + // Admin users with the "admin/ratelimit" permission are not rate limited + $rateLimitEnabled = false; + } + + if ($rateLimitEnabled === true) { + RateLimiter::for('api', function (Request $request) { + return Limit::perMinute(180)->by($request->user()?->id ?: $request->ip()); + }); + } else { + RateLimiter::for('api', function () { + return Limit::none(); + }); + } $this->routes(function () { Route::middleware('api') @@ -55,36 +75,4 @@ class RouteServiceProvider extends ServiceProvider ->name("{{$singularUri}}.attachments.destroy"); }); } - - /** - * Configure the rate limiters for the application. - * - * @return void - */ - protected function configureRateLimiting() - { - // RateLimiter::for('api', function (Request $request) { - // return Limit::perMinute(60)->by($request->user()?->id !== null ?: $request->ip()); - // }); - - $rateLimitEnabled = true; - $user = auth()->user(); - - if (app()->environment('testing')) { - $rateLimitEnabled = false; - } elseif ($user !== null && $user->hasPermission('admin/ratelimit') === true) { - // Admin users with the "admin/ratelimit" permission are not rate limited - $rateLimitEnabled = false; - } - - if ($rateLimitEnabled === true) { - RateLimiter::for('api', function (Request $request) { - return Limit::perMinute(180)->by($request->user()?->id ?: $request->ip()); - }); - } else { - RateLimiter::for('api', function () { - return Limit::none(); - }); - } - } } diff --git a/app/Rules/Recaptcha.php b/app/Rules/Recaptcha.php index 5f9fe1b..29a8030 100644 --- a/app/Rules/Recaptcha.php +++ b/app/Rules/Recaptcha.php @@ -22,9 +22,8 @@ class Recaptcha implements Rule * * @param mixed $attribute Attribute name. * @param mixed $value Attribute value. - * @return boolean */ - public function passes(mixed $attribute, mixed $value) + public function passes(mixed $attribute, mixed $value): bool { $endpoint = config('services.google_recaptcha'); @@ -42,10 +41,8 @@ class Recaptcha implements Rule /** * Get the validation error message. - * - * @return string */ - public function message() + public function message(): string { return 'Captcha failed. Refresh the page and try again'; } diff --git a/app/Rules/UniqueFileName.php b/app/Rules/UniqueFileName.php index 70e06ff..c04c388 100644 --- a/app/Rules/UniqueFileName.php +++ b/app/Rules/UniqueFileName.php @@ -20,21 +20,17 @@ class UniqueFileName implements Rule /** * Determine if the validation rule passes. * - * @param string $attribute - * @param mixed $value - * @return boolean + * @param mixed $value */ - public function passes($attribute, $value) + public function passes(string $attribute, $value): bool { return (Media::fileExists($value) === false); } /** * Get the validation error message. - * - * @return string */ - public function message() + public function message(): string { return 'The file name already exists.'; } diff --git a/app/Rules/Uniqueish.php b/app/Rules/Uniqueish.php index f6fb8a3..5dd9470 100644 --- a/app/Rules/Uniqueish.php +++ b/app/Rules/Uniqueish.php @@ -47,9 +47,8 @@ class Uniqueish implements Rule * Set the ID of the record to be ignored. * * @param mixed $id The ID to ignore. - * @return $this */ - public function ignore(mixed $id) + public function ignore(mixed $id): static { $this->ignoreId = $id; return $this; @@ -60,9 +59,8 @@ class Uniqueish implements Rule * * @param mixed $attribute Not used. * @param mixed $value The value to compare. - * @return boolean */ - public function passes(mixed $attribute, mixed $value) + public function passes(mixed $attribute, mixed $value): bool { $columnName = ($this->column ?? $attribute); $similarValue = preg_replace('/[^A-Za-z]/', '', strtolower($value)); @@ -97,10 +95,8 @@ class Uniqueish implements Rule /** * Get the validation error message. - * - * @return string */ - public function message() + public function message(): string { return 'The :attribute is similar to one that already exists. Please choose another.'; } diff --git a/app/Services/AnimatedGifService.php b/app/Services/AnimatedGifService.php index e446e15..cab5501 100644 --- a/app/Services/AnimatedGifService.php +++ b/app/Services/AnimatedGifService.php @@ -11,7 +11,7 @@ class AnimatedGifService * @param integer $dataSize GIF blob size. * @return boolean GIF file/blob is animated. */ - public static function isAnimatedGif(string $filenameOrBlob, int $dataSize = 0) + public static function isAnimatedGif(string $filenameOrBlob, int $dataSize = 0): bool { $regex = '#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s'; $count = 0; @@ -41,10 +41,8 @@ class AnimatedGifService * @param string $filenameOrBlob GIF filename path * @param integer $dataSize GIF blob size. * @param boolean $originalFrames Get original frames (with transparent background) - * - * @return array */ - public function extract(string $filenameOrBlob, int $dataSize = 0, $originalFrames = false) + public function extract(string $filenameOrBlob, int $dataSize = 0, bool $originalFrames = false): array { if (self::isAnimatedGif($filenameOrBlob) === false) { return []; @@ -198,7 +196,7 @@ class GifFrameExtractor * * @param string $filename GIF filename path */ - private function parseFramesInfo($filename) + private function parseFramesInfo(string $filename) { $this->openFile($filename); $this->parseGifHeader(); @@ -275,10 +273,8 @@ class GifFrameExtractor /** * Parse the graphic extension of the frames (old: get_graphics_extension) - * - * @param integer $type */ - private function parseGraphicsExtension($type) + private function parseGraphicsExtension(int $type) { $startdata = $this->readByte(2); @@ -303,10 +299,8 @@ class GifFrameExtractor /** * Get the full frame string block (old: get_image_block) - * - * @param integer $type */ - private function getFrameString($type) + private function getFrameString(int $type) { if ($this->checkByte(0x2c)) { $start = $this->pointer; @@ -400,14 +394,8 @@ class GifFrameExtractor /** * Get the image data byte (old: get_imagedata_byte) - * - * @param string $type - * @param integer $start - * @param integer $length - * - * @return string */ - private function getImageDataByte($type, $start, $length) + private function getImageDataByte(string $type, int $start, int $length): string { if ($type == "ext") { return substr($this->frameSources[$this->frameNumber]["graphicsextension"], $start, $length); @@ -419,15 +407,8 @@ class GifFrameExtractor /** * Get the image data bit (old: get_imagedata_bit) - * - * @param string $type - * @param integer $byteIndex - * @param integer $bitStart - * @param integer $bitLength - * - * @return number */ - private function getImageDataBit($type, $byteIndex, $bitStart, $bitLength) + private function getImageDataBit(string $type, int $byteIndex, int $bitStart, int $bitLength): number { if ($type == "ext") { return $this->readBits(ord(substr($this->frameSources[$this->frameNumber]["graphicsextension"], $byteIndex, 1)), $bitStart, $bitLength); @@ -439,12 +420,8 @@ class GifFrameExtractor /** * Return the value of 2 ASCII chars (old: dualbyteval) - * - * @param string $s - * - * @return integer */ - private function dualByteVal($s) + private function dualByteVal(string $s): int { $i = (ord($s[1]) * 256 + ord($s[0])); @@ -453,10 +430,8 @@ class GifFrameExtractor /** * Read the data stream (old: read_data_stream) - * - * @param integer $firstLength */ - private function readDataStream($firstLength) + private function readDataStream(int $firstLength) { $this->pointerForward($firstLength); $length = $this->readByteInt(); @@ -471,10 +446,8 @@ class GifFrameExtractor /** * Open the gif file (old: loadfile) - * - * @param string $filename */ - private function openFile($filename) + private function openFile(string $filename) { $this->handle = fopen($filename, "rb"); $this->pointer = 0; @@ -495,12 +468,8 @@ class GifFrameExtractor /** * Read the file from the beginning to $byteCount in binary (old: readbyte) - * - * @param integer $byteCount - * - * @return string */ - private function readByte($byteCount) + private function readByte(int $byteCount): string { $data = fread($this->handle, $byteCount); $this->pointer += $byteCount; @@ -510,10 +479,8 @@ class GifFrameExtractor /** * Read a byte and return ASCII value (old: readbyte_int) - * - * @return integer */ - private function readByteInt() + private function readByteInt(): int { $data = fread($this->handle, 1); $this->pointer++; @@ -523,14 +490,8 @@ class GifFrameExtractor /** * Convert a $byte to decimal (old: readbits) - * - * @param string $byte - * @param integer $start - * @param integer $length - * - * @return number */ - private function readBits($byte, $start, $length) + private function readBits(string $byte, int $start, int $length): number { $bin = str_pad(decbin($byte), 8, "0", STR_PAD_LEFT); $data = substr($bin, $start, $length); @@ -540,10 +501,8 @@ class GifFrameExtractor /** * Rewind the file pointer reader (old: p_rewind) - * - * @param integer $length */ - private function pointerRewind($length) + private function pointerRewind(int $length) { $this->pointer -= $length; fseek($this->handle, $this->pointer); @@ -551,10 +510,8 @@ class GifFrameExtractor /** * Forward the file pointer reader (old: p_forward) - * - * @param integer $length */ - private function pointerForward($length) + private function pointerForward(int $length) { $this->pointer += $length; fseek($this->handle, $this->pointer); @@ -562,13 +519,8 @@ class GifFrameExtractor /** * Get a section of the data from $start to $start + $length (old: datapart) - * - * @param integer $start - * @param integer $length - * - * @return string */ - private function dataPart($start, $length) + private function dataPart(int $start, int $length): string { fseek($this->handle, $start); $data = fread($this->handle, $length); @@ -579,12 +531,8 @@ class GifFrameExtractor /** * Check if a character if a byte (old: checkbyte) - * - * @param integer $byte - * - * @return boolean */ - private function checkByte($byte) + private function checkByte(int $byte): bool { if (fgetc($this->handle) == chr($byte)) { fseek($this->handle, $this->pointer); @@ -598,10 +546,8 @@ class GifFrameExtractor /** * Check the end of the file (old: checkEOF) - * - * @return boolean */ - private function checkEOF() + private function checkEOF(): bool { if (fgetc($this->handle) === false) { return true; @@ -628,70 +574,56 @@ class GifFrameExtractor /** * Get the total of all added frame duration - * - * @return integer */ - public function getTotalDuration() + public function getTotalDuration(): int { return $this->totalDuration; } /** * Get the number of extracted frames - * - * @return integer */ - public function getFrameNumber() + public function getFrameNumber(): int { return $this->frameNumber; } /** * Get the extracted frames (images and durations) - * - * @return array */ - public function getFrames() + public function getFrames(): array { return $this->frames; } /** * Get the extracted frame positions - * - * @return array */ - public function getFramePositions() + public function getFramePositions(): array { return $this->framePositions; } /** * Get the extracted frame dimensions - * - * @return array */ - public function getFrameDimensions() + public function getFrameDimensions(): array { return $this->frameDimensions; } /** * Get the extracted frame images - * - * @return array */ - public function getFrameImages() + public function getFrameImages(): array { return $this->frameImages; } /** * Get the extracted frame durations - * - * @return array */ - public function getFrameDurations() + public function getFrameDurations(): array { return $this->frameDurations; } diff --git a/app/Traits/Uuids.php b/app/Traits/Uuids.php index 4e9cf81..64524f0 100644 --- a/app/Traits/Uuids.php +++ b/app/Traits/Uuids.php @@ -8,10 +8,8 @@ trait Uuids { /** * Boot function from Laravel. - * - * @return void */ - protected static function bootUuids() + protected static function bootUuids(): void { static::creating(function ($model) { if (empty($model->{$model->getKeyName()}) === true) { @@ -22,20 +20,16 @@ trait Uuids /** * Get the value indicating whether the IDs are incrementing. - * - * @return boolean */ - public function getIncrementing() + public function getIncrementing(): bool { return false; } /** * Get the auto-incrementing key type. - * - * @return string */ - public function getKeyType() + public function getKeyType(): string { return 'string'; } diff --git a/composer.json b/composer.json index fb07772..25f621e 100644 --- a/composer.json +++ b/composer.json @@ -8,15 +8,15 @@ ], "license": "MIT", "require": { - "php": "^8.0.2", + "php": "^8.1", "doctrine/dbal": "^3.5", "guzzlehttp/guzzle": "^7.2", "intervention/image": "^2.7", - "laravel/framework": "^9.19", - "laravel/sanctum": "^3.0", - "laravel/tinker": "^2.7", + "laravel/framework": "^10.12", + "laravel/sanctum": "^3.2", + "laravel/tinker": "^2.8", "league/flysystem-aws-s3-v3": "^3.12", - "owen-it/laravel-auditing": "^13.0", + "owen-it/laravel-auditing": "^13.1", "php-ffmpeg/php-ffmpeg": "^1.1", "sunspikes/clamav-validator": "*", "thiagoalessio/tesseract_ocr": "^2.12", @@ -25,11 +25,11 @@ "require-dev": { "fakerphp/faker": "^1.9.1", "laravel/pint": "^1.0", - "laravel/sail": "^1.0.1", + "laravel/sail": "^1.18", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.1", "phpunit/phpunit": "^10.1.3", - "spatie/laravel-ignition": "^1.0" + "spatie/laravel-ignition": "^2.0" }, "autoload": { "files": [ @@ -77,6 +77,6 @@ "pestphp/pest-plugin": true } }, - "minimum-stability": "dev", + "minimum-stability": "stable", "prefer-stable": true } diff --git a/config/app.php b/config/app.php index 030f356..ddfaa03 100644 --- a/config/app.php +++ b/config/app.php @@ -1,5 +1,6 @@ [ - - /* - * Laravel Framework Service Providers... - */ - Illuminate\Auth\AuthServiceProvider::class, - Illuminate\Broadcasting\BroadcastServiceProvider::class, - Illuminate\Bus\BusServiceProvider::class, - Illuminate\Cache\CacheServiceProvider::class, - Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, - Illuminate\Cookie\CookieServiceProvider::class, - Illuminate\Database\DatabaseServiceProvider::class, - Illuminate\Encryption\EncryptionServiceProvider::class, - Illuminate\Filesystem\FilesystemServiceProvider::class, - Illuminate\Foundation\Providers\FoundationServiceProvider::class, - Illuminate\Hashing\HashServiceProvider::class, - Illuminate\Mail\MailServiceProvider::class, - Illuminate\Notifications\NotificationServiceProvider::class, - Illuminate\Pagination\PaginationServiceProvider::class, - Illuminate\Pipeline\PipelineServiceProvider::class, - Illuminate\Queue\QueueServiceProvider::class, - Illuminate\Redis\RedisServiceProvider::class, - Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, - Illuminate\Session\SessionServiceProvider::class, - Illuminate\Translation\TranslationServiceProvider::class, - Illuminate\Validation\ValidationServiceProvider::class, - Illuminate\View\ViewServiceProvider::class, - + 'providers' => ServiceProvider::defaultProviders()->merge([ /* * Package Service Providers... */ @@ -196,8 +170,7 @@ return [ // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, - - ], + ])->toArray(), /* |-------------------------------------------------------------------------- diff --git a/config/auth.php b/config/auth.php index d8c6cee..9548c15 100644 --- a/config/auth.php +++ b/config/auth.php @@ -80,16 +80,20 @@ return [ | than one user table or model in the application and you want to have | separate password reset settings based on the specific user types. | - | The expire time is the number of minutes that each reset token will be + | The expiry time is the number of minutes that each reset token will be | considered valid. This security feature keeps tokens short-lived so | they have less time to be guessed. You may change this as needed. | + | The throttle setting is the number of seconds a user must wait before + | generating more password reset tokens. This prevents the user from + | quickly generating a very large amount of password reset tokens. + | */ 'passwords' => [ 'users' => [ 'provider' => 'users', - 'table' => 'password_resets', + 'table' => 'password_reset_tokens', 'expire' => 60, 'throttle' => 60, ], diff --git a/config/broadcasting.php b/config/broadcasting.php index ca1c67e..4dbd22c 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -36,7 +36,7 @@ return [ 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - 'host' => env('PUSHER_HOST') === true ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com', + 'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com', 'port' => env('PUSHER_PORT', 443), 'scheme' => env('PUSHER_SCHEME', 'https'), 'encrypted' => true, diff --git a/config/database.php b/config/database.php index 8400a85..535cd52 100644 --- a/config/database.php +++ b/config/database.php @@ -58,9 +58,8 @@ return [ 'prefix_indexes' => true, 'strict' => true, 'engine' => null, - 'options' => extension_loaded('pdo_mysql') === true ? array_filter([ + 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), - PDO::ATTR_TIMEOUT => env('DB_TIMEOUT', 30), ]) : [], ], diff --git a/config/filesystems.php b/config/filesystems.php index 80a6bff..5756647 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -29,11 +29,13 @@ return [ */ 'disks' => [ + 'local' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL') . "/storage", 'public' => true, + 'throw' => false, ], 'cdn' => [ @@ -68,6 +70,26 @@ return [ ] ], + 'public' => [ + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'url' => env('APP_URL') . '/storage', + 'visibility' => 'public', + 'throw' => false, + ], + + 's3' => [ + 'driver' => 's3', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), + 'bucket' => env('AWS_BUCKET'), + 'url' => env('AWS_URL'), + 'endpoint' => env('AWS_ENDPOINT'), + 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), + 'throw' => false, + ], + ], /* diff --git a/config/logging.php b/config/logging.php index 752af71..d000835 100644 --- a/config/logging.php +++ b/config/logging.php @@ -3,6 +3,7 @@ use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler; +use Monolog\Processor\PsrLogMessageProcessor; return [ @@ -61,6 +62,7 @@ return [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, ], 'daily' => [ @@ -68,6 +70,7 @@ return [ 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, + 'replace_placeholders' => true, ], 'slack' => [ @@ -76,6 +79,7 @@ return [ 'username' => 'Laravel Log', 'emoji' => ':boom:', 'level' => env('LOG_LEVEL', 'critical'), + 'replace_placeholders' => true, ], 'papertrail' => [ @@ -87,6 +91,7 @@ return [ 'port' => env('PAPERTRAIL_PORT'), 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), ], + 'processors' => [PsrLogMessageProcessor::class], ], 'stderr' => [ @@ -97,16 +102,20 @@ return [ 'with' => [ 'stream' => 'php://stderr', ], + 'processors' => [PsrLogMessageProcessor::class], ], 'syslog' => [ 'driver' => 'syslog', 'level' => env('LOG_LEVEL', 'debug'), + 'facility' => LOG_USER, + 'replace_placeholders' => true, ], 'errorlog' => [ 'driver' => 'errorlog', 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, ], 'null' => [ diff --git a/config/mail.php b/config/mail.php index 492c953..566f0c1 100644 --- a/config/mail.php +++ b/config/mail.php @@ -28,7 +28,7 @@ return [ | sending an e-mail. You will specify which one you are using for your | mailers below. You are free to add additional mailers as required. | - | Supported: "smtp", "sendmail", "mailgun", "ses", + | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", | "postmark", "log", "array", "failover" | */ @@ -51,10 +51,16 @@ return [ 'mailgun' => [ 'transport' => 'mailgun', + // 'client' => [ + // 'timeout' => 5, + // ], ], 'postmark' => [ 'transport' => 'postmark', + // 'client' => [ + // 'timeout' => 5, + // ], ], 'sendmail' => [ diff --git a/config/services.php b/config/services.php index dc231b9..126d810 100644 --- a/config/services.php +++ b/config/services.php @@ -36,4 +36,5 @@ return [ 'site_key' => env('GOOGLE_RECAPTCHA_SITE_KEY'), 'secret_key' => env('GOOGLE_RECAPTCHA_SECRET_SITE_KEY'), ], + ]; diff --git a/database/factories/ArticleFactory.php b/database/factories/ArticleFactory.php index 56ee276..3fc95a9 100644 --- a/database/factories/ArticleFactory.php +++ b/database/factories/ArticleFactory.php @@ -15,7 +15,7 @@ class ArticleFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $publishDate = Carbon::parse($this->faker->dateTimeBetween('-1 month', '+1 month')); @@ -24,8 +24,8 @@ class ArticleFactory extends Factory 'slug' => $this->faker->slug(), 'publish_at' => $publishDate, 'content' => $this->faker->paragraphs(3, true), - 'user_id' => $this->faker->uuid, - 'hero' => $this->faker->uuid, + 'user_id' => $this->faker->uuid(), + 'hero' => $this->faker->uuid(), ]; } } diff --git a/database/factories/EventFactory.php b/database/factories/EventFactory.php index d4b1976..285ca45 100644 --- a/database/factories/EventFactory.php +++ b/database/factories/EventFactory.php @@ -15,7 +15,7 @@ class EventFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $startDate = Carbon::parse($this->faker->dateTimeBetween('now', '+1 year')); $endDate = Carbon::parse($this->faker->dateTimeBetween($startDate, '+1 year')); @@ -24,14 +24,14 @@ class EventFactory extends Factory return [ 'title' => $this->faker->sentence(), 'location' => $this->faker->randomElement(['online', 'physical']), - 'address' => $this->faker->address, + 'address' => $this->faker->address(), 'start_at' => $startDate, 'end_at' => $endDate, 'publish_at' => $publishDate, 'status' => $this->faker->randomElement(['draft', 'soon', 'open', 'closed', 'cancelled']), 'registration_type' => $this->faker->randomElement(['none', 'email', 'link', 'message']), 'registration_data' => $this->faker->sentence(), - 'hero' => $this->faker->uuid, + 'hero' => $this->faker->uuid(), 'content' => $this->faker->paragraphs(3, true), 'price' => $this->faker->numberBetween(0, 150), 'ages' => $this->faker->regexify('\d+(\+|\-\d+)?'), diff --git a/database/factories/MediaFactory.php b/database/factories/MediaFactory.php index 05244ae..e896c4a 100644 --- a/database/factories/MediaFactory.php +++ b/database/factories/MediaFactory.php @@ -15,13 +15,13 @@ class MediaFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'title' => $this->faker->sentence(), - 'name' => storage_path('app/public/') . $this->faker->slug() . '.' . $this->faker->fileExtension, - 'mime_type' => $this->faker->mimeType, - 'user_id' => $this->faker->uuid, + 'name' => storage_path('app/public/') . $this->faker->slug() . '.' . $this->faker->fileExtension(), + 'mime_type' => $this->faker->mimeType(), + 'user_id' => $this->faker->uuid(), 'size' => $this->faker->numberBetween(1000, 1000000), ]; } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index c4e7f11..c874bda 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -15,7 +15,7 @@ class UserFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $faker = \Faker\Factory::create(); $faker->addProvider(new \Faker\Provider\CustomInternetProvider($faker)); @@ -39,10 +39,8 @@ class UserFactory extends Factory /** * Indicate that the model's email address should be unverified. - * - * @return static */ - public function unverified() + public function unverified(): static { return $this->state(fn (array $attributes) => [ 'email_verified_at' => null, diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 03d1d84..53656a4 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('users', function (Blueprint $table) { $table->uuid('id')->primary(); @@ -30,10 +28,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('users'); } diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index fcacb80..4f42fe6 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('password_resets', function (Blueprint $table) { $table->string('email')->index(); @@ -22,10 +20,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('password_resets'); } diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index 1719198..249da81 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('failed_jobs', function (Blueprint $table) { $table->id(); @@ -26,10 +24,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('failed_jobs'); } diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php index 9207c18..29db28a 100644 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('personal_access_tokens', function (Blueprint $table) { $table->id(); @@ -27,10 +25,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('personal_access_tokens'); } diff --git a/database/migrations/2022_12_28_113117_create_posts_table.php b/database/migrations/2022_12_28_113117_create_posts_table.php index 1890220..8c3a230 100644 --- a/database/migrations/2022_12_28_113117_create_posts_table.php +++ b/database/migrations/2022_12_28_113117_create_posts_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('posts', function (Blueprint $table) { $table->uuid('id')->primary(); @@ -27,10 +25,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('posts'); } diff --git a/database/migrations/2022_12_30_105153_create_media_table.php b/database/migrations/2022_12_30_105153_create_media_table.php index 3873828..7f9209c 100644 --- a/database/migrations/2022_12_30_105153_create_media_table.php +++ b/database/migrations/2022_12_30_105153_create_media_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('media', function (Blueprint $table) { $table->uuid('id')->primary(); @@ -27,10 +25,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('media'); } diff --git a/database/migrations/2022_12_30_110049_create_permissions_table.php b/database/migrations/2022_12_30_110049_create_permissions_table.php index 2142080..5977404 100644 --- a/database/migrations/2022_12_30_110049_create_permissions_table.php +++ b/database/migrations/2022_12_30_110049_create_permissions_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('permissions', function (Blueprint $table) { $table->uuid('id')->primary(); @@ -25,10 +23,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('permissions'); } diff --git a/database/migrations/2023_01_01_103251_create_events_table.php b/database/migrations/2023_01_01_103251_create_events_table.php index 7e9cde3..211be9c 100644 --- a/database/migrations/2023_01_01_103251_create_events_table.php +++ b/database/migrations/2023_01_01_103251_create_events_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('events', function (Blueprint $table) { $table->uuid('id')->primary(); @@ -32,10 +30,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('events'); } diff --git a/database/migrations/2023_01_021_050482_create_subscriptions_table.php b/database/migrations/2023_01_021_050482_create_subscriptions_table.php index b47f416..635ff85 100644 --- a/database/migrations/2023_01_021_050482_create_subscriptions_table.php +++ b/database/migrations/2023_01_021_050482_create_subscriptions_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('subscriptions', function (Blueprint $table) { $table->uuid('id')->primary(); @@ -23,10 +21,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('subscriptions'); } diff --git a/database/migrations/2023_01_05_043106_create_jobs_table.php b/database/migrations/2023_01_05_043106_create_jobs_table.php index a786a89..6098d9b 100644 --- a/database/migrations/2023_01_05_043106_create_jobs_table.php +++ b/database/migrations/2023_01_05_043106_create_jobs_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('jobs', function (Blueprint $table) { $table->bigIncrements('id'); @@ -26,10 +24,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('jobs'); } diff --git a/database/migrations/2023_01_05_112154_create_user_codes_table.php b/database/migrations/2023_01_05_112154_create_user_codes_table.php index 1d98f9c..dfae89e 100644 --- a/database/migrations/2023_01_05_112154_create_user_codes_table.php +++ b/database/migrations/2023_01_05_112154_create_user_codes_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('user_codes', function (Blueprint $table) { $table->id(); @@ -27,10 +25,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('user_codes'); } diff --git a/database/migrations/2023_01_08_045958_create_audits_table.php b/database/migrations/2023_01_08_045958_create_audits_table.php index 7016272..42669aa 100644 --- a/database/migrations/2023_01_08_045958_create_audits_table.php +++ b/database/migrations/2023_01_08_045958_create_audits_table.php @@ -5,14 +5,12 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Schema; -class CreateAuditsTable extends Migration +return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::connection(config('audit.drivers.database.connection', config('database.default')))->create('audits', function (Blueprint $table) { @@ -37,11 +35,9 @@ class CreateAuditsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::connection(config('audit.drivers.database.connection', config('database.default')))->drop('audits'); } -} +}; diff --git a/database/migrations/2023_01_08_050847_create_user_logins_table.php b/database/migrations/2023_01_08_050847_create_user_logins_table.php index b2200df..3752181 100644 --- a/database/migrations/2023_01_08_050847_create_user_logins_table.php +++ b/database/migrations/2023_01_08_050847_create_user_logins_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('user_logins', function (Blueprint $table) { $table->uuid('id')->primary(); @@ -29,10 +27,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('user_logins'); } diff --git a/database/migrations/2023_01_24_080416_create_analytics_table.php b/database/migrations/2023_01_24_080416_create_analytics_table.php index 18db1cd..3c5bb9a 100644 --- a/database/migrations/2023_01_24_080416_create_analytics_table.php +++ b/database/migrations/2023_01_24_080416_create_analytics_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('analytics', function (Blueprint $table) { $table->id(); @@ -25,10 +23,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('analytics'); } diff --git a/database/migrations/2023_02_24_023054_create_attachments_table.php b/database/migrations/2023_02_24_023054_create_attachments_table.php index dbf3f88..54b8441 100644 --- a/database/migrations/2023_02_24_023054_create_attachments_table.php +++ b/database/migrations/2023_02_24_023054_create_attachments_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('attachments', function (Blueprint $table) { $table->id(); @@ -25,10 +23,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('attachments'); } diff --git a/database/migrations/2023_02_28_090609_add_price_to_events_table.php b/database/migrations/2023_02_28_090609_add_price_to_events_table.php index bee4565..5fdc902 100644 --- a/database/migrations/2023_02_28_090609_add_price_to_events_table.php +++ b/database/migrations/2023_02_28_090609_add_price_to_events_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('events', function (Blueprint $table) { $table->string('price')->default(""); @@ -20,10 +18,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('events', function (Blueprint $table) { $table->dropColumn('price'); diff --git a/database/migrations/2023_03_01_075334_add_ages_to_events_table.php b/database/migrations/2023_03_01_075334_add_ages_to_events_table.php index b3543fb..22f0ceb 100644 --- a/database/migrations/2023_03_01_075334_add_ages_to_events_table.php +++ b/database/migrations/2023_03_01_075334_add_ages_to_events_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('events', function (Blueprint $table) { $table->string('ages')->default(""); @@ -20,10 +18,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('events', function (Blueprint $table) { $table->dropColumn('ages'); diff --git a/database/migrations/2023_04_05_222458_update_media_table.php b/database/migrations/2023_04_05_222458_update_media_table.php index 6df5d64..9a7ee94 100644 --- a/database/migrations/2023_04_05_222458_update_media_table.php +++ b/database/migrations/2023_04_05_222458_update_media_table.php @@ -9,10 +9,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { DB::table('media')->whereNull('mime')->update(['mime' => '']); DB::table('media')->whereNull('permission')->update(['permission' => '']); @@ -37,10 +35,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('media', function (Blueprint $table) { $table->bigInteger('size')->change(); diff --git a/database/migrations/2023_04_18_111723_update_no_nullable_phone_on_users_table.php b/database/migrations/2023_04_18_111723_update_no_nullable_phone_on_users_table.php index 558c4f2..67d11ce 100644 --- a/database/migrations/2023_04_18_111723_update_no_nullable_phone_on_users_table.php +++ b/database/migrations/2023_04_18_111723_update_no_nullable_phone_on_users_table.php @@ -9,10 +9,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { DB::table('users')->whereNull('phone')->update(['phone' => '']); @@ -23,10 +21,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->string('phone')->nullable(true)->change(); diff --git a/database/migrations/2023_04_18_113354_add_display_name_to_users_table.php b/database/migrations/2023_04_18_113354_add_display_name_to_users_table.php index 023c9b4..da2d613 100644 --- a/database/migrations/2023_04_18_113354_add_display_name_to_users_table.php +++ b/database/migrations/2023_04_18_113354_add_display_name_to_users_table.php @@ -9,10 +9,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->string('display_name')->default(""); @@ -28,10 +26,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->dropColumn('display_name'); diff --git a/database/migrations/2023_04_19_122711_drop_subscriptions_table.php b/database/migrations/2023_04_19_122711_drop_subscriptions_table.php index 61b90a2..0ca3633 100644 --- a/database/migrations/2023_04_19_122711_drop_subscriptions_table.php +++ b/database/migrations/2023_04_19_122711_drop_subscriptions_table.php @@ -8,20 +8,16 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::dropIfExists('subscriptions'); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::create('subscriptions', function (Blueprint $table) { $table->uuid('id')->primary(); diff --git a/database/migrations/2023_04_25_235615_update_posts_table.php b/database/migrations/2023_04_25_235615_update_posts_table.php index 228561d..aac9dd7 100644 --- a/database/migrations/2023_04_25_235615_update_posts_table.php +++ b/database/migrations/2023_04_25_235615_update_posts_table.php @@ -9,10 +9,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::rename('posts', 'articles'); @@ -22,10 +20,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::rename('articles', 'posts'); diff --git a/database/migrations/2023_05_01_045630_update_analytics_table.php b/database/migrations/2023_05_01_045630_update_analytics_table.php index 5ad2eee..cfcd5d7 100644 --- a/database/migrations/2023_05_01_045630_update_analytics_table.php +++ b/database/migrations/2023_05_01_045630_update_analytics_table.php @@ -9,10 +9,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('analytics', function (Blueprint $table) { $table->bigInteger('session')->nullable(false); @@ -97,10 +95,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('analytics', function (Blueprint $table) { $table->dropColumn('session'); diff --git a/database/migrations/2023_05_04_071954_remove_username_from_users_table.php b/database/migrations/2023_05_04_071954_remove_username_from_users_table.php index 05bde34..aa0df58 100644 --- a/database/migrations/2023_05_04_071954_remove_username_from_users_table.php +++ b/database/migrations/2023_05_04_071954_remove_username_from_users_table.php @@ -9,10 +9,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->dropColumn('username'); @@ -21,10 +19,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->string('username')->unique(); diff --git a/database/migrations/2023_05_06_080418_create_shortlinks_table.php b/database/migrations/2023_05_06_080418_create_shortlinks_table.php index 3220cb9..7c6f3fd 100644 --- a/database/migrations/2023_05_06_080418_create_shortlinks_table.php +++ b/database/migrations/2023_05_06_080418_create_shortlinks_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('shortlinks', function (Blueprint $table) { $table->id(); @@ -23,10 +21,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('shortlinks'); } diff --git a/database/migrations/2023_05_06_082705_add_counter_to_shortlinks_table.php b/database/migrations/2023_05_06_082705_add_counter_to_shortlinks_table.php index d0a2cd1..25cdb7a 100644 --- a/database/migrations/2023_05_06_082705_add_counter_to_shortlinks_table.php +++ b/database/migrations/2023_05_06_082705_add_counter_to_shortlinks_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('shortlinks', function (Blueprint $table) { $table->bigInteger('used')->default(0); @@ -20,10 +18,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('shortlinks', function (Blueprint $table) { // diff --git a/database/migrations/2023_05_08_021929_update_users_table.php b/database/migrations/2023_05_08_021929_update_users_table.php index 744ca60..497de63 100644 --- a/database/migrations/2023_05_08_021929_update_users_table.php +++ b/database/migrations/2023_05_08_021929_update_users_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->string('first_name')->default('')->change(); @@ -21,10 +19,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->string('first_name')->nullable(false)->change(); diff --git a/database/migrations/2023_05_09_003156_add_location_url_to_events.php b/database/migrations/2023_05_09_003156_add_location_url_to_events.php index b8c5289..e33f9e8 100644 --- a/database/migrations/2023_05_09_003156_add_location_url_to_events.php +++ b/database/migrations/2023_05_09_003156_add_location_url_to_events.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('events', function (Blueprint $table) { $table->string('location_url')->default(''); @@ -20,10 +18,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('events', function (Blueprint $table) { $table->dropColumn('location_url'); diff --git a/database/migrations/2023_05_11_032859_add_private_to_attachments_table.php b/database/migrations/2023_05_11_032859_add_private_to_attachments_table.php index f150b3e..2efac94 100644 --- a/database/migrations/2023_05_11_032859_add_private_to_attachments_table.php +++ b/database/migrations/2023_05_11_032859_add_private_to_attachments_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('attachments', function (Blueprint $table) { $table->boolean('private')->default(false); @@ -20,10 +18,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('attachments', function (Blueprint $table) { $table->dropColumn('private'); diff --git a/database/migrations/2023_05_11_033621_create_event_users_table.php b/database/migrations/2023_05_11_033621_create_event_users_table.php index d1895ec..ab3cdbd 100644 --- a/database/migrations/2023_05_11_033621_create_event_users_table.php +++ b/database/migrations/2023_05_11_033621_create_event_users_table.php @@ -8,10 +8,8 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('event_users', function (Blueprint $table) { $table->id(); @@ -26,10 +24,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('event_users'); } diff --git a/database/migrations/2023_05_24_000000_rename_password_resets_table.php b/database/migrations/2023_05_24_000000_rename_password_resets_table.php new file mode 100644 index 0000000..f0ad375 --- /dev/null +++ b/database/migrations/2023_05_24_000000_rename_password_resets_table.php @@ -0,0 +1,24 @@ +create(); diff --git a/lang/en/auth.php b/lang/en/auth.php deleted file mode 100644 index 6598e2c..0000000 --- a/lang/en/auth.php +++ /dev/null @@ -1,20 +0,0 @@ - 'These credentials do not match our records.', - 'password' => 'The provided password is incorrect.', - 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', - -]; diff --git a/lang/en/pagination.php b/lang/en/pagination.php deleted file mode 100644 index d481411..0000000 --- a/lang/en/pagination.php +++ /dev/null @@ -1,19 +0,0 @@ - '« Previous', - 'next' => 'Next »', - -]; diff --git a/lang/en/passwords.php b/lang/en/passwords.php deleted file mode 100644 index 2345a56..0000000 --- a/lang/en/passwords.php +++ /dev/null @@ -1,22 +0,0 @@ - 'Your password has been reset!', - 'sent' => 'We have emailed your password reset link!', - 'throttled' => 'Please wait before retrying.', - 'token' => 'This password reset token is invalid.', - 'user' => "We can't find a user with that email address.", - -]; diff --git a/lang/en/validation.php b/lang/en/validation.php deleted file mode 100644 index af94bd4..0000000 --- a/lang/en/validation.php +++ /dev/null @@ -1,179 +0,0 @@ - 'The :attribute must be accepted.', - 'accepted_if' => 'The :attribute must be accepted when :other is :value.', - 'active_url' => 'The :attribute is not a valid URL.', - 'after' => 'The :attribute must be a date after :date.', - 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', - 'alpha' => 'The :attribute must only contain letters.', - 'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.', - 'alpha_num' => 'The :attribute must only contain letters and numbers.', - 'array' => 'The :attribute must be an array.', - 'ascii' => 'The :attribute must only contain single-byte alphanumeric characters and symbols.', - 'before' => 'The :attribute must be a date before :date.', - 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', - 'between' => [ - 'array' => 'The :attribute must have between :min and :max items.', - 'file' => 'The :attribute must be between :min and :max kilobytes.', - 'numeric' => 'The :attribute must be between :min and :max.', - 'string' => 'The :attribute must be between :min and :max characters.', - ], - 'boolean' => 'The :attribute field must be true or false.', - 'confirmed' => 'The :attribute confirmation does not match.', - 'current_password' => 'The password is incorrect.', - 'date' => 'The :attribute is not a valid date.', - 'date_equals' => 'The :attribute must be a date equal to :date.', - 'date_format' => 'The :attribute does not match the format :format.', - 'decimal' => 'The :attribute must have :decimal decimal places.', - 'declined' => 'The :attribute must be declined.', - 'declined_if' => 'The :attribute must be declined when :other is :value.', - 'different' => 'The :attribute and :other must be different.', - 'digits' => 'The :attribute must be :digits digits.', - 'digits_between' => 'The :attribute must be between :min and :max digits.', - 'dimensions' => 'The :attribute has invalid image dimensions.', - 'distinct' => 'The :attribute field has a duplicate value.', - 'doesnt_end_with' => 'The :attribute may not end with one of the following: :values.', - 'doesnt_start_with' => 'The :attribute may not start with one of the following: :values.', - 'email' => 'The :attribute must be a valid email address.', - 'ends_with' => 'The :attribute must end with one of the following: :values.', - 'enum' => 'The selected :attribute is invalid.', - 'exists' => 'The selected :attribute is invalid.', - 'file' => 'The :attribute must be a file.', - 'filled' => 'The :attribute field must have a value.', - 'gt' => [ - 'array' => 'The :attribute must have more than :value items.', - 'file' => 'The :attribute must be greater than :value kilobytes.', - 'numeric' => 'The :attribute must be greater than :value.', - 'string' => 'The :attribute must be greater than :value characters.', - ], - 'gte' => [ - 'array' => 'The :attribute must have :value items or more.', - 'file' => 'The :attribute must be greater than or equal to :value kilobytes.', - 'numeric' => 'The :attribute must be greater than or equal to :value.', - 'string' => 'The :attribute must be greater than or equal to :value characters.', - ], - 'image' => 'The :attribute must be an image.', - 'in' => 'The selected :attribute is invalid.', - 'in_array' => 'The :attribute field does not exist in :other.', - 'integer' => 'The :attribute must be an integer.', - 'ip' => 'The :attribute must be a valid IP address.', - 'ipv4' => 'The :attribute must be a valid IPv4 address.', - 'ipv6' => 'The :attribute must be a valid IPv6 address.', - 'json' => 'The :attribute must be a valid JSON string.', - 'lowercase' => 'The :attribute must be lowercase.', - 'lt' => [ - 'array' => 'The :attribute must have less than :value items.', - 'file' => 'The :attribute must be less than :value kilobytes.', - 'numeric' => 'The :attribute must be less than :value.', - 'string' => 'The :attribute must be less than :value characters.', - ], - 'lte' => [ - 'array' => 'The :attribute must not have more than :value items.', - 'file' => 'The :attribute must be less than or equal to :value kilobytes.', - 'numeric' => 'The :attribute must be less than or equal to :value.', - 'string' => 'The :attribute must be less than or equal to :value characters.', - ], - 'mac_address' => 'The :attribute must be a valid MAC address.', - 'max' => [ - 'array' => 'The :attribute must not have more than :max items.', - 'file' => 'The :attribute must not be greater than :max kilobytes.', - 'numeric' => 'The :attribute must not be greater than :max.', - 'string' => 'The :attribute must not be greater than :max characters.', - ], - 'max_digits' => 'The :attribute must not have more than :max digits.', - 'mimes' => 'The :attribute must be a file of type: :values.', - 'mimetypes' => 'The :attribute must be a file of type: :values.', - 'min' => [ - 'array' => 'The :attribute must have at least :min items.', - 'file' => 'The :attribute must be at least :min kilobytes.', - 'numeric' => 'The :attribute must be at least :min.', - 'string' => 'The :attribute must be at least :min characters.', - ], - 'min_digits' => 'The :attribute must have at least :min digits.', - 'multiple_of' => 'The :attribute must be a multiple of :value.', - 'not_in' => 'The selected :attribute is invalid.', - 'not_regex' => 'The :attribute format is invalid.', - 'numeric' => 'The :attribute must be a number.', - 'password' => [ - 'letters' => 'The :attribute must contain at least one letter.', - 'mixed' => 'The :attribute must contain at least one uppercase and one lowercase letter.', - 'numbers' => 'The :attribute must contain at least one number.', - 'symbols' => 'The :attribute must contain at least one symbol.', - 'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.', - ], - 'present' => 'The :attribute field must be present.', - 'prohibited' => 'The :attribute field is prohibited.', - 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', - 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', - 'prohibits' => 'The :attribute field prohibits :other from being present.', - 'regex' => 'The :attribute format is invalid.', - 'required' => 'The :attribute field is required.', - 'required_array_keys' => 'The :attribute field must contain entries for: :values.', - 'required_if' => 'The :attribute field is required when :other is :value.', - 'required_if_accepted' => 'The :attribute field is required when :other is accepted.', - 'required_unless' => 'The :attribute field is required unless :other is in :values.', - 'required_with' => 'The :attribute field is required when :values is present.', - 'required_with_all' => 'The :attribute field is required when :values are present.', - 'required_without' => 'The :attribute field is required when :values is not present.', - 'required_without_all' => 'The :attribute field is required when none of :values are present.', - 'same' => 'The :attribute and :other must match.', - 'size' => [ - 'array' => 'The :attribute must contain :size items.', - 'file' => 'The :attribute must be :size kilobytes.', - 'numeric' => 'The :attribute must be :size.', - 'string' => 'The :attribute must be :size characters.', - ], - 'starts_with' => 'The :attribute must start with one of the following: :values.', - 'string' => 'The :attribute must be a string.', - 'timezone' => 'The :attribute must be a valid timezone.', - 'unique' => 'The :attribute has already been taken.', - 'uploaded' => 'The :attribute failed to upload.', - 'uppercase' => 'The :attribute must be uppercase.', - 'url' => 'The :attribute must be a valid URL.', - 'ulid' => 'The :attribute must be a valid ULID.', - 'uuid' => 'The :attribute must be a valid UUID.', - - /* - |-------------------------------------------------------------------------- - | Custom Validation Language Lines - |-------------------------------------------------------------------------- - | - | Here you may specify custom validation messages for attributes using the - | convention "attribute.rule" to name the lines. This makes it quick to - | specify a specific custom language line for a given attribute rule. - | - */ - - 'custom' => [ - 'attribute-name' => [ - 'rule-name' => 'custom-message', - ], - ], - - /* - |-------------------------------------------------------------------------- - | Custom Validation Attributes - |-------------------------------------------------------------------------- - | - | The following language lines are used to swap our attribute placeholder - | with something more reader friendly such as "E-Mail Address" instead - | of "email". This simply helps us make our message more expressive. - | - */ - - 'attributes' => [], - -]; diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index ab92402..e3ad27e 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -3,15 +3,14 @@ namespace Tests; use Illuminate\Contracts\Console\Kernel; +use Illuminate\Foundation\Application; trait CreatesApplication { /** * Creates the application. - * - * @return \Illuminate\Foundation\Application */ - public function createApplication() + public function createApplication(): Application { $app = require __DIR__ . '/../bootstrap/app.php'; diff --git a/tests/Feature/ArticlesApiTest.php b/tests/Feature/ArticlesApiTest.php index 4ee0b7f..b0925d2 100644 --- a/tests/Feature/ArticlesApiTest.php +++ b/tests/Feature/ArticlesApiTest.php @@ -14,13 +14,13 @@ class ArticlesApiTest extends TestCase protected $faker; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->faker = FakerFactory::create(); } - public function testAnyUserCanViewArticle() + public function testAnyUserCanViewArticle(): void { // Create an event $article = Article::factory()->create([ @@ -51,7 +51,7 @@ class ArticlesApiTest extends TestCase ]); } - public function testAdminCanCreateUpdateDeleteArticle() + public function testAdminCanCreateUpdateDeleteArticle(): void { // Create a user with the admin/events permission $adminUser = User::factory()->create(); @@ -102,7 +102,7 @@ class ArticlesApiTest extends TestCase ]); } - public function testNonAdminCannotCreateUpdateDeleteArticle() + public function testNonAdminCannotCreateUpdateDeleteArticle(): void { // Create a user without admin/events permission $user = User::factory()->create(); diff --git a/tests/Feature/AuthApiTest.php b/tests/Feature/AuthApiTest.php index c35a1a4..4df3c7f 100644 --- a/tests/Feature/AuthApiTest.php +++ b/tests/Feature/AuthApiTest.php @@ -9,7 +9,7 @@ class AuthApiTest extends TestCase use RefreshDatabase; - public function testLogin() + public function testLogin(): void { $user = User::factory()->create([ 'password' => bcrypt('password'), diff --git a/tests/Feature/ContactFormTest.php b/tests/Feature/ContactFormTest.php index 3bb7f94..72e8464 100644 --- a/tests/Feature/ContactFormTest.php +++ b/tests/Feature/ContactFormTest.php @@ -8,7 +8,7 @@ class ContactFormTest extends TestCase use RefreshDatabase; - public function testContactForm() + public function testContactForm(): void { $formData = [ 'name' => 'John Doe', diff --git a/tests/Feature/EventsApiTest.php b/tests/Feature/EventsApiTest.php index 066c283..6c80c54 100644 --- a/tests/Feature/EventsApiTest.php +++ b/tests/Feature/EventsApiTest.php @@ -15,13 +15,13 @@ class EventsApiTest extends TestCase protected $faker; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->faker = FakerFactory::create(); } - public function testAnyUserCanViewEvent() + public function testAnyUserCanViewEvent(): void { // Create an event $event = Event::factory()->create([ @@ -52,7 +52,7 @@ class EventsApiTest extends TestCase ]); } - public function testAnyUserCannotSeeDraftEvent() + public function testAnyUserCannotSeeDraftEvent(): void { // Create a draft event $draftEvent = Event::factory()->create([ @@ -85,7 +85,7 @@ class EventsApiTest extends TestCase ]); } - public function testAdminCanCreateUpdateDeleteEvent() + public function testAdminCanCreateUpdateDeleteEvent(): void { // Create a user with the admin/events permission $adminUser = User::factory()->create(); @@ -139,7 +139,7 @@ class EventsApiTest extends TestCase ]); } - public function testNonAdminCannotCreateUpdateDeleteEvent() + public function testNonAdminCannotCreateUpdateDeleteEvent(): void { // Create a user without admin/events permission $user = User::factory()->create(); diff --git a/tests/Feature/UsersApiTest.php b/tests/Feature/UsersApiTest.php index 5633e90..0d7b2c1 100644 --- a/tests/Feature/UsersApiTest.php +++ b/tests/Feature/UsersApiTest.php @@ -10,7 +10,7 @@ class UsersApiTest extends TestCase use RefreshDatabase; - public function testNonAdminUsersCanOnlyViewBasicUserInfo() + public function testNonAdminUsersCanOnlyViewBasicUserInfo(): void { // create a non-admin user $nonAdminUser = User::factory()->create(); @@ -71,7 +71,7 @@ class UsersApiTest extends TestCase ]); } - public function testGuestCannotCreateUser() + public function testGuestCannotCreateUser(): void { $userData = [ 'email' => 'johndoe@example.com', @@ -85,7 +85,7 @@ class UsersApiTest extends TestCase ]); } - public function testGuestCanRegisterUser() + public function testGuestCanRegisterUser(): void { $userData = [ 'first_name' => 'John', @@ -102,7 +102,7 @@ class UsersApiTest extends TestCase ]); } - public function testCannotCreateDuplicateEmailOrDisplayName() + public function testCannotCreateDuplicateEmailOrDisplayName(): void { $userData = [ 'display_name' => 'JackDoe', @@ -125,7 +125,7 @@ class UsersApiTest extends TestCase $response->assertJsonValidationErrors(['display_name', 'email']); } - public function testUserCanOnlyUpdateOwnUser() + public function testUserCanOnlyUpdateOwnUser(): void { $user = User::factory()->create(); @@ -153,7 +153,7 @@ class UsersApiTest extends TestCase $response->assertStatus(403); } - public function testUserCannotDeleteUsers() + public function testUserCannotDeleteUsers(): void { $user = User::factory()->create(); @@ -169,7 +169,7 @@ class UsersApiTest extends TestCase $this->assertDatabaseHas('users', ['id' => $otherUser->id]); } - public function testAdminCanUpdateAnyUser() + public function testAdminCanUpdateAnyUser(): void { $admin = User::factory()->create(); $admin->givePermission('admin/users'); @@ -204,7 +204,7 @@ class UsersApiTest extends TestCase ]); } - public function testAdminCanDeleteAnyUser() + public function testAdminCanDeleteAnyUser(): void { $admin = User::factory()->create(); $admin->givePermission('admin/users'); diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index e5c5fef..5773b0c 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -8,10 +8,8 @@ class ExampleTest extends TestCase { /** * A basic test example. - * - * @return void */ - public function test_that_true_is_true() + public function test_that_true_is_true(): void { $this->assertTrue(true); }