Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 10.x Shift #941

Merged
merged 22 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* text=auto
* text=auto eol=lf
*.css linguist-vendored
*.scss linguist-vendored
6 changes: 2 additions & 4 deletions app/Concerns/HasLikes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

use App\Models\Like;
use App\Models\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\MorphMany;

trait HasLikes
{
/**
* @return \Illuminate\Database\Eloquent\Collection
*/
public function likes()
public function likes(): Collection
{
return $this->likesRelation;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Concerns/HasTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
namespace App\Concerns;

use App\Models\Tag;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\MorphToMany;

trait HasTags
{
/**
* @return \Illuminate\Database\Eloquent\Collection
*/
public function tags()
public function tags(): Collection
{
return $this->tagsRelation;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Concerns/PreparesSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private function batch(Collection $chunks, int $limit): array
}

// Append current item to last element of carry if the combination is < 5000 characters.
if (strlen(Arr::last($carry).$item) < $limit) {
if ($limit > strlen(Arr::last($carry).$item)) {
$carry[count($carry) - 1] .= "\r\n{$item}";

return $carry;
Expand Down
6 changes: 2 additions & 4 deletions app/Concerns/ProvidesSubscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

use App\Models\Subscription;
use App\Models\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Ramsey\Uuid\Uuid;

trait ProvidesSubscriptions
{
/**
* @return \Illuminate\Database\Eloquent\Collection
*/
public function subscriptions()
public function subscriptions(): Collection
{
return $this->subscriptionsRelation;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateArticleViewCounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct()
$this->token = config('services.fathom.token');
}

public function handle()
public function handle(): void
{
if (! $this->siteId || ! $this->token) {
$this->error('Fathom site ID and token must be configured');
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->command('schedule-monitor:sync')->dailyAt('04:56');
$schedule->command('model:prune', ['--model' => MonitoredScheduledTaskLogItem::class])->daily();
Expand All @@ -24,7 +24,7 @@ protected function schedule(Schedule $schedule)
/**
* Register the Closure based commands for the application.
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
}
Expand Down
4 changes: 1 addition & 3 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ class Handler extends ExceptionHandler

/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
public function register(): void
{
$this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) {
Expand Down
12 changes: 7 additions & 5 deletions app/Http/Controllers/Admin/ArticlesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use App\Policies\ArticlePolicy;
use App\Queries\SearchArticles;
use Illuminate\Auth\Middleware\Authenticate;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;

class ArticlesController extends Controller
{
Expand All @@ -19,7 +21,7 @@ public function __construct()
$this->middleware([Authenticate::class, VerifyAdmins::class]);
}

public function index()
public function index(): View
{
if ($adminSearch = request('admin_search')) {
$articles = SearchArticles::get($adminSearch)->appends(['admin_search' => $adminSearch]);
Expand All @@ -32,7 +34,7 @@ public function index()
return view('admin.articles', compact('articles', 'adminSearch'));
}

public function approve(Article $article)
public function approve(Article $article): RedirectResponse
{
$this->authorize(ArticlePolicy::APPROVE, $article);

Expand All @@ -43,7 +45,7 @@ public function approve(Article $article)
return redirect()->route('articles.show', $article->slug());
}

public function disapprove(Article $article)
public function disapprove(Article $article): RedirectResponse
{
$this->authorize(ArticlePolicy::DISAPPROVE, $article);

Expand All @@ -54,7 +56,7 @@ public function disapprove(Article $article)
return redirect()->route('articles.show', $article->slug());
}

public function decline(Article $article)
public function decline(Article $article): RedirectResponse
{
$this->authorize(ArticlePolicy::DECLINE, $article);

Expand All @@ -63,7 +65,7 @@ public function decline(Article $article)
return redirect()->route('articles.show', $article->slug());
}

public function togglePinnedStatus(Article $article)
public function togglePinnedStatus(Article $article): RedirectResponse
{
$this->authorize(ArticlePolicy::PINNED, $article);

Expand Down
10 changes: 6 additions & 4 deletions app/Http/Controllers/Admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use App\Policies\UserPolicy;
use App\Queries\SearchUsers;
use Illuminate\Auth\Middleware\Authenticate;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;

class UsersController extends Controller
{
Expand All @@ -20,7 +22,7 @@ public function __construct()
$this->middleware([Authenticate::class, VerifyAdmins::class]);
}

public function index()
public function index(): View
{
if ($adminSearch = request('admin_search')) {
$users = SearchUsers::get($adminSearch)->appends(['admin_search' => $adminSearch]);
Expand All @@ -31,7 +33,7 @@ public function index()
return view('admin.users', compact('users', 'adminSearch'));
}

public function ban(BanRequest $request, User $user)
public function ban(BanRequest $request, User $user): RedirectResponse
{
$this->authorize(UserPolicy::BAN, $user);

Expand All @@ -42,7 +44,7 @@ public function ban(BanRequest $request, User $user)
return redirect()->route('profile', $user->username());
}

public function unban(User $user)
public function unban(User $user): RedirectResponse
{
$this->authorize(UserPolicy::BAN, $user);

Expand All @@ -53,7 +55,7 @@ public function unban(User $user)
return redirect()->route('profile', $user->username());
}

public function delete(User $user)
public function delete(User $user): RedirectResponse
{
$this->authorize(UserPolicy::DELETE, $user);

Expand Down
7 changes: 4 additions & 3 deletions app/Http/Controllers/Articles/ArticlesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Illuminate\View\View;
use Symfony\Component\HttpFoundation\Response;

class ArticlesController extends Controller
Expand Down Expand Up @@ -73,7 +74,7 @@ public function index(Request $request)
]);
}

public function show(Article $article)
public function show(Article $article): View
{
$user = Auth::user();

Expand All @@ -94,7 +95,7 @@ public function show(Article $article)
]);
}

public function create(Request $request)
public function create(Request $request): View
{
$tags = Tag::query();

Expand All @@ -121,7 +122,7 @@ public function store(ArticleRequest $request)
: redirect()->route('articles.show', $article->slug());
}

public function edit(Request $request, Article $article)
public function edit(Request $request, Article $article): View
{
$this->authorize(ArticlePolicy::UPDATE, $article);

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Articles/AuthoredArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Http\Middleware\Authenticate;
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
use Illuminate\Http\Request;
use Illuminate\View\View;

class AuthoredArticles extends Controller
{
Expand All @@ -14,7 +15,7 @@ public function __construct()
$this->middleware([Authenticate::class, EnsureEmailIsVerified::class]);
}

public function __invoke(Request $request)
public function __invoke(Request $request): View
{
return view('users.articles', [
'articles' => $request->user()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/GithubController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function userNotFound(GithubUser $user): RedirectResponse
if ($user->isTooYoung()) {
$this->error('errors.github_account_too_young');

return redirect()->home();
return redirect()->route('home');
}

return $this->redirectUserToRegistrationPage($user);
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ public function username()

/**
* Get the needed authorization credentials from the request.
*
* @return array
*/
protected function credentials(Request $request)
protected function credentials(Request $request): array
{
$credentials = $request->only($this->username(), 'password');

Expand Down
4 changes: 1 addition & 3 deletions app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ public function __construct()

/**
* Get the password reset validation rules.
*
* @return array
*/
protected function rules()
protected function rules(): array
{
return [
'token' => 'required',
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/BlockUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\User;
use App\Policies\UserPolicy;
use Illuminate\Auth\Middleware\Authenticate;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;

class BlockUserController extends Controller
Expand All @@ -15,7 +16,7 @@ public function __construct()
$this->middleware(Authenticate::class);
}

public function __invoke(Request $request, User $user)
public function __invoke(Request $request, User $user): RedirectResponse
{
$this->authorize(UserPolicy::BLOCK, $user);

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Forum/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
use App\Models\Tag;
use App\Models\Thread;
use App\Models\User;
use Illuminate\View\View;

class TagsController extends Controller
{
use UsesFilters;

public function show(Tag $tag)
public function show(Tag $tag): View
{
$threads = [];
$filter = $this->getFilter();
Expand Down
Loading