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 #46

Merged
merged 49 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ec60dab
Convert `optional()` to nullsafe operator
laravel-shift Sep 27, 2024
0ddf832
Use Faker methods
laravel-shift Sep 27, 2024
63a8ff4
Remove unnecessary `$model` property
laravel-shift Sep 27, 2024
a13aed0
Adopt class based routes
laravel-shift Sep 27, 2024
87f6dd0
Move `resources/lang` folder
laravel-shift Sep 27, 2024
4746f90
Slim `lang` files
laravel-shift Sep 27, 2024
eb8c3ba
Remove explicit call to register policies
laravel-shift Sep 27, 2024
122749d
Remove `fruitcake/laravel-cors` dependency
laravel-shift Sep 27, 2024
fa34d6e
Shift core files
laravel-shift Sep 27, 2024
a700229
Shift config files
laravel-shift Sep 27, 2024
417a4eb
Default config files
laravel-shift Sep 27, 2024
e8f1a73
Bump Composer dependencies
laravel-shift Sep 27, 2024
a57fb0f
Bump NPM dependencies
laravel-shift Sep 27, 2024
284a94d
Use `<env>` tags for configuration
laravel-shift Sep 27, 2024
193f4af
Adopt anonymous migrations
laravel-shift Sep 27, 2024
10243ba
Rename `password_resets` table
laravel-shift Sep 27, 2024
4a052ae
Add type hints for Laravel 10
laravel-shift Sep 27, 2024
79d9f64
Add type hints from DocBlocks
laravel-shift Sep 27, 2024
24d12f4
Remove redundant typing from DocBlocks
laravel-shift Sep 27, 2024
2fb8cfa
Dusting
driftingly Sep 27, 2024
0eabf29
Ignore Dusting commit in git blame
driftingly Sep 27, 2024
851b968
Update dependencies
driftingly Sep 27, 2024
cea5e14
Dusting
driftingly Sep 27, 2024
1ed3705
Ignore Dusting commit in git blame
driftingly Sep 27, 2024
fc64e4c
Update `FILESYSTEM_DISK` change in `.env.*` files
driftingly Sep 27, 2024
7ce2984
Update Duster
driftingly Sep 27, 2024
1ecc45c
Update command returns
driftingly Sep 27, 2024
a7f1987
Dusting
driftingly Sep 27, 2024
f01a1f2
Ignore Dusting commit in git blame
driftingly Sep 27, 2024
4850d2d
Bump PHPUnit dependencies
laravel-shift Sep 27, 2024
0d3f3f9
Ignore PHPUnit cache folder
laravel-shift Sep 27, 2024
f7950b1
Adopt PHP attributes in test classes
laravel-shift Sep 27, 2024
c85aa78
Define test classes as `final`
laravel-shift Sep 27, 2024
ff2f09f
Dusting
driftingly Sep 27, 2024
4fd7ba1
Ignore Dusting commit in git blame
driftingly Sep 27, 2024
0ba0984
Update PHPUnit config
driftingly Sep 27, 2024
1998a1f
Update Duster CI to not commit
driftingly Sep 27, 2024
7a3eacc
Merge pull request #47 from tighten/shift-129840
driftingly Sep 27, 2024
8a0f2ed
Add npm dependencies
laravel-shift Sep 27, 2024
87eceab
Update build scripts
laravel-shift Sep 27, 2024
eff5db9
Configure Vite
laravel-shift Sep 27, 2024
3bc4f13
Remove `webpack.mix.js`
laravel-shift Sep 27, 2024
f31bb6f
Use ES modules
laravel-shift Sep 27, 2024
975a3fb
Rename ENV variables
laravel-shift Sep 27, 2024
4d8d51f
Add PostCSS configuration for Tailwind
laravel-shift Sep 27, 2024
c8bee67
Use new `@vite` Blade directive
laravel-shift Sep 27, 2024
358d2d1
Ignore build assets
laravel-shift Sep 27, 2024
e654b2f
Merge pull request #48 from tighten/shift-129841
driftingly Sep 27, 2024
4211ced
Update js dependencies
driftingly Sep 27, 2024
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
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: [email protected]

- 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: [email protected]
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
Loading