Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor lib/private/App #39299

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ class AppManager implements IAppManager {
'prevent_group_restriction',
];

private IUserSession $userSession;
private IConfig $config;
private AppConfig $appConfig;
private IGroupManager $groupManager;
private ICacheFactory $memCacheFactory;
private IEventDispatcher $dispatcher;
private LoggerInterface $logger;

/** @var string[] $appId => $enabled */
private array $installedAppsCache = [];

Expand All @@ -104,20 +96,15 @@ class AppManager implements IAppManager {
/** @var array<string, true> */
private array $loadedApps = [];

public function __construct(IUserSession $userSession,
IConfig $config,
AppConfig $appConfig,
IGroupManager $groupManager,
ICacheFactory $memCacheFactory,
IEventDispatcher $dispatcher,
LoggerInterface $logger) {
$this->userSession = $userSession;
$this->config = $config;
$this->appConfig = $appConfig;
$this->groupManager = $groupManager;
$this->memCacheFactory = $memCacheFactory;
$this->dispatcher = $dispatcher;
$this->logger = $logger;
public function __construct(
private IUserSession $userSession,
private IConfig $config,
private AppConfig $appConfig,
private IGroupManager $groupManager,
private ICacheFactory $memCacheFactory,
private IEventDispatcher $dispatcher,
private LoggerInterface $logger,
) {
}

/**
Expand Down
8 changes: 3 additions & 5 deletions lib/private/App/AppStore/Bundles/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
use OCP\IL10N;

abstract class Bundle {
/** @var IL10N */
protected $l10n;

/**
* @param IL10N $l10n
*/
public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
public function __construct(
protected IL10N $l10n,
) {
}

/**
Expand Down
7 changes: 3 additions & 4 deletions lib/private/App/AppStore/Bundles/BundleFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
use OCP\IL10N;

class BundleFetcher {
private IL10N $l10n;

public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
public function __construct(
private IL10N $l10n,
) {
}

/**
Expand Down
14 changes: 3 additions & 11 deletions lib/private/App/AppStore/Fetcher/AppFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,17 @@
use Psr\Log\LoggerInterface;

class AppFetcher extends Fetcher {
/** @var CompareVersion */
private $compareVersion;

/** @var IRegistry */
protected $registry;

/** @var bool */
private $ignoreMaxVersion;

public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config,
CompareVersion $compareVersion,
private CompareVersion $compareVersion,
LoggerInterface $logger,
IRegistry $registry) {
protected IRegistry $registry,
) {
parent::__construct(
$appDataFactory,
$clientService,
Expand All @@ -64,9 +59,6 @@ public function __construct(Factory $appDataFactory,
$registry
);

$this->compareVersion = $compareVersion;
$this->registry = $registry;

$this->fileName = 'apps.json';
$this->endpointName = 'apps.json';
$this->ignoreMaxVersion = true;
Expand Down
6 changes: 4 additions & 2 deletions lib/private/App/AppStore/Fetcher/CategoryFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
use Psr\Log\LoggerInterface;

class CategoryFetcher extends Fetcher {
public function __construct(Factory $appDataFactory,
public function __construct(
Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config,
LoggerInterface $logger,
IRegistry $registry) {
IRegistry $registry,
) {
parent::__construct(
$appDataFactory,
$clientService,
Expand Down
29 changes: 8 additions & 21 deletions lib/private/App/AppStore/Fetcher/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ abstract class Fetcher {

/** @var IAppData */
protected $appData;
/** @var IClientService */
protected $clientService;
/** @var ITimeFactory */
protected $timeFactory;
/** @var IConfig */
protected $config;
/** @var LoggerInterface */
protected $logger;
/** @var IRegistry */
protected $registry;

/** @var string */
protected $fileName;
Expand All @@ -67,18 +57,15 @@ abstract class Fetcher {
/** @var ?string */
protected $channel = null;

public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config,
LoggerInterface $logger,
IRegistry $registry) {
public function __construct(
Factory $appDataFactory,
protected IClientService $clientService,
protected ITimeFactory $timeFactory,
protected IConfig $config,
protected LoggerInterface $logger,
protected IRegistry $registry,
) {
$this->appData = $appDataFactory->get('appstore');
$this->clientService = $clientService;
$this->timeFactory = $timeFactory;
$this->config = $config;
$this->logger = $logger;
$this->registry = $registry;
}

/**
Expand Down
12 changes: 4 additions & 8 deletions lib/private/App/AppStore/Version/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@
namespace OC\App\AppStore\Version;

class Version {
/** @var string */
private $minVersion;
/** @var string */
private $maxVersion;

/**
* @param string $minVersion
* @param string $maxVersion
*/
public function __construct($minVersion, $maxVersion) {
$this->minVersion = $minVersion;
$this->maxVersion = $maxVersion;
public function __construct(
private string $minVersion,
private string $maxVersion,
) {
}

/**
Expand Down
11 changes: 4 additions & 7 deletions lib/private/App/DependencyAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,17 @@
use OCP\IL10N;

class DependencyAnalyzer {
/** @var Platform */
private $platform;
/** @var \OCP\IL10N */
private $l;
/** @var array */
private $appInfo;

/**
* @param Platform $platform
* @param \OCP\IL10N $l
*/
public function __construct(Platform $platform, IL10N $l) {
$this->platform = $platform;
$this->l = $l;
public function __construct(
private Platform $platform,
private IL10N $l,
) {
}

/**
Expand Down
8 changes: 3 additions & 5 deletions lib/private/App/InfoParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@
use function simplexml_load_string;

class InfoParser {
/** @var \OCP\ICache|null */
private $cache;

/**
* @param ICache|null $cache
*/
public function __construct(ICache $cache = null) {
$this->cache = $cache;
public function __construct(
private ?ICache $cache = null,
) {
}

/**
Expand Down
7 changes: 3 additions & 4 deletions lib/private/App/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
* @package OC\App
*/
class Platform {
private IConfig $config;

public function __construct(IConfig $config) {
$this->config = $config;
public function __construct(
private IConfig $config,
) {
}

public function getPhpVersion(): string {
Expand Down
Loading