kopia lustrzana https://github.com/pixelfed/pixelfed
Fix PHPStan 'empty() always exists and is not falsy' errors
- Remove redundant empty() checks where variables are guaranteed to exist and be non-falsy - Replace empty() with simple null/false checks where appropriate - Maintain original logic while fixing static analysis issues - Affected files: - app/Http/Controllers/GroupController.php - app/Http/Controllers/ProfileAliasController.php - app/Jobs/ImageOptimizePipeline/ImageUpdate.php - app/Jobs/InboxPipeline/DeleteWorker.php - app/Jobs/InboxPipeline/InboxValidator.php - app/Jobs/InboxPipeline/InboxWorker.php - app/Jobs/ProfilePipeline/HandleUpdateActivity.php - app/Rules/ExpoPushTokenRule.php - app/Services/AutospamService.php - app/Services/CollectionService.php - app/Services/NotificationAppGatewayService.php - app/Services/WebfingerService.php - app/Util/ActivityPub/Helpers.phppull/6290/head
rodzic
cc90df9d8c
commit
72e840345e
|
|
@ -636,7 +636,7 @@ class GroupController extends GroupFederationController
|
|||
{
|
||||
abort_unless(config('groups.enabled'), 404);
|
||||
$group = GroupService::get($id);
|
||||
abort_if(! $group || empty($group), 404);
|
||||
abort_if(! $group, 404);
|
||||
|
||||
return view('groups.invite-claim', compact('group'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class ProfileAliasController extends Controller
|
|||
$webfingerService = WebfingerService::lookup($acct);
|
||||
$webfingerUrl = WebfingerService::rawGet($acct);
|
||||
|
||||
if (! $webfingerService || ! isset($webfingerService['url']) || ! $webfingerUrl || empty($webfingerUrl)) {
|
||||
if (! $webfingerService || ! isset($webfingerService['url']) || ! $webfingerUrl) {
|
||||
return back()->with('error', 'Invalid account, cannot add alias at this time.');
|
||||
}
|
||||
$alias = new ProfileAlias;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class ImageUpdate implements ShouldQueue
|
|||
$disk = Storage::disk(config('filesystems.default'));
|
||||
$localFs = config('filesystems.default') === 'local';
|
||||
|
||||
if (! $path || empty($path)) {
|
||||
if (! $path) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class DeleteWorker implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
if(empty($headers) || empty($payload)) {
|
||||
if(!$headers || !$payload) {
|
||||
Log::info("DeleteWorker: Empty headers or payload, skipping job");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class InboxValidator implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
if(empty($headers) || empty($payload) || !isset($headers['signature']) || !isset($headers['date'])) {
|
||||
if(!$headers || !$payload || !isset($headers['signature']) || !isset($headers['date'])) {
|
||||
Log::info("InboxValidator: Invalid headers or payload structure, skipping job");
|
||||
return;
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ class InboxValidator implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
if(empty($profile) || empty($headers) || empty($payload)) {
|
||||
if(!$profile || !$headers || !$payload) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ class InboxValidator implements ShouldQueue
|
|||
}
|
||||
|
||||
$res = json_decode($res->body(), true, 8);
|
||||
if(!$res || empty($res) || !isset($res['publicKey']) || !isset($res['publicKey']['id'])) {
|
||||
if(!$res || !isset($res['publicKey']) || !isset($res['publicKey']['id'])) {
|
||||
return;
|
||||
}
|
||||
if($res['publicKey']['id'] !== $actor->key_id) {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class InboxWorker implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
if(empty($headers) || empty($payload) || !isset($headers['signature']) || !isset($headers['date'])) {
|
||||
if(!$headers || !$payload || !isset($headers['signature']) || !isset($headers['date'])) {
|
||||
Log::info("InboxWorker: Invalid headers or payload structure, skipping job");
|
||||
return;
|
||||
}
|
||||
|
|
@ -201,7 +201,7 @@ class InboxWorker implements ShouldQueue
|
|||
}
|
||||
|
||||
$res = json_decode($res->body(), true, 8);
|
||||
if(!$res || empty($res) || !isset($res['publicKey']) || !isset($res['publicKey']['id'])) {
|
||||
if(!$res || !isset($res['publicKey']) || !isset($res['publicKey']['id'])) {
|
||||
return;
|
||||
}
|
||||
if($res['publicKey']['id'] !== $actor->key_id) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class HandleUpdateActivity implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
if (empty($payload) || ! isset($payload['actor'])) {
|
||||
if (! $payload || ! isset($payload['actor'])) {
|
||||
Log::info("HandleUpdateActivity: Invalid payload or missing actor, skipping job");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class ExpoPushTokenRule implements ValidationRule
|
|||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (! $value || empty($value)) {
|
||||
if (! $value) {
|
||||
$fail('The :attribute must not be empty.');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class AutospamService
|
|||
|
||||
return Cache::remember(self::MODEL_CACHE_KEY, 86400, function () {
|
||||
$res = Storage::get(self::MODEL_FILE_PATH);
|
||||
if (! $res || empty($res)) {
|
||||
if (! $res) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class CollectionService
|
|||
public static function getThumb($id)
|
||||
{
|
||||
$item = self::getItems($id, 0, 1);
|
||||
if(!$item || empty($item)) {
|
||||
if(!$item) {
|
||||
return url('/storage/no-preview.png');
|
||||
}
|
||||
$status = StatusService::get($item[0]);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class NotificationAppGatewayService
|
|||
}
|
||||
|
||||
$apiKey = config('instance.notifications.nag.api_key');
|
||||
if (! $apiKey || empty($apiKey) || strlen($apiKey) !== 45) {
|
||||
if (! $apiKey || strlen($apiKey) !== 45) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ class NotificationAppGatewayService
|
|||
|
||||
public static function isValidExpoPushToken($token)
|
||||
{
|
||||
if (! $token || empty($token)) {
|
||||
if (! $token) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -89,19 +89,19 @@ class NotificationAppGatewayService
|
|||
return false;
|
||||
}
|
||||
|
||||
if (! $userToken || empty($userToken) || ! self::isValidExpoPushToken($userToken)) {
|
||||
if (! $userToken || ! self::isValidExpoPushToken($userToken)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$types = PushNotificationService::NOTIFY_TYPES;
|
||||
|
||||
if (! $type || empty($type) || ! in_array($type, $types)) {
|
||||
if (! $type || ! in_array($type, $types)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$apiKey = config('instance.notifications.nag.api_key');
|
||||
|
||||
if (! $apiKey || empty($apiKey)) {
|
||||
if (! $apiKey) {
|
||||
return false;
|
||||
}
|
||||
$url = 'https://'.config('instance.notifications.nag.endpoint').'/api/v1/relay/deliver';
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class WebfingerService
|
|||
if (! $n) {
|
||||
return false;
|
||||
}
|
||||
if (empty($n) || ! str_starts_with($n, 'https://')) {
|
||||
if (! str_starts_with($n, 'https://')) {
|
||||
return false;
|
||||
}
|
||||
$host = parse_url($n, PHP_URL_HOST);
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ class Helpers
|
|||
$uri = Uri::new($url);
|
||||
$host = $uri->getHost();
|
||||
|
||||
if (! $host || empty($host)) {
|
||||
if (! $host) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -338,7 +338,7 @@ class Helpers
|
|||
|
||||
return Cache::remember($key, $ttl, function () use ($url) {
|
||||
$res = ActivityPubFetchService::get($url);
|
||||
if (! $res || empty($res)) {
|
||||
if (! $res) {
|
||||
return false;
|
||||
}
|
||||
$res = json_decode($res, true, 8);
|
||||
|
|
@ -477,7 +477,6 @@ class Helpers
|
|||
public static function isValidStatusData(?array $res): bool
|
||||
{
|
||||
return $res &&
|
||||
! empty($res) &&
|
||||
! isset($res['error']) &&
|
||||
isset($res['@context']) &&
|
||||
isset($res['published']);
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue