Skip to content

Commit

Permalink
full uppercase const
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Jul 10, 2023
1 parent a84fa17 commit 1075d89
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/files_external/lib/Command/Applicable.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 404;
}

if ($mount->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
if ($mount->getType() === StorageConfig::MOUNT_TYPE_PERSONAL) {
$output->writeln('<error>Can\'t change applicables on personal mounts</error>');
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Config/ConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
}, $storages, $storageConfigs);

$mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAL) {
return new PersonalMount(
$this->userStoragesService,
$storageConfig,
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Controller/StoragesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function show($id, $testOnly = true) {

$data = $this->formatStorageForUI($storage)->jsonSerialize();
$isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
$data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
$data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAL || $isAdmin;

return new DataResponse(
$data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function show($id, $testOnly = true) {

$data = $this->formatStorageForUI($storage)->jsonSerialize();
$isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
$data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
$data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAL || $isAdmin;

return new DataResponse(
$data,
Expand Down
8 changes: 4 additions & 4 deletions apps/files_external/lib/Lib/StorageConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
class StorageConfig implements \JsonSerializable {
public const MOUNT_TYPE_ADMIN = 1;
public const MOUNT_TYPE_PERSONAl = 2;
public const MOUNT_TYPE_PERSONAL = 2;

/**
* Storage config id
Expand Down Expand Up @@ -381,14 +381,14 @@ public function setStatus($status, $message = null) {
}

/**
* @return int self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAl
* @return int self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAL
*/
public function getType() {
return $this->type;
}

/**
* @param int $type self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAl
* @param int $type self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAL
*/
public function setType($type) {
$this->type = $type;
Expand Down Expand Up @@ -425,7 +425,7 @@ public function jsonSerialize(): array {
$result['statusMessage'] = $this->statusMessage;
}
$result['userProvided'] = $this->authMechanism instanceof IUserProvided;
$result['type'] = ($this->getType() === self::MOUNT_TYPE_PERSONAl) ? 'personal': 'system';
$result['type'] = ($this->getType() === self::MOUNT_TYPE_PERSONAL) ? 'personal': 'system';
return $result;
}
}
4 changes: 2 additions & 2 deletions apps/files_external/lib/Service/DBConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
class DBConfigService {
public const MOUNT_TYPE_ADMIN = 1;
public const MOUNT_TYPE_PERSONAl = 2;
public const MOUNT_TYPE_PERSONAL = 2;

public const APPLICABLE_TYPE_GLOBAL = 1;
public const APPLICABLE_TYPE_GROUP = 2;
Expand Down Expand Up @@ -234,7 +234,7 @@ public function getAdminMountsForMultiple($type, array $values) {
public function getUserMountsFor($type, $value) {
$builder = $this->connection->getQueryBuilder();
$query = $this->getForQuery($builder, $type, $value);
$query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_PERSONAl, IQueryBuilder::PARAM_INT)));
$query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_PERSONAL, IQueryBuilder::PARAM_INT)));

return $this->getMountsFromQuery($query);
}
Expand Down
5 changes: 2 additions & 3 deletions apps/files_external/lib/Service/UserStoragesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
use OC\Files\Filesystem;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;

use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IUserMountCache;
use OCP\IUserSession;
Expand Down Expand Up @@ -103,7 +102,7 @@ protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $
}

protected function getType() {
return DBConfigService::MOUNT_TYPE_PERSONAl;
return DBConfigService::MOUNT_TYPE_PERSONAL;
}

/**
Expand Down Expand Up @@ -141,6 +140,6 @@ public function getVisibilityType() {
}

protected function isApplicable(StorageConfig $config) {
return ($config->getApplicableUsers() === [$this->getUser()->getUID()]) && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAl;
return ($config->getApplicableUsers() === [$this->getUser()->getUID()]) && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAL;

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method getUID on possibly null value
}
}
2 changes: 1 addition & 1 deletion apps/files_external/tests/Auth/Password/GlobalAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testNoCredentialsPersonal() {
$this->credentialsManager->expects($this->never())
->method('retrieve');

$storage = $this->getStorageConfig(StorageConfig::MOUNT_TYPE_PERSONAl);
$storage = $this->getStorageConfig(StorageConfig::MOUNT_TYPE_PERSONAL);

$this->instance->manipulateStorageConfig($storage);
$this->assertEquals([], $storage->getBackendOptions());
Expand Down
10 changes: 5 additions & 5 deletions apps/files_external/tests/Service/DBConfigServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function testGetMountsFor() {

public function testGetAdminMounts() {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
$this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAL);

$mounts = $this->dbConfig->getAdminMounts();
$this->assertCount(1, $mounts);
Expand All @@ -208,7 +208,7 @@ public function testGetAdminMounts() {
public function testGetAdminMountsFor() {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$id3 = $this->addMount('/test3', 'foo3', 'bar3', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
$id3 = $this->addMount('/test3', 'foo3', 'bar3', 100, DBConfigService::MOUNT_TYPE_PERSONAL);

$this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_USER, 'test');
$this->dbConfig->addApplicable($id3, DBConfigService::APPLICABLE_TYPE_USER, 'test');
Expand All @@ -221,8 +221,8 @@ public function testGetAdminMountsFor() {

public function testGetUserMountsFor() {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
$id3 = $this->addMount('/test3', 'foo3', 'bar3', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
$this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAL);
$id3 = $this->addMount('/test3', 'foo3', 'bar3', 100, DBConfigService::MOUNT_TYPE_PERSONAL);

$this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_USER, 'test');
$this->dbConfig->addApplicable($id3, DBConfigService::APPLICABLE_TYPE_USER, 'test');
Expand Down Expand Up @@ -285,7 +285,7 @@ public function testGetMountsForDuplicateByGroup() {

public function testGetAllMounts() {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$id2 = $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
$id2 = $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAL);

$mounts = $this->dbConfig->getAllMounts();
$this->assertCount(2, $mounts);
Expand Down

0 comments on commit 1075d89

Please sign in to comment.