Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/ACL/ACLManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function getRules(int $storageId, array $paths, bool $cache = true): arr

$nonCachedPaths = array_filter($paths, fn (string $path): bool => !isset($rules[$path]));

if (!empty($nonCachedPaths)) {
if ($nonCachedPaths !== []) {
$newRules = $this->ruleManager->getRulesForFilesByPath($this->user, $storageId, $nonCachedPaths);
foreach ($newRules as $path => $rulesForPath) {
if ($cache) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ACL/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static function xmlDeserialize(Reader $reader): Rule {
throw new \RuntimeException(self::MAPPING_TYPE . ' is not a string.');
}

if (!in_array($mappingType, ['user', 'group', 'circle'])) {
if (!in_array($mappingType, ['user', 'group', 'circle'], true)) {
throw new \RuntimeException(self::MAPPING_TYPE . ' does not have a valid value.');
}

Expand Down
8 changes: 4 additions & 4 deletions lib/ACL/RuleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
* @param array{mapping_type?: 'user'|'group'|'dummy'|'circle'|null, mapping_id: string, fileid: int|string, mask: int|string, permissions: int|string} $data
*/
private function createRule(array $data): ?Rule {
if (empty($data['mapping_type'])) {
if (!isset($data['mapping_type'])) {
return null;
}
$mapping = $this->userMappingManager->mappingFromId($data['mapping_type'], $data['mapping_id']);
Expand Down Expand Up @@ -116,7 +116,7 @@ public function getRulesForFilesByPath(IUser $user, int $storageId, array $fileP
*/
public function getRulesForFilesByIds(IUser $user, array $fileIds): array {
$userMappings = $this->userMappingManager->getMappingsForUser($user);
if (empty($userMappings)) {
if ($userMappings === []) {
return [];
}

Expand Down Expand Up @@ -144,7 +144,7 @@ public function getRulesForFilesByIds(IUser $user, array $fileIds): array {
*/
public function getRulesForFilesByParent(IUser $user, int $storageId, int $parentId): array {
$userMappings = $this->userMappingManager->getMappingsForUser($user);
if (empty($userMappings)) {
if ($userMappings === []) {
return [];
}

Expand Down Expand Up @@ -312,7 +312,7 @@ public function getAllRulesForPrefix(int $storageId, string $prefix): array {
*/
public function getRulesForPrefix(IUser $user, int $storageId, string $prefix): array {
$userMappings = $this->userMappingManager->getMappingsForUser($user);
if (empty($userMappings)) {
if ($userMappings === []) {
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$name = $this->folderManager->trimMountpoint($name);

// Check if the folder name is valid
if (empty($name)) {
if ($name === '') {
$output->writeln('<error>Folder name cannot be empty</error>');
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Rename.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// Check if the new name is valid
$name = $this->folderManager->trimMountpoint($name);
if (empty($name)) {
if ($name === '') {
$output->writeln('<error>Folder name cannot be empty</error>');
return 1;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Folder/FolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ public function canManageACL(int $folderId, IUser $user, bool $excludeAdmins = f
}

private function computeCanManageACL(int $folderId, IUser $user, bool $excludeAdmins): bool {
$userId = $user->getUId();
$userId = $user->getUID();
if (!$excludeAdmins && $this->groupManager->isAdmin($userId)) {
return true;
}
Expand Down Expand Up @@ -1536,12 +1536,12 @@ public function updateOverwriteHomeFolders(): void {
$appIdsList = $this->appConfig->getValueArray('files', 'overwrites_home_folders');

if ($this->hasHomeFolderOverwriteMount()) {
if (!in_array(Application::APP_ID, $appIdsList)) {
if (!in_array(Application::APP_ID, $appIdsList, true)) {
$appIdsList[] = Application::APP_ID;
$this->appConfig->setValueArray('files', 'overwrites_home_folders', $appIdsList);
}
} else {
if (in_array(Application::APP_ID, $appIdsList)) {
if (in_array(Application::APP_ID, $appIdsList, true)) {
$appIdsList = array_values(array_filter($appIdsList, fn ($v): bool => $v !== Application::APP_ID));
$this->appConfig->setValueArray('files', 'overwrites_home_folders', $appIdsList);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mount/GroupMountPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getSourcePath(): string {
$storage = $this->storage;
if ($storage && $storage->instanceOfStorage(Jail::class)) {
/** @var Jail $storage */
return $storage->getUnJailedPath('');
return $storage->getUnjailedPath('');
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion lib/Mount/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader): array {
return array_map(function (FolderDefinitionWithPermissions $folder) use ($user, $loader, $conflicts, $aclManager, $rootRules): IMountPoint {
// check for existing files in the user home and rename them if needed
$originalFolderName = $folder->mountPoint;
if (in_array($originalFolderName, $conflicts)) {
if (in_array($originalFolderName, $conflicts, true)) {
/** @var IStorage $userStorage */
$userStorage = $this->mountProviderCollection->getHomeMountForUser($user)->getStorage();
$userCache = $userStorage->getCache();
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ApplicationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function __construct(
public function checkAppsInstalled(): bool {
$diffApps = array_diff(Application::APPS_USE_GROUPFOLDERS, $this->appManager->getEnabledApps());

return empty($diffApps);
return $diffApps === [];
}
}
4 changes: 2 additions & 2 deletions lib/Service/FoldersFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function getForApiUser(array $folders): array {
return array_filter($folders, function (array $folder) use ($user): bool {
foreach ($folder['manage'] as $manager) {
if ($manager['type'] === 'group') {
if ($this->groupManager->isInGroup($user->getUid(), $manager['id'])) {
if ($this->groupManager->isInGroup($user->getUID(), $manager['id'])) {
return true;
}
} elseif ($manager['id'] === $user->getUid()) {
} elseif ($manager['id'] === $user->getUID()) {
return true;
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Versions/VersionsBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function getVersionsForFile(IUser $user, FileInfo $file): array {
throw new RuntimeException('Failed to get id of file.');
}
$versionEntity->setFileId($fileId);
$versionEntity->setTimestamp($file->getMTime());
$versionEntity->setTimestamp($file->getMtime());
$versionEntity->setSize($file->getSize());
$versionEntity->setMimetype($this->mimeTypeLoader->getId($file->getMimetype()));
$versionEntity->setDecodedMetadata([]);
Expand All @@ -135,7 +135,7 @@ public function getVersionsForFile(IUser $user, FileInfo $file): array {
// This means that the name of some versions is the exact mtime of the next version. This behavior is now fixed.
// To prevent occasional conflicts between the last version and the current one, we decrement the last version mtime.
$mtime = (int)$version->getName();
if ($mtime === $file->getMTime()) {
if ($mtime === $file->getMtime()) {
$versionEntity->setTimestamp($mtime - 1);
$version->move($version->getParent()->getPath() . '/' . ($mtime - 1));
} else {
Expand Down Expand Up @@ -427,7 +427,7 @@ public function createVersionEntity(File $file): null {
$versionEntity->setFileId($fileId);
$versionEntity->setTimestamp($timestamp);
$versionEntity->setSize($file->getSize());
$versionEntity->setMimetype($this->mimeTypeLoader->getId($file->getMimetype()));
$versionEntity->setMimetype($this->mimeTypeLoader->getId($file->getMimeType()));
$versionEntity->setDecodedMetadata([]);
$this->groupVersionsMapper->insert($versionEntity);
}
Expand Down Expand Up @@ -494,7 +494,7 @@ public function importVersionsForFile(IUser $user, Node $source, Node $target, a
$versionEntity->setFileId($target->getId());
$versionEntity->setTimestamp($version->getTimestamp());
$versionEntity->setSize($version->getSize());
$versionEntity->setMimetype($this->mimeTypeLoader->getId($version->getMimetype()));
$versionEntity->setMimetype($this->mimeTypeLoader->getId($version->getMimeType()));
if ($version instanceof IMetadataVersion) {
$versionEntity->setDecodedMetadata($version->getMetadata());
}
Expand Down
9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
includes:
- vendor-bin/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon

parameters:
level: 10
phpVersion:
Expand All @@ -9,6 +12,12 @@ parameters:
- lib
- templates
- tests
strictRules:
allRules: false
strictFunctionCalls: true
disallowedLooseComparison: true
disallowedEmpty: true
disallowedImplicitArrayCreation: true
excludePaths:
- tests/stubs
scanDirectories:
Expand Down
2 changes: 1 addition & 1 deletion tests/ACL/ACLManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function setUp(): void {
/** @var string[] $paths */
$this->requestedPaths = array_values(array_merge($this->requestedPaths, $paths));
$rules = array_fill_keys($paths, []);
$actualRules = array_filter($this->rules, fn (string $path): bool => array_search($path, $paths) !== false, ARRAY_FILTER_USE_KEY);
$actualRules = array_filter($this->rules, fn (string $path): bool => array_search($path, $paths, true) !== false, ARRAY_FILTER_USE_KEY);

return array_merge($rules, $actualRules);
});
Expand Down
3 changes: 2 additions & 1 deletion vendor-bin/phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"require-dev": {
"phpstan/phpstan": "^2.2"
"phpstan/phpstan": "^2.2",
"phpstan/phpstan-strict-rules": "^2.0"
}
}
54 changes: 53 additions & 1 deletion vendor-bin/phpstan/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading