Merge pull request #670 from jonnybarnes/develop

MTM: Laravel 10
This commit is contained in:
Jonny Barnes 2023-02-18 10:03:06 +00:00 • committed by GitHub
commit fcf0b4a778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
163 changed files with 2959 additions and 3146 deletions

View file

@ -5,17 +5,23 @@ root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
# Tab indentation
[Makefile]
indent_style = tab
tab_width = 4
[yml]
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

View file

@ -25,22 +25,10 @@ class MigratePlaceDataFromPostgis extends Command
*/
protected $description = 'Copy Postgis data to normal latitude longitude fields';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
public function handle(): int
{
$locationColumn = DB::selectOne(DB::raw("
SELECT EXISTS (

View file

@ -6,6 +6,7 @@ namespace App\Console\Commands;
use App\Models\WebMention;
use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\FileSystem\FileSystem;
class ParseCachedWebMentions extends Command
@ -27,9 +28,9 @@ class ParseCachedWebMentions extends Command
/**
* Execute the console command.
*
* @return mixed
* @throws FileNotFoundException
*/
public function handle(FileSystem $filesystem)
public function handle(FileSystem $filesystem): void
{
$htmlFiles = $filesystem->allFiles(storage_path() . '/HTML');
foreach ($htmlFiles as $file) {
@ -49,9 +50,6 @@ class ParseCachedWebMentions extends Command
/**
* Determine the source URL from a filename.
*
* @param string
* @return string
*/
private function urlFromFilename(string $filepath): string
{

View file

@ -24,22 +24,10 @@ class ReDownloadWebMentions extends Command
*/
protected $description = 'Redownload the HTML content of webmentions';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
public function handle(): void
{
$webmentions = WebMention::all();
foreach ($webmentions as $webmention) {

View file

@ -10,7 +10,7 @@ class Kernel extends ConsoleKernel
/**
* The Artisan commands provided by your application.
*
* @var array
* @var array<int, string>
*/
protected $commands = [
Commands\ParseCachedWebMentions::class,
@ -20,22 +20,18 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*
* @codeCoverageIgnore
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->command('cache:prune-stale-tags')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__ . '/Commands');

View file

@ -21,47 +21,34 @@ class Handler extends ExceptionHandler
/**
* A list of the exception types that are not reported.
*
* @var array
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
NotFoundHttpException::class,
ModelNotFoundException::class,
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param Throwable $throwable
* @return void
*
* @throws Exception
* @throws Throwable
*/
public function report(Throwable $throwable)
public function report(Throwable $e): void
{
parent::report($throwable);
parent::report($e);
if (config('logging.slack') && $this->shouldReport($throwable)) {
if (config('logging.slack') && $this->shouldReport($e)) {
$guzzle = new Client([
'headers' => [
'Content-Type' => 'application/json',
],
]);
$exceptionName = get_class($throwable) ?? 'Unknown Exception';
$title = $exceptionName . ': ' . $throwable->getMessage();
$exceptionName = get_class($e) ?? 'Unknown Exception';
$title = $exceptionName . ': ' . $e->getMessage();
$guzzle->post(
config('logging.slack'),
@ -89,7 +76,6 @@ class Handler extends ExceptionHandler
* Render an exception into an HTTP response.
*
* @param Request $request
* @param Throwable $throwable
* @return Response
*
* @throws Throwable

View file

@ -14,8 +14,6 @@ class ClientsController extends Controller
{
/**
* Show a list of known clients.
*
* @return \Illuminate\View\View
*/
public function index(): View
{
@ -26,8 +24,6 @@ class ClientsController extends Controller
/**
* Show form to add a client name.
*
* @return \Illuminate\View\View
*/
public function create(): View
{
@ -36,8 +32,6 @@ class ClientsController extends Controller
/**
* Process the request to adda new client name.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function store(): RedirectResponse
{
@ -51,9 +45,6 @@ class ClientsController extends Controller
/**
* Show a form to edit a client name.
*
* @param int $clientId
* @return \Illuminate\View\View
*/
public function edit(int $clientId): View
{
@ -68,9 +59,6 @@ class ClientsController extends Controller
/**
* Process the request to edit a client name.
*
* @param int $clientId
* @return \Illuminate\Http\RedirectResponse
*/
public function update(int $clientId): RedirectResponse
{
@ -84,9 +72,6 @@ class ClientsController extends Controller
/**
* Process a request to delete a client.
*
* @param int $clientId
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(int $clientId): RedirectResponse
{

View file

@ -17,8 +17,6 @@ class ContactsController extends Controller
{
/**
* List the currect contacts that can be edited.
*
* @return \Illuminate\View\View
*/
public function index(): View
{
@ -29,8 +27,6 @@ class ContactsController extends Controller
/**
* Display the form to add a new contact.
*
* @return \Illuminate\View\View
*/
public function create(): View
{
@ -39,8 +35,6 @@ class ContactsController extends Controller
/**
* Process the request to add a new contact.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function store(): RedirectResponse
{
@ -57,9 +51,6 @@ class ContactsController extends Controller
/**
* Show the form to edit an existing contact.
*
* @param int $contactId
* @return \Illuminate\View\View
*/
public function edit(int $contactId): View
{
@ -72,9 +63,6 @@ class ContactsController extends Controller
* Process the request to edit a contact.
*
* @todo Allow saving profile pictures for people without homepages
*
* @param int $contactId
* @return \Illuminate\Http\RedirectResponse
*/
public function update(int $contactId): RedirectResponse
{
@ -101,9 +89,6 @@ class ContactsController extends Controller
/**
* Process the request to delete a contact.
*
* @param int $contactId
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(int $contactId): RedirectResponse
{
@ -119,7 +104,6 @@ class ContactsController extends Controller
* This method attempts to find the microformat marked-up profile image
* from a given homepage and save it accordingly
*
* @param int $contactId
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function getAvatar(int $contactId)

View file

@ -11,8 +11,6 @@ class HomeController extends Controller
{
/**
* Show the homepage of the admin CP.
*
* @return \Illuminate\View\View
*/
public function welcome(): View
{

View file

@ -14,8 +14,6 @@ class LikesController extends Controller
{
/**
* List the likes that can be edited.
*
* @return \Illuminate\View\View
*/
public function index(): View
{
@ -26,8 +24,6 @@ class LikesController extends Controller
/**
* Show the form to make a new like.
*
* @return \Illuminate\View\View
*/
public function create(): View
{
@ -36,8 +32,6 @@ class LikesController extends Controller
/**
* Process a request to make a new like.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function store(): RedirectResponse
{
@ -51,9 +45,6 @@ class LikesController extends Controller
/**
* Display the form to edit a specific like.
*
* @param int $likeId
* @return \Illuminate\View\View
*/
public function edit(int $likeId): View
{
@ -67,9 +58,6 @@ class LikesController extends Controller
/**
* Process a request to edit a like.
*
* @param int $likeId
* @return \Illuminate\Http\RedirectResponse
*/
public function update(int $likeId): RedirectResponse
{
@ -83,9 +71,6 @@ class LikesController extends Controller
/**
* Process the request to delete a like.
*
* @param int $likeId
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(int $likeId): RedirectResponse
{

View file

@ -15,8 +15,6 @@ class NotesController extends Controller
{
/**
* List the notes that can be edited.
*
* @return \Illuminate\View\View
*/
public function index(): View
{
@ -30,8 +28,6 @@ class NotesController extends Controller
/**
* Show the form to make a new note.
*
* @return \Illuminate\View\View
*/
public function create(): View
{
@ -40,9 +36,6 @@ class NotesController extends Controller
/**
* Process a request to make a new note.
*
* @param Request $request
* @return RedirectResponse
*/
public function store(Request $request): RedirectResponse
{
@ -56,9 +49,6 @@ class NotesController extends Controller
/**
* Display the form to edit a specific note.
*
* @param int $noteId
* @return \Illuminate\View\View
*/
public function edit(int $noteId): View
{
@ -71,9 +61,6 @@ class NotesController extends Controller
/**
* Process a request to edit a note. Easy since this can only be done
* from the admin CP.
*
* @param int $noteId
* @return \Illuminate\Http\RedirectResponse
*/
public function update(int $noteId): RedirectResponse
{
@ -92,9 +79,6 @@ class NotesController extends Controller
/**
* Delete the note.
*
* @param int $noteId
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(int $noteId): RedirectResponse
{

View file

@ -21,8 +21,6 @@ class PlacesController extends Controller
/**
* List the places that can be edited.
*
* @return View
*/
public function index(): View
{
@ -33,8 +31,6 @@ class PlacesController extends Controller
/**
* Show the form to make a new place.
*
* @return View
*/
public function create(): View
{
@ -43,8 +39,6 @@ class PlacesController extends Controller
/**
* Process a request to make a new place.
*
* @return RedirectResponse
*/
public function store(): RedirectResponse
{
@ -62,9 +56,6 @@ class PlacesController extends Controller
/**
* Display the form to edit a specific place.
*
* @param int $placeId
* @return View
*/
public function edit(int $placeId): View
{
@ -75,9 +66,6 @@ class PlacesController extends Controller
/**
* Process a request to edit a place.
*
* @param int $placeId
* @return RedirectResponse
*/
public function update(int $placeId): RedirectResponse
{
@ -94,9 +82,6 @@ class PlacesController extends Controller
/**
* List the places we can merge with the current place.
*
* @param int $placeId
* @return View
*/
public function mergeIndex(int $placeId): View
{
@ -114,10 +99,6 @@ class PlacesController extends Controller
/**
* Show a form for merging two specific places.
*
* @param int $placeId1
* @param int $placeId2
* @return View
*/
public function mergeEdit(int $placeId1, int $placeId2): View
{
@ -129,8 +110,6 @@ class PlacesController extends Controller
/**
* Process the request to merge two places.
*
* @return RedirectResponse
*/
public function mergeStore(): RedirectResponse
{

View file

@ -14,8 +14,6 @@ class SyndicationTargetsController extends Controller
{
/**
* Show a list of known syndication targets.
*
* @return View
*/
public function index(): View
{
@ -26,8 +24,6 @@ class SyndicationTargetsController extends Controller
/**
* Show form to add a syndication target.
*
* @return View
*/
public function create(): View
{
@ -36,9 +32,6 @@ class SyndicationTargetsController extends Controller
/**
* Process the request to adda new syndication target.
*
* @param Request $request
* @return RedirectResponse
*/
public function store(Request $request): RedirectResponse
{
@ -60,9 +53,6 @@ class SyndicationTargetsController extends Controller
/**
* Show a form to edit a syndication target.
*
* @param SyndicationTarget $syndicationTarget
* @return View
*/
public function edit(SyndicationTarget $syndicationTarget): View
{
@ -73,10 +63,6 @@ class SyndicationTargetsController extends Controller
/**
* Process the request to edit a client name.
*
* @param Request $request
* @param SyndicationTarget $syndicationTarget
* @return RedirectResponse
*/
public function update(Request $request, SyndicationTarget $syndicationTarget): RedirectResponse
{
@ -98,9 +84,6 @@ class SyndicationTargetsController extends Controller
/**
* Process a request to delete a client.
*
* @param SyndicationTarget $syndicationTarget
* @return RedirectResponse
*/
public function destroy(SyndicationTarget $syndicationTarget): RedirectResponse
{

View file

@ -14,10 +14,6 @@ class ArticlesController extends Controller
{
/**
* Show all articles (with pagination).
*
* @param int|null $year
* @param int|null $month
* @return View
*/
public function index(int $year = null, int $month = null): View
{
@ -31,13 +27,8 @@ class ArticlesController extends Controller
/**
* Show a single article.
*
* @param int $year
* @param int $month
* @param string $slug
* @return RedirectResponse|View
*/
public function show(int $year, int $month, string $slug)
public function show(int $year, int $month, string $slug): RedirectResponse|View
{
try {
$article = Article::where('titleurl', $slug)->firstOrFail();
@ -56,11 +47,7 @@ class ArticlesController extends Controller
}
/**
* We only have the ID, work out post title, year and month
* and redirect to it.
*
* @param string $idFromUrl
* @return RedirectResponse
* We only have the ID, work out post title, year and month and redirect to it.
*/
public function onlyIdInUrl(string $idFromUrl): RedirectResponse
{

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
@ -12,10 +13,8 @@ class AuthController extends Controller
{
/**
* Show the login form.
*
* @return View|RedirectResponse
*/
public function showLogin()
public function showLogin(): View|RedirectResponse
{
if (Auth::check()) {
return redirect('/');
@ -25,14 +24,11 @@ class AuthController extends Controller
}
/**
* Log in a user, set a session variable, check credentials against
* the .env file.
*
* @return RedirectResponse
* Log in a user, set a session variable, check credentials against the `.env` file.
*/
public function login(): RedirectResponse
public function login(Request $request): RedirectResponse
{
$credentials = request()->only('name', 'password');
$credentials = $request->only('name', 'password');
if (Auth::attempt($credentials, true)) {
return redirect()->intended('/');
@ -42,11 +38,9 @@ class AuthController extends Controller
}
/**
* Show the form to logout a user.
*
* @return View|RedirectResponse
* Show the form to allow a user to log-out.
*/
public function showLogout()
public function showLogout(): View|RedirectResponse
{
if (Auth::check() === false) {
// The user is not logged in, just redirect them home
@ -58,8 +52,6 @@ class AuthController extends Controller
/**
* Log the user out from their current session.
*
* @return RedirectResponse;
*/
public function logout(): RedirectResponse
{

View file

@ -11,8 +11,6 @@ class BookmarksController extends Controller
{
/**
* Show the most recent bookmarks.
*
* @return View
*/
public function index(): View
{
@ -23,9 +21,6 @@ class BookmarksController extends Controller
/**
* Show a single bookmark.
*
* @param Bookmark $bookmark
* @return View
*/
public function show(Bookmark $bookmark): View
{
@ -36,9 +31,6 @@ class BookmarksController extends Controller
/**
* Show bookmarks tagged with a specific tag.
*
* @param string $tag
* @return View
*/
public function tagged(string $tag): View
{

View file

@ -12,8 +12,6 @@ class ContactsController extends Controller
{
/**
* Show all the contacts.
*
* @return View
*/
public function index(): View
{
@ -33,9 +31,6 @@ class ContactsController extends Controller
/**
* Show a single contact.
*
* @param Contact $contact
* @return View
*/
public function show(Contact $contact): View
{

View file

@ -13,8 +13,6 @@ class FeedsController extends Controller
{
/**
* Returns the blog RSS feed.
*
* @return Response
*/
public function blogRss(): Response
{
@ -28,8 +26,6 @@ class FeedsController extends Controller
/**
* Returns the blog Atom feed.
*
* @return Response
*/
public function blogAtom(): Response
{
@ -42,8 +38,6 @@ class FeedsController extends Controller
/**
* Returns the notes RSS feed.
*
* @return Response
*/
public function notesRss(): Response
{
@ -57,8 +51,6 @@ class FeedsController extends Controller
/**
* Returns the notes Atom feed.
*
* @return Response
*/
public function notesAtom(): Response
{
@ -73,8 +65,6 @@ class FeedsController extends Controller
/**
* Returns the blog JSON feed.
*
* @return array
*/
public function blogJson(): array
{
@ -106,10 +96,8 @@ class FeedsController extends Controller
/**
* Returns the notes JSON feed.
*
* @return array
*/
public function notesJson()
public function notesJson(): array
{
$notes = Note::latest()->with('media')->take(20)->get();
$data = [
@ -138,8 +126,6 @@ class FeedsController extends Controller
/**
* Returns the blog JF2 feed.
*
* @return JsonResponse
*/
public function blogJf2(): JsonResponse
{
@ -176,8 +162,6 @@ class FeedsController extends Controller
/**
* Returns the notes JF2 feed.
*
* @return JsonResponse
*/
public function notesJf2(): JsonResponse
{

View file

@ -7,6 +7,7 @@ use App\Models\Bookmark;
use App\Models\Like;
use App\Models\Note;
use App\Services\ActivityStreamsService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\View\View;
@ -14,12 +15,10 @@ class FrontPageController extends Controller
{
/**
* Show all the recent activity.
*
* @return Response|View
*/
public function index()
public function index(Request $request): Response|View
{
if (request()->wantsActivityStream()) {
if ($request->wantsActivityStream()) {
return (new ActivityStreamsService())->siteOwnerResponse();
}

View file

@ -11,8 +11,6 @@ class LikesController extends Controller
{
/**
* Show the latest likes.
*
* @return View
*/
public function index(): View
{
@ -23,9 +21,6 @@ class LikesController extends Controller
/**
* Show a single like.
*
* @param Like $like
* @return View
*/
public function show(Like $like): View
{

Some files were not shown because too many files have changed in this diff Show more