1
0
mirror of https://github.com/flarum/core.git synced 2025-08-31 11:52:16 +02:00

chore: update codebase to php8.1 (#3827)

* chore: set minimum php version to 8.1

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: update codebase to php8.1

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* chore: update workflow php version

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: caught errors

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: more caught errors

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: phpstan caught errors

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* fix: test-caught errors

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: test-caught errors

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: test-caught errors

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: introduce `Flarum\Locale\TranslatorInterface`

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* chore: remove mixin

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: test-caught errors

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: one last error

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Sami Mazouz
2023-05-30 11:36:12 +01:00
committed by GitHub
parent 34a04b0746
commit 6f11e044a7
703 changed files with 4329 additions and 12772 deletions

View File

@@ -14,7 +14,7 @@ use Flarum\Query\QueryCriteria;
class HideIgnoredFromAllDiscussionsPage
{
public function __invoke(FilterState $filterState, QueryCriteria $criteria)
public function __invoke(FilterState $filterState, QueryCriteria $criteria): void
{
// We only want to hide on the "all discussions" page.
if (count($filterState->getActiveFilters()) === 0) {

View File

@@ -11,7 +11,6 @@ namespace Flarum\Subscriptions\Job;
use Flarum\Notification\NotificationSyncer;
use Flarum\Post\Post;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Subscriptions\Notification\NewPostBlueprint;
use Flarum\User\User;
use Illuminate\Bus\Queueable;
@@ -25,27 +24,13 @@ class SendReplyNotification implements ShouldQueue
use Queueable;
use SerializesModels;
/**
* @var Post
*/
protected $post;
/**
* @var int
*/
protected $lastPostNumber;
/**
* @param Post $post
* @param int|null $lastPostNumber
*/
public function __construct(Post $post, $lastPostNumber)
{
$this->post = $post;
$this->lastPostNumber = $lastPostNumber;
public function __construct(
protected Post $post,
protected ?int $lastPostNumber
) {
}
public function handle(NotificationSyncer $notifications, SettingsRepositoryInterface $settings)
public function handle(NotificationSyncer $notifications): void
{
$post = $this->post;
$discussion = $post->discussion;

View File

@@ -16,23 +16,12 @@ use Flarum\Subscriptions\Notification\NewPostBlueprint;
class DeleteNotificationWhenPostIsHiddenOrDeleted
{
/**
* @var NotificationSyncer
*/
protected $notifications;
/**
* @param NotificationSyncer $notifications
*/
public function __construct(NotificationSyncer $notifications)
{
$this->notifications = $notifications;
public function __construct(
protected NotificationSyncer $notifications
) {
}
/**
* @param Hidden|Deleted $event
*/
public function handle($event)
public function handle(Deleted|Hidden $event): void
{
$this->notifications->delete(new NewPostBlueprint($event->post));
}

View File

@@ -13,7 +13,7 @@ use Flarum\Post\Event\Posted;
class FollowAfterReply
{
public function handle(Posted $event)
public function handle(Posted $event): void
{
$actor = $event->actor;

View File

@@ -15,20 +15,12 @@ use Flarum\Subscriptions\Notification\NewPostBlueprint;
class RestoreNotificationWhenPostIsRestored
{
/**
* @var NotificationSyncer
*/
protected $notifications;
/**
* @param NotificationSyncer $notifications
*/
public function __construct(NotificationSyncer $notifications)
{
$this->notifications = $notifications;
public function __construct(
protected NotificationSyncer $notifications
) {
}
public function handle(Restored $event)
public function handle(Restored $event): void
{
$this->notifications->restore(new NewPostBlueprint($event->post));
}

View File

@@ -13,7 +13,7 @@ use Flarum\Discussion\Event\Saving;
class SaveSubscriptionToDatabase
{
public function handle(Saving $event)
public function handle(Saving $event): void
{
$discussion = $event->discussion;
$data = $event->data;

View File

@@ -16,21 +16,12 @@ use Illuminate\Contracts\Queue\Queue;
class SendNotificationWhenReplyIsPosted
{
/**
* @var Queue
*/
protected $queue;
public function __construct(Queue $queue)
{
$this->queue = $queue;
public function __construct(
protected Queue $queue
) {
}
/**
* @param Posted|PostWasApproved $event
* @return void
*/
public function handle($event)
public function handle(Posted|PostWasApproved $event): void
{
$this->queue->push(
new SendReplyNotification($event->post, $event->post->discussion->last_post_number)

View File

@@ -9,79 +9,52 @@
namespace Flarum\Subscriptions\Notification;
use Flarum\Database\AbstractModel;
use Flarum\Discussion\Discussion;
use Flarum\Locale\TranslatorInterface;
use Flarum\Notification\Blueprint\BlueprintInterface;
use Flarum\Notification\MailableInterface;
use Flarum\Post\Post;
use Symfony\Contracts\Translation\TranslatorInterface;
use Flarum\User\User;
class NewPostBlueprint implements BlueprintInterface, MailableInterface
{
/**
* @var Post
*/
public $post;
/**
* @param Post $post
*/
public function __construct(Post $post)
{
$this->post = $post;
public function __construct(
public Post $post
) {
}
/**
* {@inheritdoc}
*/
public function getSubject()
public function getSubject(): ?AbstractModel
{
return $this->post->discussion;
}
/**
* {@inheritdoc}
*/
public function getFromUser()
public function getFromUser(): ?User
{
return $this->post->user;
}
/**
* {@inheritdoc}
*/
public function getData()
public function getData(): array
{
return ['postNumber' => (int) $this->post->number];
}
/**
* {@inheritdoc}
*/
public function getEmailView()
public function getEmailView(): string|array
{
return ['text' => 'flarum-subscriptions::emails.newPost'];
}
/**
* {@inheritdoc}
*/
public function getEmailSubject(TranslatorInterface $translator)
public function getEmailSubject(TranslatorInterface $translator): string
{
return $translator->trans('flarum-subscriptions.email.new_post.subject', ['{title}' => $this->post->discussion->title]);
}
/**
* {@inheritdoc}
*/
public static function getType()
public static function getType(): string
{
return 'newPost';
}
/**
* {@inheritdoc}
*/
public static function getSubjectModel()
public static function getSubjectModel(): string
{
return Discussion::class;
}

View File

@@ -21,12 +21,12 @@ class SubscriptionFilterGambit extends AbstractRegexGambit implements FilterInte
{
use ValidateFilterTrait;
protected function getGambitPattern()
protected function getGambitPattern(): string
{
return 'is:(follow|ignor)(?:ing|ed)';
}
protected function conditions(SearchState $search, array $matches, $negate)
protected function conditions(SearchState $search, array $matches, bool $negate): void
{
$this->constrain($search->getQuery(), $search->getActor(), $matches[1], $negate);
}
@@ -36,7 +36,7 @@ class SubscriptionFilterGambit extends AbstractRegexGambit implements FilterInte
return 'subscription';
}
public function filter(FilterState $filterState, $filterValue, bool $negate)
public function filter(FilterState $filterState, string|array $filterValue, bool $negate): void
{
$filterValue = $this->asString($filterValue);
@@ -45,7 +45,7 @@ class SubscriptionFilterGambit extends AbstractRegexGambit implements FilterInte
$this->constrain($filterState->getQuery(), $filterState->getActor(), $matches[1], $negate);
}
protected function constrain(Builder $query, User $actor, string $subscriptionType, bool $negate)
protected function constrain(Builder $query, User $actor, string $subscriptionType, bool $negate): void
{
$method = $negate ? 'whereNotIn' : 'whereIn';
$query->$method('discussions.id', function ($query) use ($actor, $subscriptionType) {