mirror of
https://github.com/flarum/core.git
synced 2025-08-20 15:21:49 +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:
@@ -15,21 +15,11 @@ use Flarum\User\User;
|
||||
|
||||
class UserPolicy extends AbstractPolicy
|
||||
{
|
||||
/**
|
||||
* @var SettingsRepositoryInterface
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
public function __construct(SettingsRepositoryInterface $settings)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
public function __construct(
|
||||
protected SettingsRepositoryInterface $settings
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $actor
|
||||
* @param User $user
|
||||
* @return bool|null
|
||||
*/
|
||||
public function editNickname(User $actor, User $user)
|
||||
{
|
||||
if ($actor->isGuest() && ! $user->exists && $this->settings->get('flarum-nicknames.set_on_registration')) {
|
||||
|
@@ -9,29 +9,20 @@
|
||||
|
||||
namespace Flarum\Nicknames;
|
||||
|
||||
use Flarum\Locale\TranslatorInterface;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\User\UserValidator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class AddNicknameValidation
|
||||
{
|
||||
/**
|
||||
* @var SettingsRepositoryInterface
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
public function __construct(SettingsRepositoryInterface $settings, TranslatorInterface $translator)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->translator = $translator;
|
||||
public function __construct(
|
||||
protected SettingsRepositoryInterface $settings,
|
||||
protected TranslatorInterface $translator
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke($flarumValidator, Validator $validator)
|
||||
public function __invoke(UserValidator $flarumValidator, Validator $validator): void
|
||||
{
|
||||
$idSuffix = $flarumValidator->getUser() ? ','.$flarumValidator->getUser()->id : '';
|
||||
$rules = $validator->getRules();
|
||||
|
@@ -16,6 +16,6 @@ class NicknameDriver implements DriverInterface
|
||||
{
|
||||
public function displayName(User $user): string
|
||||
{
|
||||
return $user->nickname ? $user->nickname : $user->username;
|
||||
return $user->nickname ?? $user->username;
|
||||
}
|
||||
}
|
||||
|
@@ -19,27 +19,16 @@ namespace Flarum\Nicknames;
|
||||
use Flarum\Search\GambitInterface;
|
||||
use Flarum\Search\SearchState;
|
||||
use Flarum\User\UserRepository;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class NicknameFullTextGambit implements GambitInterface
|
||||
{
|
||||
/**
|
||||
* @var UserRepository
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
/**
|
||||
* @param \Flarum\User\UserRepository $users
|
||||
*/
|
||||
public function __construct(UserRepository $users)
|
||||
{
|
||||
$this->users = $users;
|
||||
public function __construct(
|
||||
protected UserRepository $users
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $searchValue
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
private function getUserSearchSubQuery($searchValue)
|
||||
private function getUserSearchSubQuery(string $searchValue): Builder
|
||||
{
|
||||
return $this->users
|
||||
->query()
|
||||
@@ -48,15 +37,12 @@ class NicknameFullTextGambit implements GambitInterface
|
||||
->orWhere('nickname', 'like', "{$searchValue}%");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply(SearchState $search, $searchValue)
|
||||
public function apply(SearchState $search, string $bit): bool
|
||||
{
|
||||
$search->getQuery()
|
||||
->whereIn(
|
||||
'id',
|
||||
$this->getUserSearchSubQuery($searchValue)
|
||||
$this->getUserSearchSubQuery($bit)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
@@ -15,17 +15,12 @@ use Illuminate\Support\Arr;
|
||||
|
||||
class SaveNicknameToDatabase
|
||||
{
|
||||
/**
|
||||
* @var SettingsRepositoryInterface
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
public function __construct(SettingsRepositoryInterface $settings)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
public function __construct(
|
||||
protected SettingsRepositoryInterface $settings
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Saving $event)
|
||||
public function handle(Saving $event): void
|
||||
{
|
||||
$user = $event->user;
|
||||
$data = $event->data;
|
||||
|
Reference in New Issue
Block a user