Add phpstan level 7(#544)

This commit is contained in:
Saeed Vaziry
2025-03-12 13:31:10 +01:00
committed by GitHub
parent c22bb1fa80
commit 493cbb0849
437 changed files with 4505 additions and 2193 deletions

View File

@ -52,16 +52,21 @@ public function create(Request $request, Project $project, Server $server): SshK
$this->validateRoute($project, $server);
/** @var \App\Models\User $user */
$user = auth()->user();
$sshKey = null;
if ($request->has('key_id')) {
$this->validate($request, DeployKeyToServer::rules($request->user(), $server));
$this->validate($request, DeployKeyToServer::rules($user, $server));
$sshKey = $request->user()->sshKeys()->findOrFail($request->key_id);
/** @var ?SshKey $sshKey */
$sshKey = $user->sshKeys()->findOrFail($request->key_id);
}
if (! $sshKey) {
$this->validate($request, CreateSshKey::rules());
$sshKey = app(CreateSshKey::class)->create($request->user(), $request->all());
/** @var SshKey $sshKey */
$sshKey = app(CreateSshKey::class)->create($user, $request->all());
}
app(DeployKeyToServer::class)->deploy($server, ['key_id' => $sshKey->id]);
@ -72,7 +77,7 @@ public function create(Request $request, Project $project, Server $server): SshK
#[Delete('{sshKey}', name: 'api.projects.servers.ssh-keys.delete', middleware: 'ability:write')]
#[Endpoint(title: 'delete', description: 'Delete ssh key from server.')]
#[Response(status: 204)]
public function delete(Project $project, Server $server, SshKey $sshKey)
public function delete(Project $project, Server $server, SshKey $sshKey): \Illuminate\Http\Response
{
$this->authorize('delete', [$sshKey, $server]);