Skip to content

Commit 3fc7152

Browse files
Update to Laravel 8 and require PHP 7.4
1 parent dfb9902 commit 3fc7152

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2871
-1809
lines changed

app/AddMediaFromGitHubApiUrl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App;
44

55
use GuzzleHttp\Client;
6-
use Spatie\MediaLibrary\FileAdder\FileAdderFactory;
6+
use Spatie\MediaLibrary\MediaCollections\FileAdderFactory;
77

88
trait AddMediaFromGitHubApiUrl
99
{

app/Beta8JavascriptFileParser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Beta8JavascriptFileParser
88
{
9-
protected $content;
9+
protected string $content;
1010

1111
public function __construct(string $content)
1212
{

app/Console/Commands/GetCoreJavascriptHash.php

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?php
22

3-
43
namespace App\Console\Commands;
54

6-
75
use GuzzleHttp\Client;
86
use Illuminate\Console\Command;
97

app/Console/Commands/RetrieveExtensions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RetrieveExtensions extends Command
1919
protected $signature = 'extensions:retrieve';
2020
protected $description = 'Retrieve extensions via Packagist';
2121

22-
protected $client;
22+
protected Client $client;
2323

2424
public function __construct()
2525
{

app/Events/AbstractTaskEvent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ abstract class AbstractTaskEvent implements ShouldBroadcast
1313
{
1414
use Dispatchable, InteractsWithSockets, SerializesModels;
1515

16-
public $task;
16+
public Task $task;
1717

1818
public function __construct(Task $task)
1919
{

app/Events/OptOutCheckUpdated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class OptOutCheckUpdated implements ShouldBroadcast
1515
{
1616
use Dispatchable, InteractsWithSockets, SerializesModels;
1717

18-
public $check;
18+
public OptOutCheck $check;
1919

2020
public function __construct(OptOutCheck $check)
2121
{

app/Events/RequestUpdated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class RequestUpdated implements ShouldBroadcast
1515
{
1616
use Dispatchable, InteractsWithSockets, SerializesModels;
1717

18-
public $request;
18+
public Request $request;
1919

2020
public function __construct(Request $request)
2121
{

app/Events/ScanUpdated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ScanUpdated implements ShouldBroadcast
1313
{
1414
use Dispatchable, InteractsWithSockets, SerializesModels;
1515

16-
public $scan;
16+
public Scan $scan;
1717

1818
public function __construct(Scan $scan)
1919
{

app/Events/TaskLog.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
class TaskLog extends AbstractTaskEvent
88
{
9-
protected $time;
10-
protected $message;
9+
protected string $time;
10+
protected string $message;
1111

1212
public function __construct(Task $task, string $time, string $message)
1313
{

app/Exceptions/Handler.php

+10-26
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Handler extends ExceptionHandler
1010
/**
1111
* A list of the exception types that are not reported.
1212
*
13-
* @var array
13+
* @var array<int, class-string<Throwable>>
1414
*/
1515
protected $dontReport = [
1616
//
@@ -19,41 +19,25 @@ class Handler extends ExceptionHandler
1919
/**
2020
* A list of the inputs that are never flashed for validation exceptions.
2121
*
22-
* @var array
22+
* @var array<int, string>
2323
*/
2424
protected $dontFlash = [
25+
'current_password',
2526
'password',
2627
'password_confirmation',
2728
];
2829

2930
/**
30-
* Report or log an exception.
31+
* Register the exception handling callbacks for the application.
3132
*
32-
* @param \Throwable $exception
3333
* @return void
34-
*
35-
* @throws \Exception
36-
*/
37-
public function report(Throwable $exception)
38-
{
39-
if (app()->bound('sentry') && $this->shouldReport($exception)) {
40-
app('sentry')->captureException($exception);
41-
}
42-
43-
parent::report($exception);
44-
}
45-
46-
/**
47-
* Render an exception into an HTTP response.
48-
*
49-
* @param \Illuminate\Http\Request $request
50-
* @param \Throwable $exception
51-
* @return \Symfony\Component\HttpFoundation\Response
52-
*
53-
* @throws \Throwable
5434
*/
55-
public function render($request, Throwable $exception)
35+
public function register()
5636
{
57-
return parent::render($request, $exception);
37+
$this->reportable(function (Throwable $e) {
38+
if (app()->bound('sentry')) {
39+
app('sentry')->captureException($e);
40+
}
41+
});
5842
}
5943
}

app/ExtensionVersion.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Carbon\Carbon;
66
use Illuminate\Database\Eloquent\Model;
7-
use Spatie\MediaLibrary\HasMedia\HasMedia;
8-
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
7+
use Spatie\MediaLibrary\HasMedia;
8+
use Spatie\MediaLibrary\InteractsWithMedia;
99

1010
/**
1111
* @property int $id
@@ -25,7 +25,7 @@
2525
class ExtensionVersion extends Model implements HasMedia
2626
{
2727
use AddMediaFromGitHubApiUrl;
28-
use HasMediaTrait;
28+
use InteractsWithMedia;
2929

3030
protected $casts = [
3131
'packagist' => 'array',
@@ -47,7 +47,7 @@ public function extension()
4747
return $this->belongsTo(Extension::class);
4848
}
4949

50-
public function registerMediaCollections()
50+
public function registerMediaCollections(): void
5151
{
5252
$this
5353
->addMediaCollection('dist')

app/FlarumVersion.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FlarumVersion
2828

2929
// MD5 hash of the javascript of Flarum core, excluding the sourcemap declaration
3030
// Obtained through the GetCoreJavascriptHash command
31-
public $forumJavascriptHashes = [
31+
public array $forumJavascriptHashes = [
3232
'189296cfbba1fc2ed589ba2f15725905' => self::BETA_8,
3333
'c4852231b8e6286ce37761a1cfab1297' => self::BETA_9,
3434
'3616121e8824e77d8676060d103765fb' => self::BETA_10,
@@ -45,7 +45,7 @@ class FlarumVersion
4545
'c3d9c002b7b0b12c3c967723ac41ec77' => [self::V1_1_0, self::V1_1_1],
4646
];
4747

48-
public $adminJavascriptHashes = [
48+
public array $adminJavascriptHashes = [
4949
'3ac891548d3b255cbe65a97fc4eba017' => self::BETA_8,
5050
'a558ecde363e01b1cdd6a76a684eba48' => self::BETA_9,
5151
'de40f6fa13b1c5158bb617fa70b818dc' => self::BETA_10,

app/GeoIPDatabase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class GeoIPDatabase
1010
{
11-
protected $reader = [];
12-
protected $cache;
11+
protected array $reader = [];
12+
protected Repository $cache;
1313

1414
public function __construct(Repository $cache)
1515
{

app/Jobs/IgnoreCheck.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class IgnoreCheck implements ShouldQueue
1717
{
1818
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
1919

20-
protected $check;
20+
protected OptOutCheck $check;
2121

2222
public function __construct(OptOutCheck $check)
2323
{

app/Jobs/ScanJavascript.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Beta8JavascriptFileParser;
66
use App\FlarumVersion;
77
use Exception;
8+
use GuzzleHttp\Utils;
89
use Illuminate\Support\Arr;
910
use Illuminate\Support\Collection;
1011

@@ -20,7 +21,7 @@ protected function handleTask()
2021
$adminJsHash = null;
2122

2223
try {
23-
$revManifest = \GuzzleHttp\json_decode($this->request("$safeFlarumUrl/assets/rev-manifest.json")->getBody()->getContents(), true);
24+
$revManifest = Utils::jsonDecode($this->request("$safeFlarumUrl/assets/rev-manifest.json")->getBody()->getContents(), true);
2425

2526
$manifestForumJsHash = Arr::get($revManifest, 'forum.js');
2627
$manifestAdminJsHash = Arr::get($revManifest, 'admin.js');

app/Jobs/ScanTaskManager.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@
88

99
class ScanTaskManager
1010
{
11-
/**
12-
* @var Scan $scan
13-
*/
14-
protected $scan;
11+
protected Scan $scan;
1512
/**
1613
* @var Collection|Task[]
1714
*/
1815
protected $tasks;
1916
/**
2017
* @var string[]
2118
*/
22-
public $dispatched = [];
19+
public array $dispatched = [];
2320

2421
public function __construct(Scan $scan)
2522
{

app/Jobs/ShowcaseScreenshot.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ShowcaseScreenshot implements ShouldQueue
1414
{
1515
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
1616

17-
protected $website;
17+
protected Website $website;
1818

1919
public function __construct(Website $website)
2020
{

app/Jobs/ShowcaseUpdate.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\ScannerClient;
66
use App\Website;
77
use GuzzleHttp\Exception\ClientException;
8+
use GuzzleHttp\Utils;
89
use Illuminate\Bus\Queueable;
910
use Illuminate\Queue\SerializesModels;
1011
use Illuminate\Queue\InteractsWithQueue;
@@ -18,7 +19,7 @@ class ShowcaseUpdate implements ShouldQueue
1819

1920
const PAGE_LIMIT = 50;
2021

21-
protected $website;
22+
protected Website $website;
2223

2324
public function __construct(Website $website)
2425
{
@@ -44,7 +45,7 @@ public function handle()
4445
$apiUrl = rtrim($this->website->canonical_url, '/') . '/api';
4546

4647
try {
47-
$forum = \GuzzleHttp\json_decode($client->get($apiUrl, [
48+
$forum = Utils::jsonDecode($client->get($apiUrl, [
4849
'http_errors' => true,
4950
])->getBody()->getContents(), true);
5051
} catch (ClientException $exception) {
@@ -101,7 +102,7 @@ protected function guessTotalItems(string $url): int
101102

102103
// We first try offset 0, because many forums will have few posts
103104
// And also offset 0 is never properly reached with the loop below
104-
$document = \GuzzleHttp\json_decode($client->get($url . '?page[limit]=' . self::PAGE_LIMIT, [
105+
$document = Utils::jsonDecode($client->get($url . '?page[limit]=' . self::PAGE_LIMIT, [
105106
'http_errors' => true,
106107
])->getBody()->getContents(), true);
107108

@@ -115,7 +116,7 @@ protected function guessTotalItems(string $url): int
115116

116117
// Try to find a page that's not completely full in as few queries as possible
117118
for ($i = $page / 2; $i >= 0.5; $i = $i / 2) {
118-
$document = \GuzzleHttp\json_decode($client->get($url . '?page[limit]=' . self::PAGE_LIMIT . '&page[offset]=' . (self::PAGE_LIMIT * $page), [
119+
$document = Utils::jsonDecode($client->get($url . '?page[limit]=' . self::PAGE_LIMIT . '&page[offset]=' . (self::PAGE_LIMIT * $page), [
119120
'http_errors' => true,
120121
])->getBody()->getContents(), true);
121122

app/Jobs/TaskJob.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ abstract class TaskJob implements ShouldQueue
2525
{
2626
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
2727

28-
/**
29-
* @var Task $task
30-
*/
31-
protected $task;
28+
protected Task $task;
3229

33-
protected $data = [];
30+
protected array $data = [];
3431

3532
const LOG_PUBLIC = 'public';
3633
const LOG_PRIVATE = 'private';

app/Jobs/WebsitePing.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class WebsitePing implements ShouldQueue
1616
{
1717
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
1818

19-
protected $website;
19+
protected Website $website;
2020

2121
public function __construct(Website $website)
2222
{

app/Providers/AppServiceProvider.php

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use App\GeoIPDatabase;
66
use App\ScannerClient;
77
use Illuminate\Support\ServiceProvider;
8-
use Laravel\Horizon\Horizon;
98
use Pdp\Rules;
109
use Storage;
1110

app/Report/RatingAgent.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
class RatingAgent
1111
{
12-
protected $canonical;
13-
protected $homepage;
14-
protected $alternate;
15-
protected $exposed;
16-
protected $version;
17-
18-
public $rating = '-';
19-
public $importantRules = [];
12+
protected Task $canonical;
13+
protected Task $homepage;
14+
protected Task $alternate;
15+
protected Task $exposed;
16+
protected Task $version;
17+
18+
public string $rating = '-';
19+
public array $importantRules = [];
2020

2121
public function __construct(Task $canonical, Task $homepage, Task $alternate, Task $exposed, Task $version)
2222
{

app/Resources/ExtensionResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
class ExtensionResource extends JsonResource
1414
{
15-
public function toArray($request)
15+
public function toArray($request): array
1616
{
1717
$relationships = [];
1818

app/Resources/ExtensionVersionResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
class ExtensionVersionResource extends JsonResource
1212
{
13-
public function toArray($request)
13+
public function toArray($request): array
1414
{
1515
return [
1616
'type' => 'extension-versions',

app/Resources/OptOutCheckResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
class OptOutCheckResource extends JsonResource
1212
{
13-
public function toArray($request)
13+
public function toArray($request): array
1414
{
1515
return [
1616
'type' => 'opt-out-checks',

app/Resources/RequestResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
class RequestResource extends JsonResource
1313
{
14-
public function toArray($request)
14+
public function toArray($request): array
1515
{
1616
return [
1717
'type' => 'requests',

0 commit comments

Comments
 (0)