Uses PHP8's constructor property promotion.

Signed-off-by: Faraz Samapoor <fsa@adlas.at>
pull/38975/head
Faraz Samapoor 11 months ago committed by Faraz Samapoor
parent 877ddd2827
commit e98cf3c374

@ -32,13 +32,12 @@ use OCP\IConfig;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class BackgroundCleanupUpdaterBackupsJob extends QueuedJob { class BackgroundCleanupUpdaterBackupsJob extends QueuedJob {
protected IConfig $config; public function __construct(
protected LoggerInterface $log; protected IConfig $config,
protected LoggerInterface $log,
public function __construct(IConfig $config, LoggerInterface $log, ITimeFactory $time) { ITimeFactory $time,
) {
parent::__construct($time); parent::__construct($time);
$this->config = $config;
$this->log = $log;
} }
/** /**

@ -36,15 +36,13 @@ use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
class CheckForUserCertificates extends QueuedJob { class CheckForUserCertificates extends QueuedJob {
protected IConfig $config; public function __construct(
private IUserManager $userManager; protected IConfig $config,
private IRootFolder $rootFolder; private IUserManager $userManager,
private IRootFolder $rootFolder,
public function __construct(IConfig $config, IUserManager $userManager, IRootFolder $rootFolder, ITimeFactory $time) { ITimeFactory $time,
) {
parent::__construct($time); parent::__construct($time);
$this->config = $config;
$this->userManager = $userManager;
$this->rootFolder = $rootFolder;
} }
/** /**

@ -31,11 +31,11 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob; use OCP\BackgroundJob\TimedJob;
class CleanupLoginFlowV2 extends TimedJob { class CleanupLoginFlowV2 extends TimedJob {
private LoginFlowV2Mapper $loginFlowV2Mapper; public function __construct(
ITimeFactory $time,
public function __construct(ITimeFactory $time, LoginFlowV2Mapper $loginFlowV2Mapper) { private LoginFlowV2Mapper $loginFlowV2Mapper,
) {
parent::__construct($time); parent::__construct($time);
$this->loginFlowV2Mapper = $loginFlowV2Mapper;
$this->setInterval(3600); $this->setInterval(3600);
} }

@ -32,13 +32,12 @@ use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
class LookupServerSendCheckBackgroundJob extends QueuedJob { class LookupServerSendCheckBackgroundJob extends QueuedJob {
protected IConfig $config; public function __construct(
private IUserManager $userManager; protected IConfig $config,
private IUserManager $userManager,
public function __construct(IConfig $config, IUserManager $userManager, ITimeFactory $time) { ITimeFactory $time,
) {
parent::__construct($time); parent::__construct($time);
$this->config = $config;
$this->userManager = $userManager;
} }
public function run($arguments) { public function run($arguments) {

@ -26,17 +26,11 @@ declare(strict_types=1);
namespace OC\Core\Data; namespace OC\Core\Data;
class LoginFlowV2Credentials implements \JsonSerializable { class LoginFlowV2Credentials implements \JsonSerializable {
/** @var string */ public function __construct(
private $server; private string $server,
/** @var string */ private string $loginName,
private $loginName; private string $appPassword,
/** @var string */ ) {
private $appPassword;
public function __construct(string $server, string $loginName, string $appPassword) {
$this->server = $server;
$this->loginName = $loginName;
$this->appPassword = $appPassword;
} }
/** /**

@ -26,14 +26,10 @@ declare(strict_types=1);
namespace OC\Core\Data; namespace OC\Core\Data;
class LoginFlowV2Tokens { class LoginFlowV2Tokens {
/** @var string */ public function __construct(
private $loginToken; private string $loginToken,
/** @var string */ private string $pollToken,
private $pollToken; ) {
public function __construct(string $loginToken, string $pollToken) {
$this->loginToken = $loginToken;
$this->pollToken = $pollToken;
} }
public function getPollToken(): string { public function getPollToken(): string {

@ -36,12 +36,15 @@ use OCP\IDBConnection;
class LoginFlowV2Mapper extends QBMapper { class LoginFlowV2Mapper extends QBMapper {
private const lifetime = 1200; private const lifetime = 1200;
/** @var ITimeFactory */ public function __construct(
private $timeFactory; IDBConnection $db,
private ITimeFactory $timeFactory,
public function __construct(IDBConnection $db, ITimeFactory $timeFactory) { ) {
parent::__construct($db, 'login_flow_v2', LoginFlowV2::class); parent::__construct(
$this->timeFactory = $timeFactory; $db,
'login_flow_v2',
LoginFlowV2::class,
);
} }
/** /**

@ -35,16 +35,14 @@ use OCP\IUser;
* @since 25.0.0 * @since 25.0.0
*/ */
class BeforePasswordResetEvent extends Event { class BeforePasswordResetEvent extends Event {
private IUser $user;
private string $password;
/** /**
* @since 25.0.0 * @since 25.0.0
*/ */
public function __construct(IUser $user, string $password) { public function __construct(
private IUser $user,
private string $password,
) {
parent::__construct(); parent::__construct();
$this->user = $user;
$this->password = $password;
} }
/** /**

@ -35,16 +35,14 @@ use OCP\IUser;
* @since 25.0.0 * @since 25.0.0
*/ */
class PasswordResetEvent extends Event { class PasswordResetEvent extends Event {
private IUser $user;
private string $password;
/** /**
* @since 25.0.0 * @since 25.0.0
*/ */
public function __construct(IUser $user, string $password) { public function __construct(
private IUser $user,
private string $password,
) {
parent::__construct(); parent::__construct();
$this->user = $user;
$this->password = $password;
} }
/** /**

@ -46,38 +46,14 @@ use OCP\IURLGenerator;
use OCP\IUser; use OCP\IUser;
class TwoFactorMiddleware extends Middleware { class TwoFactorMiddleware extends Middleware {
/** @var Manager */ public function __construct(
private $twoFactorManager; private Manager $twoFactorManager,
private Session $userSession,
/** @var Session */ private ISession $session,
private $userSession; private IURLGenerator $urlGenerator,
private IControllerMethodReflector $reflector,
/** @var ISession */ private IRequest $request,
private $session; ) {
/** @var IURLGenerator */
private $urlGenerator;
/** @var IControllerMethodReflector */
private $reflector;
/** @var IRequest */
private $request;
/**
* @param Manager $twoFactorManager
* @param Session $userSession
* @param ISession $session
* @param IURLGenerator $urlGenerator
*/
public function __construct(Manager $twoFactorManager, Session $userSession, ISession $session,
IURLGenerator $urlGenerator, IControllerMethodReflector $reflector, IRequest $request) {
$this->twoFactorManager = $twoFactorManager;
$this->userSession = $userSession;
$this->session = $session;
$this->urlGenerator = $urlGenerator;
$this->reflector = $reflector;
$this->request = $request;
} }
/** /**

@ -36,17 +36,11 @@ use OCP\Notification\INotification;
use OCP\Notification\INotifier; use OCP\Notification\INotifier;
class CoreNotifier implements INotifier { class CoreNotifier implements INotifier {
/** @var IConfig */ public function __construct(
private $config; private IConfig $config,
/** @var IFactory */ private IFactory $factory,
private $l10nFactory; private IURLGenerator $url,
/** @var IURLGenerator */ ) {
private $url;
public function __construct(IConfig $config, IFactory $factory, IURLGenerator $url) {
$this->config = $config;
$this->l10nFactory = $factory;
$this->url = $url;
} }
/** /**
@ -66,14 +60,14 @@ class CoreNotifier implements INotifier {
* @since 17.0.0 * @since 17.0.0
*/ */
public function getName(): string { public function getName(): string {
return $this->l10nFactory->get('core')->t('Nextcloud Server'); return $this->factory->get('core')->t('Nextcloud Server');
} }
public function prepare(INotification $notification, string $languageCode): INotification { public function prepare(INotification $notification, string $languageCode): INotification {
if ($notification->getApp() !== 'core') { if ($notification->getApp() !== 'core') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
$l = $this->l10nFactory->get('core', $languageCode); $l = $this->factory->get('core', $languageCode);
if ($notification->getSubject() === 'repair_exposing_links') { if ($notification->getSubject() === 'repair_exposing_links') {
$notification->setParsedSubject($l->t('Some of your link shares have been removed')); $notification->setParsedSubject($l->t('Some of your link shares have been removed'));

@ -43,28 +43,15 @@ use OCP\Security\ISecureRandom;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class LoginFlowV2Service { class LoginFlowV2Service {
private LoginFlowV2Mapper $mapper; public function __construct(
private ISecureRandom $random; private LoginFlowV2Mapper $mapper,
private ITimeFactory $time; private ISecureRandom $random,
private IConfig $config; private ITimeFactory $time,
private ICrypto $crypto; private IConfig $config,
private LoggerInterface $logger; private ICrypto $crypto,
private IProvider $tokenProvider; private LoggerInterface $logger,
private IProvider $tokenProvider,
public function __construct(LoginFlowV2Mapper $mapper, ) {
ISecureRandom $random,
ITimeFactory $time,
IConfig $config,
ICrypto $crypto,
LoggerInterface $logger,
IProvider $tokenProvider) {
$this->mapper = $mapper;
$this->random = $random;
$this->time = $time;
$this->config = $config;
$this->crypto = $crypto;
$this->logger = $logger;
$this->tokenProvider = $tokenProvider;
} }
/** /**

@ -65,12 +65,11 @@ class FeedBackHandler {
private int $progressStateMax = 100; private int $progressStateMax = 100;
private int $progressStateStep = 0; private int $progressStateStep = 0;
private string $currentStep = ''; private string $currentStep = '';
private IEventSource $eventSource;
private IL10N $l10n;
public function __construct(IEventSource $eventSource, IL10N $l10n) { public function __construct(
$this->eventSource = $eventSource; private IEventSource $eventSource,
$this->l10n = $l10n; private IL10N $l10n,
) {
} }
public function handleRepairFeedback(Event $event): void { public function handleRepairFeedback(Event $event): void {

Loading…
Cancel
Save