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

Refactors /Metadata, /Migration, and /Net namespaces in /lib/private/ #39109

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/private/Metadata/Capabilities.php
Expand Up @@ -26,15 +26,13 @@
use OCP\IConfig;

class Capabilities implements IPublicCapability {
private IMetadataManager $manager;
private IConfig $config;

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

public function getCapabilities() {
public function getCapabilities(): array {
if ($this->config->getSystemValueBool('enable_file_metadata', true)) {
return ['metadataAvailable' => $this->manager->getCapabilities()];
}
Expand Down
10 changes: 4 additions & 6 deletions lib/private/Metadata/FileEventListener.php
Expand Up @@ -39,12 +39,10 @@
* @template-implements IEventListener<NodeWrittenEvent>
*/
class FileEventListener implements IEventListener {
private IMetadataManager $manager;
private LoggerInterface $logger;

public function __construct(IMetadataManager $manager, LoggerInterface $logger) {
$this->manager = $manager;
$this->logger = $logger;
public function __construct(
private IMetadataManager $manager,
private LoggerInterface $logger,
) {
}

private function shouldExtractMetadata(Node $node): bool {
Expand Down
11 changes: 3 additions & 8 deletions lib/private/Metadata/MetadataManager.php
Expand Up @@ -24,17 +24,12 @@

class MetadataManager implements IMetadataManager {
/** @var array<string, IMetadataProvider> */
private array $providers;
private array $providerClasses;
private FileMetadataMapper $fileMetadataMapper;
private array $providers = [];
private array $providerClasses = [];

public function __construct(
FileMetadataMapper $fileMetadataMapper
private FileMetadataMapper $fileMetadataMapper,
) {
$this->providers = [];
$this->providerClasses = [];
$this->fileMetadataMapper = $fileMetadataMapper;

// TODO move to another place, where?
$this->registerProvider(ExifProvider::class);
}
Expand Down
5 changes: 1 addition & 4 deletions lib/private/Metadata/Provider/ExifProvider.php
Expand Up @@ -28,12 +28,9 @@
use Psr\Log\LoggerInterface;

class ExifProvider implements IMetadataProvider {
private LoggerInterface $logger;

public function __construct(
LoggerInterface $logger
private LoggerInterface $logger,
) {
$this->logger = $logger;
}

public static function groupsProvided(): array {
Expand Down
18 changes: 8 additions & 10 deletions lib/private/Migration/BackgroundRepair.php
Expand Up @@ -41,15 +41,13 @@
* @package OC\Migration
*/
class BackgroundRepair extends TimedJob {
private IJobList $jobList;
private LoggerInterface $logger;
private IEventDispatcher $dispatcher;

public function __construct(IEventDispatcher $dispatcher, ITimeFactory $time, LoggerInterface $logger, IJobList $jobList) {
public function __construct(
private IEventDispatcher $dispatcher,
ITimeFactory $time,
private LoggerInterface $logger,
private IJobList $jobList,
) {
parent::__construct($time);
$this->dispatcher = $dispatcher;
$this->logger = $logger;
$this->jobList = $jobList;
$this->setInterval(15 * 60);
}

Expand All @@ -58,7 +56,7 @@ public function __construct(IEventDispatcher $dispatcher, ITimeFactory $time, Lo
* @throws \Exception
* @throws \OC\NeedsUpdateException
*/
protected function run($argument) {
protected function run($argument): void {
fsamapoor marked this conversation as resolved.
Show resolved Hide resolved
if (!isset($argument['app']) || !isset($argument['step'])) {
// remove the job - we can never execute it
$this->jobList->remove($this, $this->argument);
Expand Down Expand Up @@ -101,7 +99,7 @@ protected function run($argument) {
* @param $app
* @throws NeedsUpdateException
*/
protected function loadApp($app) {
protected function loadApp($app): void {
OC_App::loadApp($app);
}
}
21 changes: 9 additions & 12 deletions lib/private/Migration/ConsoleOutput.php
Expand Up @@ -34,34 +34,31 @@
* @package OC\Migration
*/
class ConsoleOutput implements IOutput {
/** @var OutputInterface */
private $output;
private ?ProgressBar $progressBar = null;

/** @var ProgressBar */
private $progressBar;

public function __construct(OutputInterface $output) {
$this->output = $output;
public function __construct(
private OutputInterface $output,
) {
}

/**
* @param string $message
*/
public function info($message) {
public function info($message): void {
fsamapoor marked this conversation as resolved.
Show resolved Hide resolved
$this->output->writeln("<info>$message</info>");
}

/**
* @param string $message
*/
public function warning($message) {
public function warning($message): void {
$this->output->writeln("<comment>$message</comment>");
}

/**
* @param int $max
*/
public function startProgress($max = 0) {
public function startProgress($max = 0): void {
fsamapoor marked this conversation as resolved.
Show resolved Hide resolved
if (!is_null($this->progressBar)) {
$this->progressBar->finish();
}
Expand All @@ -73,7 +70,7 @@ public function startProgress($max = 0) {
* @param int $step
* @param string $description
*/
public function advance($step = 1, $description = '') {
public function advance($step = 1, $description = ''): void {
fsamapoor marked this conversation as resolved.
Show resolved Hide resolved
if (is_null($this->progressBar)) {
$this->progressBar = new ProgressBar($this->output);
$this->progressBar->start();
Expand All @@ -84,7 +81,7 @@ public function advance($step = 1, $description = '') {
}
}

public function finishProgress() {
public function finishProgress(): void {
if (is_null($this->progressBar)) {
return;
}
Expand Down
20 changes: 9 additions & 11 deletions lib/private/Migration/SimpleOutput.php
Expand Up @@ -33,48 +33,46 @@
* @package OC\Migration
*/
class SimpleOutput implements IOutput {
private LoggerInterface $logger;
private $appName;

public function __construct(LoggerInterface $logger, $appName) {
$this->logger = $logger;
$this->appName = $appName;
public function __construct(
private LoggerInterface $logger,
private $appName,
) {
}

/**
* @param string $message
* @since 9.1.0
*/
public function info($message) {
public function info($message): void {
$this->logger->info($message, ['app' => $this->appName]);
}

/**
* @param string $message
* @since 9.1.0
*/
public function warning($message) {
public function warning($message): void {
$this->logger->warning($message, ['app' => $this->appName]);
}

/**
* @param int $max
* @since 9.1.0
*/
public function startProgress($max = 0) {
public function startProgress($max = 0): void {
fsamapoor marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @param int $step
* @param string $description
* @since 9.1.0
*/
public function advance($step = 1, $description = '') {
public function advance($step = 1, $description = ''): void {
fsamapoor marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @since 9.1.0
*/
public function finishProgress() {
public function finishProgress(): void {
}
}
4 changes: 0 additions & 4 deletions lib/private/Net/HostnameClassifier.php
Expand Up @@ -52,10 +52,6 @@ class HostnameClassifier {
* Check host identifier for local hostname
*
* IP addresses are not considered local. Use the IpAddressClassifier for those.
*
* @param string $hostname
*
* @return bool
*/
public function isLocalHostname(string $hostname): bool {
// Disallow local network top-level domains from RFC 6762
Expand Down
4 changes: 0 additions & 4 deletions lib/private/Net/IpAddressClassifier.php
Expand Up @@ -46,10 +46,6 @@ class IpAddressClassifier {
* Check host identifier for local IPv4 and IPv6 address ranges
*
* Hostnames are not considered local. Use the HostnameClassifier for those.
*
* @param string $ip
*
* @return bool
*/
public function isLocalAddress(string $ip): bool {
$parsedIp = Factory::parseAddressString(
Expand Down