Skip to content

Commit

Permalink
Merge pull request #46 from tighten/shift-129836
Browse files Browse the repository at this point in the history
Laravel 10.x Shift
  • Loading branch information
driftingly authored Sep 27, 2024
2 parents fd90490 + 4211ced commit 19a7544
Show file tree
Hide file tree
Showing 72 changed files with 3,684 additions and 18,246 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
Expand Down Expand Up @@ -47,8 +47,8 @@ PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

GITHUB_TOKEN=

Expand Down
2 changes: 1 addition & 1 deletion .env.testing.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DB_DATABASE=phpreleases

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
Expand Down
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
3d4d70ae2c2d95dc95183637707e7778ffafdc81
582596e4ee576abcadf48ea629d02e0dcedd6a42
2fb8cfa9f5a0710ab2d5fc9cd216a742390613a4
cea5e1493e7fd194d9130c8b57c13fd6968e2cae
a7f19877c5aa0bacf0e1c8c8272a5e7bbd0f019b
ff2f09f4b4b299eecdcd0bea02e24c76373664fd
35 changes: 6 additions & 29 deletions .github/workflows/duster.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,17 @@
name: Duster Fix
name: Run Duster

on:
pull_request:
push:
branches: main
branches: [ main ]
pull_request:

jobs:
duster:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v3
- name: "duster"
uses: tighten/duster-action@v3
with:
ref: ${{ github.head_ref }}

- name: "Duster Fix"
uses: tighten/duster-action@v2
with:
args: fix

- uses: stefanzweifel/git-auto-commit-action@v4
id: auto_commit_action
with:
commit_message: Dusting
commit_user_name: GitHub Action
commit_user_email: actions@github.com

- name: Ignore Duster commit in git blame
if: steps.auto_commit_action.outputs.changes_detected == 'true'
run: echo ${{ steps.auto_commit_action.outputs.commit_hash }} >> .git-blame-ignore-revs

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Ignore Dusting commit in git blame
commit_user_name: GitHub Action
commit_user_email: actions@github.com
args: lint
11 changes: 4 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: tests
name: Run Tests

on:
# Commits made in Duster Fix will not trigger any workflows
# Tests are configured to run after the workflow finishes
workflow_run:
workflows: ["Duster Fix"]
types:
- completed
push:
branches: [ main ]
pull_request:

jobs:
test:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/public/hot
/public/build
/public/storage
/public/css
/public/js
Expand All @@ -8,11 +9,13 @@
.env
.env.backup
.env.testing
.phpunit.result.cache
/.phpunit.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode
phpunit.xml
.phpunit.result.cache
4 changes: 2 additions & 2 deletions app/Console/Commands/SendStatsToSlack.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public function __construct()
parent::__construct();
}

public function handle()
public function handle(): int
{
Notification::route('slack', config('services.slack.webhook'))
->notify(new WeeklyStats);

return 0;
return self::SUCCESS;
}
}
8 changes: 4 additions & 4 deletions app/Console/Commands/SyncPhpReleaseGraphic.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ class SyncPhpReleaseGraphic extends Command

protected $description = 'Fetch the most recent Version Support graphic from https://www.php.net/images/supported-versions.php';

public function handle()
public function handle(): int
{
$svgResponse = Http::get('https://www.php.net/images/supported-versions.php');

// Check if we get an HTML response back, which means the image wasn't found
if (str_contains($svgResponse, '<!DOCTYPE html>')) {
Log::warning('Failed fetching the svg');

return 1;
return self::FAILURE;
}

// Check if there are any changes to the SVG since we last synced it
if (
Storage::disk('public')->exists('supported-versions.svg')
&& Storage::disk('public')->get('supported-versions.svg') === $svgResponse->body()
) {
return 0;
return self::SUCCESS;
}

Storage::disk('public')->put('supported-versions.svg', $svgResponse);

return 0;
return self::SUCCESS;
}
}
4 changes: 3 additions & 1 deletion app/Console/Commands/SyncPhpReleases.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SyncPhpReleases extends Command

protected $description = 'Pull PHP releases from GitHub into our application.';

public function handle()
public function handle(): int
{
Log::info('Syncing PHP Releases');

Expand Down Expand Up @@ -74,6 +74,8 @@ public function handle()
});

$this->info('Finished saving PHP releases.');

return self::SUCCESS;
}

private function fetchReleasesFromGitHub()
Expand Down
8 changes: 2 additions & 6 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ class Kernel extends ConsoleKernel

/**
* Define the application's command schedule.
*
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->command(SyncPhpReleases::class)->twiceDaily();
$schedule->command(SyncPhpReleaseGraphic::class)->daily();
Expand All @@ -33,10 +31,8 @@ protected function schedule(Schedule $schedule)

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__ . '/Commands');

Expand Down
17 changes: 3 additions & 14 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,9 @@
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
Expand All @@ -29,10 +20,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) {
//
Expand Down
12 changes: 12 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
}
3 changes: 2 additions & 1 deletion app/Http/Controllers/HitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use App\Models\Hit;
use Illuminate\Support\Facades\DB;
use Illuminate\View\View;

class HitController
{
public function __invoke()
public function __invoke(): View
{
return view('stats', [
'hits' => Hit::simplePaginate(),
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use Carbon\Carbon;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;

class IndexController
{
public function index()
public function index(): View
{
return view('index', ['graphicUpdatedToday' => $this->graphicHasBeenUpdatedToday()]);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ReleaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Resources\ReleaseResource;
use App\Models\Release;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
Expand Down Expand Up @@ -33,7 +34,7 @@ public function minimumSupported(string $supportType = 'active')
);
}

public function showLatest()
public function showLatest(): JsonResponse
{
return response()->json(
(string) Release::orderByDesc('major')
Expand Down
11 changes: 6 additions & 5 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Kernel extends HttpKernel
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
Expand All @@ -42,25 +42,26 @@ class Kernel extends HttpKernel

'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];

/**
* 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,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
Expand Down
10 changes: 3 additions & 7 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;

class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
protected function redirectTo(Request $request): ?string
{
if (! $request->expectsJson()) {
return route('login');
}
return $request->expectsJson() ? null : route('login');
}
}
3 changes: 2 additions & 1 deletion app/Http/Middleware/RecordHit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
use App\Models\Hit;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class RecordHit
{
public function handle(Request $request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
return $next($request);
}
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param string|null ...$guards
* @return mixed
*/
public function handle(Request $request, Closure $next, ...$guards)
public function handle(Request $request, Closure $next, string ...$guards): Response
{
$guards = empty($guards) ? [null] : $guards;

Expand Down
Loading

0 comments on commit 19a7544

Please sign in to comment.