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: Use constructor property promotion where possible #3369

Merged
merged 1 commit into from
Nov 7, 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
8 changes: 2 additions & 6 deletions lib/ACL/ACLStorageWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@ public function writeStream(string $path, $stream, ?int $size = null): int {

/**
* @inheritDoc
* @param string $path
* @param ?IStorage $storage
*/
public function getCache($path = '', $storage = null): ICache {
public function getCache(string $path = '', ?IStorage $storage = null): ICache {
if (!$storage) {
$storage = $this;
}
Expand All @@ -202,10 +200,8 @@ public function getMetaData(string $path): ?array {

/**
* @inheritDoc
* @param string $path
* @param ?IStorage $storage
*/
public function getScanner($path = '', $storage = null): IScanner {
public function getScanner(string $path = '', ?IStorage $storage = null): IScanner {
if (!$storage) {
$storage = $this->storage;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/Mount/GroupFolderStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ public function getOwner(string $path): string|false {

/**
* @inheritDoc
* @param string $path
* @param ?IStorage $storage
*/
public function getCache($path = '', $storage = null): ICache {
public function getCache(string $path = '', ?IStorage $storage = null): ICache {
if ($this->cache) {
return $this->cache;
}
Expand Down
6 changes: 1 addition & 5 deletions lib/Mount/RootPermissionsMask.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ public function getMetaData(string $path): ?array {
return $data;
}

/**
* @param string $path
* @param ?IStorage $storage
*/
public function getCache($path = '', $storage = null): ICache {
public function getCache(string $path = '', ?IStorage $storage = null): ICache {
if (!$storage) {
$storage = $this;
}
Expand Down
7 changes: 2 additions & 5 deletions lib/Trash/GroupTrashItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@
use OCP\IUser;

class GroupTrashItem extends TrashItem {
private string $internalOriginalLocation;

public function __construct(
ITrashBackend $backend,
string $originalLocation,
private string $internalOriginalLocation,
int $deletedTime,
string $trashPath,
FileInfo $fileInfo,
IUser $user,
private string $mountPoint,
?IUser $deletedBy,
) {
$this->internalOriginalLocation = $originalLocation;
parent::__construct($backend, $this->mountPoint . '/' . $originalLocation, $deletedTime, $trashPath, $fileInfo, $user, $deletedBy);
parent::__construct($backend, $this->mountPoint . '/' . $this->internalOriginalLocation, $deletedTime, $trashPath, $fileInfo, $user, $deletedBy);
}

public function getInternalOriginalLocation(): string {
Expand Down
6 changes: 5 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;

return RectorConfig::configure()
->withPaths([
Expand All @@ -20,4 +21,7 @@
typeDeclarations: true,
)->withPhpSets(
php81: true,
);
)->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [
'inline_public' => true,
'rename_property' => true,
]);
2 changes: 1 addition & 1 deletion tests/Folder/FolderManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public function testQuotaDefaultValue(): void {
$this->config->expects($this->any())
->method('getSystemValueInt')
->with('groupfolders.quota.default', FileInfo::SPACE_UNLIMITED)
->willReturnCallback(function () use (&$exponent) {
->willReturnCallback(function () use (&$exponent): int {
return 1024 ** ($exponent++);
});

Expand Down
Loading