Skip to content

Commit

Permalink
Update Laravel files to match 10.x updates [API-382]
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Jul 28, 2023
1 parent aba04f2 commit b28990d
Show file tree
Hide file tree
Showing 176 changed files with 768 additions and 677 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* text=lf
* text=auto eol=lf
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Laravel 9.x Defaults
# Laravel 10.x Defaults
/.phpunit.cache
/node_modules
/public/build
/public/hot
Expand Down
8 changes: 2 additions & 6 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,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('cache:prune-stale-tags')
->hourly();
Expand Down Expand Up @@ -102,10 +100,8 @@ protected function schedule(Schedule $schedule)

/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__ . '/Commands');
$this->load(__DIR__ . '/Commands/Docs');
Expand Down
40 changes: 7 additions & 33 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,24 @@
namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Sentry\Laravel\Integration;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [

];

/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var string[]
* @var array<int, string>
*/
protected $dontFlash = [

];

/**
* Report or log an exception.
*
* @return void
*
* @throws \Throwable
*/
public function report(Throwable $exception)
public function register(): void
{
if (app()->bound('sentry') && $this->shouldReport($exception)) {
app('sentry')->captureException($exception);
}

parent::report($exception);
$this->reportable(function (Throwable $e) {
Integration::captureUnhandledException($e);
});
}
}
2 changes: 0 additions & 2 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
11 changes: 7 additions & 4 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,27 @@ class Kernel extends HttpKernel
'auth:api',
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
// WEB-1929: Enable throttling when ready!
// 'throttle:api',
// Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
'restrict',
],
];

/**
* The application's route middleware.
* The application's middleware aliases.
*
* These middleware may be assigned to groups or used individually.
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
*
* @var array
* @var array<string, class-string|string>
*/
protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::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' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \App\Http\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 @@ -4,6 +4,7 @@

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

class Authenticate extends Middleware
{
Expand Down Expand Up @@ -40,14 +41,9 @@ protected function authenticate($request, array $guards)

/**
* 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');
}
}
4 changes: 3 additions & 1 deletion app/Http/Middleware/DebugHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class DebugHeaders
{
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);

Expand Down
7 changes: 3 additions & 4 deletions app/Http/Middleware/DecodeParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

use Symfony\Component\HttpFoundation\ParameterBag;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class DecodeParams
{
/**
* WEB-979: This middleware is a work-around for `http_build_query` and its many
* quirks. You can pass any API params as a JSON string via the `params` param.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$params = $request->get('params');

Expand Down
7 changes: 3 additions & 4 deletions app/Http/Middleware/LoginIpMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class LoginIpMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$whiteIps = config('aic.auth.login_whitelist_ips');
$passed = array_filter(array_map(function ($range) use ($request) {
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Middleware/PreventRequestsDuringMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [

Expand Down
6 changes: 2 additions & 4 deletions app/Http/Middleware/RestrictContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Symfony\Component\HttpFoundation\Response;

use App\Models\BaseModel;
use App\Scopes\PublishedScope;
Expand All @@ -16,11 +17,8 @@ class RestrictContent
{
/**
* Handle an incoming request.
*
* @param string|null $guard
* @return mixed
*/
public function handle(Request $request, Closure $next, $guard = null)
public function handle(Request $request, Closure $next, $guard = null): Response
{
// Define what to show to anonymous users
if (Gate::denies('restricted-access')) {
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Middleware/ThrottleRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Closure;
use Illuminate\Support\Facades\Gate;
use Illuminate\Routing\Middleware\ThrottleRequests as BaseMiddleware;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;


class ThrottleRequests extends BaseMiddleware
{
Expand All @@ -14,7 +17,7 @@ class ThrottleRequests extends BaseMiddleware
* The function signature has to stay the same, but the extra parameters are ignored.
* If the app is unrestricted or the user is logged in keep their throttle clear.
*/
public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes = 1)
public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes = 1, $prefix = ''): Response
{
if (Gate::allows('restricted-access')) {
$key = $this->resolveRequestSignature($request);
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Middleware/TrailingNewline.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\Response;

class TrailingNewline
{
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);

Expand Down
2 changes: 0 additions & 2 deletions app/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'current_password',
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Middleware/TrustHosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
public function hosts(): array
{
return [
$this->allSubdomainsOfApplicationUrl(),
Expand Down
1 change: 1 addition & 0 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class TrustProxies extends Middleware
{
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Middleware/ValidateSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class ValidateSignature extends Middleware
{
/**
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $except = [
// 'fbclid',
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [

Expand Down
4 changes: 2 additions & 2 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class AuthServiceProvider extends BaseServiceProvider
* @var array<class-string, class-string>
*/
protected $policies = [
'App\Models\Model' => 'App\Policies\ModelPolicy',
//
];

public function boot()
public function boot(): void
{
// API-189: Gate gets called before middleware initializes!
$temp = new TrustProxies(config());
Expand Down
6 changes: 2 additions & 4 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ class EventServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
//
}

/**
* Determine if events and listeners should be automatically discovered.
*
* @return bool
*/
public function shouldDiscoverEvents()
public function shouldDiscoverEvents(): bool
{
return false;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Providers/FakerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ class FakerServiceProvider extends ServiceProvider
*
* Peruse the following link for tips on implementing custom Faker providers:
* @link https://stackoverflow.com/questions/38250776/how-to-implement-your-own-faker-provider-in-laravel
*
* @return void
*/
public function register()
public function register(): void
{

$this->app->afterResolving(function (mixed $instance) {
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/ResourceServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ResourceServiceProvider extends ServiceProvider
{
public function register()
public function register(): void
{
$this->app->singleton('Resources', function ($app) {
return new class () {
Expand Down
Loading

0 comments on commit b28990d

Please sign in to comment.