fix(phpstan): less errors

This commit is contained in:
veselcraft 2025-02-28 17:46:37 +03:00
parent 2c46297853
commit 332f803cb6
No known key found for this signature in database
GPG key ID: 9CF0B42766CCF7BA
3 changed files with 14 additions and 7 deletions

View file

@ -109,7 +109,7 @@ class Video extends Media
} elseif (!is_null($this->getRecord()->link)) { } elseif (!is_null($this->getRecord()->link)) {
return Video::TYPE_EMBED; return Video::TYPE_EMBED;
} }
return VIDEO::TYPE_UNKNOWN; return Video::TYPE_UNKNOWN;
} }
public function getVideoDriver(): ?VideoDriver public function getVideoDriver(): ?VideoDriver
@ -240,7 +240,7 @@ class Video extends Media
$this->save(); $this->save();
} }
public static function fastMake(int $owner, string $name = "Unnamed Video.ogv", string $description = "", array $file, bool $unlisted = true, bool $anon = false): Video public static function fastMake(int $owner, string $name, string $description, array $file, bool $unlisted = true, bool $anon = false): Video
{ {
if (OPENVK_ROOT_CONF['openvk']['preferences']['videos']['disableUploading']) { if (OPENVK_ROOT_CONF['openvk']['preferences']['videos']['disableUploading']) {
exit(VIDEOS_FRIENDLY_ERROR); exit(VIDEOS_FRIENDLY_ERROR);

View file

@ -9,6 +9,7 @@ use Chandler\MVC\SimplePresenter;
use Chandler\Session\Session; use Chandler\Session\Session;
use Chandler\Security\Authenticator; use Chandler\Security\Authenticator;
use Latte\Engine as TemplatingEngine; use Latte\Engine as TemplatingEngine;
use Nette\InvalidStateException as ISE;
use openvk\Web\Models\Entities\IP; use openvk\Web\Models\Entities\IP;
use openvk\Web\Themes\Themepacks; use openvk\Web\Themes\Themepacks;
use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets, Reports, CurrentUser, Posts}; use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets, Reports, CurrentUser, Posts};
@ -129,7 +130,7 @@ abstract class OpenVKPresenter extends SimplePresenter
} }
if ($throw) { if ($throw) {
throw new SecurityPolicyViolationException("Permission error"); throw new ISE("Permission error");
} else { } else {
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
} }

View file

@ -265,8 +265,11 @@ final class WallPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
$wallOwner = ($wall > 0 ? (new Users())->get($wall) : (new Clubs())->get($wall * -1)) $wallOwner = ($wall > 0 ? (new Users())->get($wall) : (new Clubs())->get($wall * -1));
?? $this->flashFail("err", tr("failed_to_publish_post"), tr("error_4"));
if ($wallOwner === null) {
$this->flashFail("err", tr("failed_to_publish_post"), tr("error_4"));
}
if ($wallOwner->isBanned()) { if ($wallOwner->isBanned()) {
$this->flashFail("err", tr("error"), tr("forbidden")); $this->flashFail("err", tr("error"), tr("forbidden"));
@ -568,8 +571,11 @@ final class WallPresenter extends OpenVKPresenter
} }
$user = $this->user->id; $user = $this->user->id;
$wallOwner = ($wall > 0 ? (new Users())->get($wall) : (new Clubs())->get($wall * -1)) $wallOwner = ($wall > 0 ? (new Users())->get($wall) : (new Clubs())->get($wall * -1));
?? $this->flashFail("err", tr("failed_to_delete_post"), tr("error_4"));
if ($wallOwner === null) {
$this->flashFail("err", tr("failed_to_delete_post"), tr("error_4"));
}
if ($wallOwner->isBanned()) { if ($wallOwner->isBanned()) {
$this->flashFail("err", tr("error"), tr("forbidden")); $this->flashFail("err", tr("error"), tr("forbidden"));