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

Upgrade to Laravel 10 and PHP 8.1 #352

Merged
merged 19 commits into from
Aug 20, 2024
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 .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Nova Packages on a server that has 8.1 installed?

php-version: 8.1

- name: Install dependencies
run: composer install --no-interaction --ignore-platform-reqs
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- main
jobs:
test:
name: PHP 8.0, Laravel 9.*
name: PHP 8.1, Laravel 9.*
runs-on: ubuntu-latest

steps:
Expand All @@ -17,14 +17,14 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1

- name: Cache Composer dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: php-8.0-laravel-9.*-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: php-8.0-laravel-9`.*-composer-
key: php-8.1-laravel-9.*-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: php-8.1-laravel-9`.*-composer-

- name: Cache npm dependencies
uses: actions/cache@v1
Expand Down
13 changes: 8 additions & 5 deletions app/Collaborator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace App;

use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

Expand All @@ -15,27 +18,27 @@ class Collaborator extends Model

protected $appends = ['name_with_username'];

public function allAuthoredPackages()
public function allAuthoredPackages(): HasMany
{
return $this->hasMany(Package::class, 'author_id')->withoutGlobalScope('notDisabled');
}

public function authoredPackages()
public function authoredPackages(): HasMany
{
return $this->hasMany(Package::class, 'author_id');
}

public function contributedPackages()
public function contributedPackages(): BelongsToMany
{
return $this->belongsToMany(Package::class);
}

public function submittedPackages()
public function submittedPackages(): HasMany
{
return $this->hasMany(Package::class, 'submitter_id', 'user_id');
}

public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/CheckPackageUrls.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CheckPackageUrls extends Command

protected $description = 'Check all package URLs for 4XX errors';

public function handle()
public function handle(): void
{
$validPackages = Package::whereNull('marked_as_unavailable_at')
->with('author')
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/DeleteAbandonedScreenshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DeleteAbandonedScreenshots extends Command

protected $description = 'Delete all screenshots that are older than 24 hours and not associated with a package';

public function handle()
public function handle(): void
{
dispatch(new DeleteAbandonedScreenshotsJob);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/DeleteOpenGraphImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DeleteOpenGraphImages extends Command

protected $description = 'Deletes all existing Open Graph images from storage.';

public function handle()
public function handle(): void
{
if (! $this->argument('package')) {
$files = Storage::allFiles(config('opengraph.image_directory_name') . '/');
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/DeleteSelfAuthoredPackageRatings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DeleteSelfAuthoredPackageRatings extends Command

protected $description = 'Delete all package ratings where the rating was by the author or a contributor of the package';

public function handle()
public function handle(): void
{
$this->deleteSelfAuthoredPackageRatings();
$this->deleteSelfContributedPackageRatings();
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/DisableUnavailablePackages.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DisableUnavailablePackages extends Command

protected $description = 'Disable unavailable packages after one month.';

public function handle()
public function handle(): void
{
$unavailablePackages = Package::whereNotNull('marked_as_unavailable_at')
->where('is_disabled', 0)
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/GenerateOpenGraphImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GenerateOpenGraphImages extends Command

protected $description = 'Generates new Open Graph images for every package.';

public function handle()
public function handle(): void
{
$this->callSilent('purge:ogimage', ['package' => $this->argument('package')]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GenerateUuidsForExistingFailedJobs extends Command

protected $description = 'Generates UUIDs for existing failed jobs that do not have a UUID set.';

public function handle()
public function handle(): int
{
DB::table('failed_jobs')->whereNull('uuid')->cursor()->each(function ($job) {
DB::table('failed_jobs')
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/GithubAuthNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GithubAuthNotify extends Command

protected $description = 'Notifies all users that they need to log in with Github.';

public function handle()
public function handle(): void
{
Notification::send(
User::whereNull('github_username')->get(),
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/SendUnavailablePackageFollowUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SendUnavailablePackageFollowUp extends Command

protected $description = 'If package has been unavailable for two weeks, send follow-up to package author.';

public function handle()
public function handle(): void
{
$unavailablePackages = Package::whereNotNull('marked_as_unavailable_at')
->where('is_disabled', 0)
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/SyncPackagistData.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SyncPackagistData extends Command

protected $description = 'Cache Packagist download counts and GitHub stars for every package.';

public function handle()
public function handle(): void
{
foreach (Package::all() as $package) {
dispatch(new SyncPackagePackagistData($package));
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/SyncRepositoryData.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SyncRepositoryData extends Command

protected $description = 'Sync VCS repository readme, url and source for every package.';

public function handle()
public function handle(): void
{
$packages = $this->argument('package')
? Package::where('id', $this->argument('package'))->get()
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Kernel extends ConsoleKernel
CheckPackageUrls::class
];

protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->command('sync:packagist')->everyTwoHours();
// Every two hours at minute 30.
Expand All @@ -32,7 +32,7 @@ protected function schedule(Schedule $schedule)
// $schedule->command('novapackages:disable-unavailable-packages')->dailyAt('21:30');
}

protected function commands()
protected function commands(): void
{
$this->load(__DIR__.'/Commands');

Expand Down
24 changes: 1 addition & 23 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@

class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
Expand All @@ -39,18 +21,15 @@ class Handler extends ExceptionHandler

/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
public function register(): void
{
//
}

/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*
* @throws \Throwable
Expand All @@ -68,7 +47,6 @@ public function report(Throwable $exception)
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
Expand Down
3 changes: 2 additions & 1 deletion app/Favorite.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use App\Package;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -20,7 +21,7 @@ class Favorite extends Model
'user_id',
];

public function package()
public function package(): BelongsTo
{
return $this->belongsTo(Package::class);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace App\Http\Controllers;

use Illuminate\View\View;
use App\Package;
use Illuminate\Http\Request;

class AdminController extends Controller
{
public function index()
public function index(): View
{
return view('admin', [
'enabled_packages' => Package::all(),
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Api/StatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace App\Http\Controllers\Api;

use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use App\Stats;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class StatsController extends Controller
{
public function __invoke(Request $request, Stats $stats)
public function __invoke(Request $request, Stats $stats): JsonResponse
{
Log::info('API: /status');

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/App/ApiDetailsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace App\Http\Controllers\App;

use Illuminate\View\View;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class ApiDetailsController extends Controller
{
public function __invoke()
public function __invoke(): View
{
return view('app.api_details');
}
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/App/CollaboratorClaimController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

namespace App\Http\Controllers\App;

use Illuminate\View\View;
use Illuminate\Http\RedirectResponse;
use App\Collaborator;
use App\Events\CollaboratorClaimed;
use App\Http\Controllers\Controller;

class CollaboratorClaimController extends Controller
{
public function create(Collaborator $collaborator)
public function create(Collaborator $collaborator): View
{
return view('app.collaborators.claim', [
'collaborator' => $collaborator,
]);
}

public function store(Collaborator $collaborator)
public function store(Collaborator $collaborator): RedirectResponse
{
$collaborator->user()->associate(auth()->user())->save();

Expand Down
12 changes: 7 additions & 5 deletions app/Http/Controllers/App/CollaboratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Http\Controllers\App;

use Illuminate\View\View;
use Illuminate\Http\RedirectResponse;
use App\Collaborator;
use App\Events\CollaboratorCreated;
use App\Http\Controllers\Controller;
Expand All @@ -11,19 +13,19 @@

class CollaboratorController extends Controller
{
public function index()
public function index(): View
{
return view('app.collaborators.index', [
'unclaimed_collaborators' => Collaborator::doesntHave('user')->get(),
]);
}

public function create()
public function create(): View
{
return view('app.collaborators.create');
}

public function store()
public function store(): RedirectResponse
{
$input = request()->validate([
'name' => 'required',
Expand All @@ -47,12 +49,12 @@ public function store()
return redirect()->route('app.collaborators.index');
}

public function edit(Collaborator $collaborator)
public function edit(Collaborator $collaborator): View
{
return view('app.collaborators.edit', compact('collaborator'));
}

public function update(Collaborator $collaborator)
public function update(Collaborator $collaborator): RedirectResponse
{
$input = request()->validate([
'name' => 'required',
Expand Down
Loading
Loading