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

Update phpstan to latest #804

Merged
merged 44 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a9852e5
Fix these
lancepioch Dec 9, 2024
d9386fd
Update phpstan
lancepioch Dec 9, 2024
3811156
Transform these into their identifiers instead
lancepioch Dec 9, 2024
1515116
Fix custom rule
lancepioch Dec 9, 2024
23148da
License is wrong
lancepioch Dec 9, 2024
6adf8e1
Update these
lancepioch Dec 9, 2024
a1a9b12
Pint fixes
lancepioch Dec 9, 2024
9d672bd
Fix this
lancepioch Dec 9, 2024
c1e4eed
Consolidate these
lancepioch Dec 9, 2024
6f82c30
Never supported PHP 7
lancepioch Jan 3, 2025
3ba9d1b
Better evaluation
lancepioch Jan 3, 2025
9725d6f
Fixes
lancepioch Jan 3, 2025
8663cb8
Don’t need ignore
lancepioch Jan 3, 2025
ce99d26
Replace trait with service
lancepioch Jan 3, 2025
ce3e1e3
Subusers are simply the many to many relationship between Servers and…
lancepioch Jan 3, 2025
73802e8
Adjust to remove ignores
lancepioch Jan 3, 2025
19cee9e
Use new query builder instead!
lancepioch Jan 3, 2025
2d8f9c5
wip
lancepioch Jan 3, 2025
6d64de2
Merge branch 'main' into lance/rules
lancepioch Jan 3, 2025
7047d29
Update composer
lancepioch Jan 3, 2025
a42887f
Quick fixes
lancepioch Jan 3, 2025
3bd977b
Use realtime facade
lancepioch Jan 3, 2025
266308b
Small fixes
lancepioch Jan 3, 2025
cef29fe
Convert to static to avoid new
lancepioch Jan 3, 2025
62429c1
Update to statics
lancepioch Jan 3, 2025
0a49924
Don’t modify protected properties directly
lancepioch Jan 3, 2025
14eb64f
Run pint
lancepioch Jan 3, 2025
dd9d0d6
Change to correct method
lancepioch Jan 4, 2025
86d3f2d
Give up and use the facade
lancepioch Jan 5, 2025
6f7a9d8
Merge branch 'main' into lance/rules
lancepioch Jan 7, 2025
49caf11
Make sure this route is available
lancepioch Jan 7, 2025
c5100ae
Filament hasn’t been loaded yet
lancepioch Jan 7, 2025
51866a4
This can be readonly
lancepioch Jan 7, 2025
41fbcaf
Typehint
lancepioch Jan 7, 2025
2895cf8
These are no longer used
lancepioch Jan 7, 2025
b68f76f
Quick fixes
lancepioch Jan 7, 2025
f2dd04b
Need doc block help
lancepioch Jan 7, 2025
4594d10
Merge branch 'main' into lance/rules
lancepioch Jan 7, 2025
0292c7d
Always true
lancepioch Jan 7, 2025
c30c8c9
We use caddy with docker
lancepioch Jan 7, 2025
419e0e2
Pint
RMartinOscar Jan 7, 2025
e34e0d5
Merge branch 'main' into lance/rules
lancepioch Jan 15, 2025
38fc1c1
Fix phpstan issues
lancepioch Jan 15, 2025
6a35cb9
Remove unused import
lancepioch Jan 15, 2025
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
75 changes: 0 additions & 75 deletions .github/docker/default.conf

This file was deleted.

70 changes: 0 additions & 70 deletions .github/docker/default_ssl.conf

This file was deleted.

16 changes: 0 additions & 16 deletions .github/docker/www.conf

This file was deleted.

14 changes: 6 additions & 8 deletions app/Console/Commands/Schedule/ProcessRunnableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
use App\Models\Schedule;
use Illuminate\Database\Eloquent\Builder;
use App\Services\Schedules\ProcessScheduleService;
use Throwable;

class ProcessRunnableCommand extends Command
{
protected $signature = 'p:schedule:process';

protected $description = 'Process schedules in the database and determine which are ready to run.';

/**
* Handle command execution.
*/
public function handle(): int
public function handle(ProcessScheduleService $processScheduleService): int
{
$schedules = Schedule::query()
->with('tasks')
Expand All @@ -35,7 +33,7 @@ public function handle(): int
$bar = $this->output->createProgressBar(count($schedules));
foreach ($schedules as $schedule) {
$bar->clear();
$this->processSchedule($schedule);
$this->processSchedule($processScheduleService, $schedule);
$bar->advance();
$bar->display();
}
Expand All @@ -50,20 +48,20 @@ public function handle(): int
* never throw an exception out, otherwise you'll end up killing the entire run group causing
* any other schedules to not process correctly.
*/
protected function processSchedule(Schedule $schedule): void
protected function processSchedule(ProcessScheduleService $processScheduleService, Schedule $schedule): void
{
if ($schedule->tasks->isEmpty()) {
return;
}

try {
$this->getLaravel()->make(ProcessScheduleService::class)->handle($schedule);
$processScheduleService->handle($schedule);

$this->line(trans('command/messages.schedule.output_line', [
'schedule' => $schedule->name,
'id' => $schedule->id,
]));
} catch (\Throwable|\Exception $exception) {
} catch (Throwable $exception) {
logger()->error($exception, ['schedule_id' => $schedule->id]);

$this->error(__('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage());
Expand Down
28 changes: 10 additions & 18 deletions app/Console/Commands/Server/BulkPowerActionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,13 @@ class BulkPowerActionCommand extends Command

protected $description = 'Perform bulk power management on large groupings of servers or nodes at once.';

/**
* BulkPowerActionCommand constructor.
*/
public function __construct(private DaemonPowerRepository $powerRepository, private ValidatorFactory $validator)
{
parent::__construct();
}

/**
* Handle the bulk power request.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function handle(): void
public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory $validator): void
{
$action = $this->argument('action');
$nodes = empty($this->option('nodes')) ? [] : explode(',', $this->option('nodes'));
$servers = empty($this->option('servers')) ? [] : explode(',', $this->option('servers'));

$validator = $this->validator->make([
$validator = $validator->make([
'action' => $action,
'nodes' => $nodes,
'servers' => $servers,
Expand All @@ -64,11 +51,14 @@ public function handle(): void
}

$bar = $this->output->createProgressBar($count);
$powerRepository = $this->powerRepository;
// @phpstan-ignore-next-line
$this->getQueryBuilder($servers, $nodes)->each(function (Server $server) use ($action, $powerRepository, &$bar) {

$this->getQueryBuilder($servers, $nodes)->get()->each(function ($server, int $index) use ($action, $powerRepository, &$bar): mixed {
$bar->clear();

if (!$server instanceof Server) {
return null;
}

try {
$powerRepository->setServer($server)->send($action);
} catch (Exception $exception) {
Expand All @@ -82,6 +72,8 @@ public function handle(): void

$bar->advance();
$bar->display();

return null;
});

$this->line('');
Expand Down
4 changes: 0 additions & 4 deletions app/Console/Commands/UpgradeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ public function handle(): void
$this->line($this->getUrl());
}

if (version_compare(PHP_VERSION, '7.4.0') < 0) {
$this->error(__('commands.upgrade.php_version') . ' [' . PHP_VERSION . '].');
}

$user = 'www-data';
$group = 'www-data';
if ($this->input->isInteractive()) {
Expand Down
24 changes: 24 additions & 0 deletions app/Eloquent/BackupQueryBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Eloquent;

use Illuminate\Database\Eloquent\Builder;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*
* @extends Builder<TModel>
*/
class BackupQueryBuilder extends Builder
{
public function nonFailed(): self
{
$this->where(function (Builder $query) {
$query
->whereNull('completed_at')
->orWhere('is_successful', true);
});

return $this;
}
}
2 changes: 1 addition & 1 deletion app/Enums/EditorLanguages.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ enum EditorLanguages: string implements HasLabel
case yaml = 'yaml';
case json = 'json';

public function getLabel(): ?string
public function getLabel(): string
lancepioch marked this conversation as resolved.
Show resolved Hide resolved
{
return $this->name;
}
Expand Down
26 changes: 14 additions & 12 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Symfony\Component\Mailer\Exception\TransportException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Throwable;

class Handler extends ExceptionHandler
{
Expand Down Expand Up @@ -179,10 +180,7 @@ public function invalidJson($request, ValidationException $exception): JsonRespo
return response()->json(['errors' => $errors], $exception->status);
}

/**
* Return the exception as a JSONAPI representation for use on API requests.
*/
protected function convertExceptionToArray(\Throwable $e, array $override = []): array
public static function exceptionToArray(Throwable $e, array $override = []): array
{
$match = self::$exceptionResponseCodes[get_class($e)] ?? null;

Expand Down Expand Up @@ -214,7 +212,7 @@ protected function convertExceptionToArray(\Throwable $e, array $override = []):
'trace' => Collection::make($e->getTrace())
->map(fn ($trace) => Arr::except($trace, ['args']))
->all(),
'previous' => Collection::make($this->extractPrevious($e))
'previous' => Collection::make(self::extractPrevious($e))
->map(fn ($exception) => $exception->getTrace())
->map(fn ($trace) => Arr::except($trace, ['args']))
->all(),
Expand All @@ -225,6 +223,14 @@ protected function convertExceptionToArray(\Throwable $e, array $override = []):
return ['errors' => [array_merge($error, $override)]];
}

/**
* Return the exception as a JSONAPI representation for use on API requests.
*/
protected function convertExceptionToArray(Throwable $e, array $override = []): array
{
return self::exceptionToArray($e, $override);
}

/**
* Return an array of exceptions that should not be reported.
*/
Expand All @@ -251,15 +257,12 @@ protected function unauthenticated($request, AuthenticationException $exception)
* Extracts all the previous exceptions that lead to the one passed into this
* function being thrown.
*
* @return \Throwable[]
* @return Throwable[]
*/
protected function extractPrevious(\Throwable $e): array
public static function extractPrevious(Throwable $e): array
{
$previous = [];
while ($value = $e->getPrevious()) {
if (!$value instanceof \Throwable) {
break;
}
$previous[] = $value;
$e = $value;
}
Expand All @@ -273,7 +276,6 @@ protected function extractPrevious(\Throwable $e): array
*/
public static function toArray(\Throwable $e): array
{
// @phpstan-ignore-next-line
return (new self(app()))->convertExceptionToArray($e);
return self::exceptionToArray($e);
}
}
Loading
Loading