diff --git a/lib/Command/Clean.php b/lib/Command/Clean.php index 40a286e53..7b5300c88 100644 --- a/lib/Command/Clean.php +++ b/lib/Command/Clean.php @@ -202,7 +202,7 @@ private function deleteDataFromRow(int $columnId): void { } } - private function print(string $message, int $level = null): void { + private function print(string $message, ?int $level = null): void { if($level === self::PRINT_LEVEL_SUCCESS) { echo "✅ ".$message; echo "\n"; diff --git a/lib/Command/CleanLegacy.php b/lib/Command/CleanLegacy.php index be2a7868a..b5f6d2db8 100644 --- a/lib/Command/CleanLegacy.php +++ b/lib/Command/CleanLegacy.php @@ -202,7 +202,7 @@ private function deleteDataFromRow(int $columnId): void { } } - private function print(string $message, int $level = null): void { + private function print(string $message, ?int $level = null): void { if($level === self::PRINT_LEVEL_SUCCESS) { echo "✅ ".$message; echo "\n"; diff --git a/lib/Controller/Api1Controller.php b/lib/Controller/Api1Controller.php index 839d71971..987b25ca4 100644 --- a/lib/Controller/Api1Controller.php +++ b/lib/Controller/Api1Controller.php @@ -181,7 +181,7 @@ public function getTable(int $tableId): DataResponse { * 403: No permissions * 404: Not found */ - public function updateTable(int $tableId, string $title = null, string $emoji = null, ?bool $archived = false): DataResponse { + public function updateTable(int $tableId, ?string $title = null, ?string $emoji = null, ?bool $archived = false): DataResponse { try { return new DataResponse($this->tableService->update($tableId, $title, $emoji, null, $archived, $this->userId)->jsonSerialize()); } catch (PermissionError $e) { diff --git a/lib/Controller/ApiColumnsController.php b/lib/Controller/ApiColumnsController.php index 6e8c080d1..edaeb8422 100644 --- a/lib/Controller/ApiColumnsController.php +++ b/lib/Controller/ApiColumnsController.php @@ -116,7 +116,7 @@ public function show(int $id): DataResponse { * @throws NotFoundError * @throws PermissionError */ - public function createNumberColumn(int $baseNodeId, string $title, ?float $numberDefault, ?int $numberDecimals, ?string $numberPrefix, ?string $numberSuffix, ?float $numberMin, ?float $numberMax, string $subtype = null, string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse { + public function createNumberColumn(int $baseNodeId, string $title, ?float $numberDefault, ?int $numberDecimals, ?string $numberPrefix, ?string $numberSuffix, ?float $numberMin, ?float $numberMax, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse { $tableId = $baseNodeType === 'table' ? $baseNodeId : null; $viewId = $baseNodeType === 'view' ? $baseNodeId : null; $column = $this->service->create( @@ -171,7 +171,7 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe * @throws NotFoundError * @throws PermissionError */ - public function createTextColumn(int $baseNodeId, string $title, ?string $textDefault, ?string $textAllowedPattern, ?int $textMaxLength, string $subtype = null, string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse { + public function createTextColumn(int $baseNodeId, string $title, ?string $textDefault, ?string $textAllowedPattern, ?int $textMaxLength, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse { $tableId = $baseNodeType === 'table' ? $baseNodeId : null; $viewId = $baseNodeType === 'view' ? $baseNodeId : null; $column = $this->service->create( @@ -225,7 +225,7 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe * @throws NotFoundError * @throws PermissionError */ - public function createSelectionColumn(int $baseNodeId, string $title, string $selectionOptions, ?string $selectionDefault, string $subtype = null, string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse { + public function createSelectionColumn(int $baseNodeId, string $title, string $selectionOptions, ?string $selectionDefault, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse { $tableId = $baseNodeType === 'table' ? $baseNodeId : null; $viewId = $baseNodeType === 'view' ? $baseNodeId : null; $column = $this->service->create( @@ -278,7 +278,7 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se * @throws NotFoundError * @throws PermissionError */ - public function createDatetimeColumn(int $baseNodeId, string $title, ?string $datetimeDefault, string $subtype = null, string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse { + public function createDatetimeColumn(int $baseNodeId, string $title, ?string $datetimeDefault, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse { $tableId = $baseNodeType === 'table' ? $baseNodeId : null; $viewId = $baseNodeType === 'view' ? $baseNodeId : null; $column = $this->service->create( diff --git a/lib/Controller/TableController.php b/lib/Controller/TableController.php index 0c2e2fa23..7d3f8a1ec 100644 --- a/lib/Controller/TableController.php +++ b/lib/Controller/TableController.php @@ -70,7 +70,7 @@ public function destroy(int $id): DataResponse { /** * @NoAdminRequired */ - public function update(int $id, string $title = null, string $emoji = null, ?bool $archived = null): DataResponse { + public function update(int $id, ?string $title = null, ?string $emoji = null, ?bool $archived = null): DataResponse { return $this->handleError(function () use ($id, $title, $emoji, $archived) { return $this->service->update($id, $title, $emoji, null, $archived, $this->userId); }); diff --git a/lib/Db/Row2Mapper.php b/lib/Db/Row2Mapper.php index 65a4077fa..06deb17cf 100644 --- a/lib/Db/Row2Mapper.php +++ b/lib/Db/Row2Mapper.php @@ -170,7 +170,7 @@ private function getWantedRowIds(string $userId, int $tableId, ?array $filter = * @return Row2[] * @throws InternalError */ - public function findAll(array $tableColumns, array $columns, int $tableId, int $limit = null, int $offset = null, array $filter = null, array $sort = null, string $userId = null): array { + public function findAll(array $tableColumns, array $columns, int $tableId, ?int $limit = null, ?int $offset = null, ?array $filter = null, ?array $sort = null, ?string $userId = null): array { $this->setColumns($columns, $tableColumns); $columnIdsArray = array_map(fn (Column $column) => $column->getId(), $columns); diff --git a/lib/Db/TableMapper.php b/lib/Db/TableMapper.php index 5b62a167f..9a8dc5a2b 100644 --- a/lib/Db/TableMapper.php +++ b/lib/Db/TableMapper.php @@ -67,7 +67,7 @@ public function findAll(?string $userId = null): array { /** * @throws Exception */ - public function search(string $term = null, ?string $userId = null, ?int $limit = null, ?int $offset = null): array { + public function search(?string $term = null, ?string $userId = null, ?int $limit = null, ?int $offset = null): array { $qb = $this->db->getQueryBuilder(); $shareQueryTablesSharedViaUser = $this->db->getQueryBuilder(); $shareQueryTablesSharedViaGroup = $this->db->getQueryBuilder(); diff --git a/lib/Db/ViewMapper.php b/lib/Db/ViewMapper.php index f6c847b20..c40b9f552 100644 --- a/lib/Db/ViewMapper.php +++ b/lib/Db/ViewMapper.php @@ -52,7 +52,7 @@ public function findAll(?int $tableId = null): array { * @return View[] * @throws Exception */ - public function search(string $term = null, ?string $userId = null, ?int $limit = null, ?int $offset = null): array { + public function search(?string $term = null, ?string $userId = null, ?int $limit = null, ?int $offset = null): array { $qb = $this->db->getQueryBuilder(); $shareTableQuery = $this->db->getQueryBuilder(); $shareQueryViewsSharedViaUser = $this->db->getQueryBuilder(); diff --git a/lib/Listener/TablesReferenceListener.php b/lib/Listener/TablesReferenceListener.php index ea2a4b025..0ea12b174 100644 --- a/lib/Listener/TablesReferenceListener.php +++ b/lib/Listener/TablesReferenceListener.php @@ -3,12 +3,12 @@ namespace OCA\Tables\Listener; use OCA\Tables\AppInfo\Application; +use OCA\Text\Event\LoadEditor; use OCP\Collaboration\Reference\RenderReferenceEvent; use OCP\EventDispatcher\Event; -use OCP\EventDispatcher\IEventListener; use OCP\EventDispatcher\IEventDispatcher; +use OCP\EventDispatcher\IEventListener; use OCP\Util; -use OCA\Text\Event\LoadEditor; /** * @template-implements IEventListener diff --git a/lib/Service/ColumnService.php b/lib/Service/ColumnService.php index 055b2c1ea..504059ca4 100644 --- a/lib/Service/ColumnService.php +++ b/lib/Service/ColumnService.php @@ -111,7 +111,7 @@ public function formatColumns(array $columns): array { * @throws InternalError * @throws PermissionError */ - public function find(int $id, string $userId = null): Column { + public function find(int $id, ?string $userId = null): Column { try { /** @var Column $column */ $column = $this->mapper->find($id); diff --git a/lib/Service/ColumnTypes/NumberStarsBusiness.php b/lib/Service/ColumnTypes/NumberStarsBusiness.php index a550a3688..be17f7ff5 100644 --- a/lib/Service/ColumnTypes/NumberStarsBusiness.php +++ b/lib/Service/ColumnTypes/NumberStarsBusiness.php @@ -21,7 +21,7 @@ public function parseValue($value, ?Column $column = null): string { * @return bool */ public function canBeParsed($value, ?Column $column = null): bool { - return !$value || in_array((int) $value, array(0,1,2,3,4,5)); + return !$value || in_array((int) $value, [0,1,2,3,4,5]); } } diff --git a/lib/Service/ContextService.php b/lib/Service/ContextService.php index 17eb86bef..0ae6ad31f 100644 --- a/lib/Service/ContextService.php +++ b/lib/Service/ContextService.php @@ -349,7 +349,7 @@ public function addNodeToContext(Context $context, int $nodeId, int $nodeType, i return $this->contextNodeRelMapper->insert($contextNodeRel); } - public function addNodeRelToPage(ContextNodeRelation $nodeRel, int $order = null, ?int $pageId = null): PageContent { + public function addNodeRelToPage(ContextNodeRelation $nodeRel, ?int $order = null, ?int $pageId = null): PageContent { if ($pageId === null) { // when no page is given, find the startpage to add it to $context = $this->contextMapper->findById($nodeRel->getContextId()); diff --git a/lib/Service/PermissionsService.php b/lib/Service/PermissionsService.php index c10492ea9..e56ae71c0 100644 --- a/lib/Service/PermissionsService.php +++ b/lib/Service/PermissionsService.php @@ -63,7 +63,7 @@ public function __construct( * * @throws InternalError */ - public function preCheckUserId(string $userId = null, bool $canBeEmpty = true): string { + public function preCheckUserId(?string $userId = null, bool $canBeEmpty = true): string { if ($userId === null) { $userId = $this->userId; } @@ -348,7 +348,7 @@ public function canDeleteRowsByViewId(int $viewId, ?string $userId = null): bool * @param string|null $userId * @return bool */ - public function canDeleteRowsByTableId(int $tableId = null, ?string $userId = null): bool { + public function canDeleteRowsByTableId(?int $tableId = null, ?string $userId = null): bool { if ($tableId === null) { return false; } @@ -640,7 +640,7 @@ private function basisCheckById(int $elementId, string $nodeType, ?string &$user * @param string|null $userId * @return bool */ - private function userIsElementOwner($element, string $userId = null, ?string $nodeType = null): bool { + private function userIsElementOwner($element, ?string $userId = null, ?string $nodeType = null): bool { if ($nodeType === 'context') { return $element->getOwnerId() === $userId; } diff --git a/lib/Service/ShareService.php b/lib/Service/ShareService.php index 9621e2583..56927c13a 100644 --- a/lib/Service/ShareService.php +++ b/lib/Service/ShareService.php @@ -368,9 +368,9 @@ public function delete(int $id): Share { } // security - if (!$this->permissionsService->canManageElementById($item->getNodeId(), $item->getNodeType())) { - throw new PermissionError('PermissionError: can not delete share with id '.$id); - } + if (!$this->permissionsService->canManageElementById($item->getNodeId(), $item->getNodeType())) { + throw new PermissionError('PermissionError: can not delete share with id '.$id); + } try { $this->mapper->delete($item); diff --git a/lib/Service/ViewService.php b/lib/Service/ViewService.php index 1af632311..2c545886c 100644 --- a/lib/Service/ViewService.php +++ b/lib/Service/ViewService.php @@ -252,7 +252,7 @@ public function update(int $id, array $data, ?string $userId = null, bool $skipT throw new PermissionError('PermissionError: can not update view with id '.$id); } - $updatableParameter = array('title', 'emoji', 'description', 'columns', 'sort', 'filter'); + $updatableParameter = ['title', 'emoji', 'description', 'columns', 'sort', 'filter']; foreach ($data as $key => $value) { if (!in_array($key, $updatableParameter)) { diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 425c2d4d3..3b1eb4144 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -119,7 +119,7 @@ public function cleanupUsers() { * @param string|null $emoji * @throws Exception */ - public function createTableV2(string $user, string $title, string $tableName, string $emoji = null): void { + public function createTableV2(string $user, string $title, string $tableName, ?string $emoji = null): void { $this->setCurrentUser($user); $this->sendOcsRequest('post', '/apps/tables/api/2/tables', [ @@ -169,7 +169,7 @@ public function userFetchesTableInfo($user, $tableName) { * @param TableNode|null $body * @throws Exception */ - public function userTablesV2(string $user, TableNode $body = null): void { + public function userTablesV2(string $user, ?TableNode $body = null): void { $this->setCurrentUser($user); $this->sendOcsRequest( 'GET', @@ -206,7 +206,7 @@ public function userTablesV2(string $user, TableNode $body = null): void { * @param TableNode|null $body * @throws Exception */ - public function initialResourcesV2(string $user, TableNode $body = null): void { + public function initialResourcesV2(string $user, ?TableNode $body = null): void { $this->setCurrentUser($user); $this->sendOcsRequest( 'GET', @@ -254,7 +254,7 @@ public function initialResourcesV2(string $user, TableNode $body = null): void { * @param string $tableName * @throws Exception */ - public function updateTableV2(string $user, string $tableName, string $title = null, ?string $emoji = null, ?bool $archived = null): void { + public function updateTableV2(string $user, string $tableName, ?string $title = null, ?string $emoji = null, ?bool $archived = null): void { $this->setCurrentUser($user); $this->sendOcsRequest( @@ -386,7 +386,7 @@ public function deleteTableV2(string $user, string $tableName): void { * @param string $columnName * @param TableNode|null $properties */ - public function createColumnV2(string $nodeType, string $nodeName, string $columnType, string $columnName, TableNode $properties = null): void { + public function createColumnV2(string $nodeType, string $nodeName, string $columnType, string $columnName, ?TableNode $properties = null): void { $props = [ 'baseNodeType' => $nodeType, ]; @@ -432,7 +432,7 @@ public function createColumnV2(string $nodeType, string $nodeName, string $colum * @param string $nodeName * @param TableNode|null $body */ - public function columnsForNodeV2(string $nodeType, string $nodeName, TableNode $body = null): void { + public function columnsForNodeV2(string $nodeType, string $nodeName, ?TableNode $body = null): void { $nodeId = null; if($nodeType === 'table') { $nodeId = $this->tableIds[$nodeName]; @@ -480,7 +480,7 @@ public function columnsForNodeV2(string $nodeType, string $nodeName, TableNode $ * @param string $file * @param TableNode|null $table */ - public function createCsvFile(string $user, string $file, TableNode $table = null): void { + public function createCsvFile(string $user, string $file, ?TableNode $table = null): void { $this->setCurrentUser($user); $url = $this->baseUrl.'remote.php/dav/files/'.$user.$file; $body = $this->tableNodeToCsv($table); @@ -590,7 +590,7 @@ public function checkRowsExists(TableNode $table): void { * @param string $user * @param TableNode|null $body */ - public function userTables(string $user, TableNode $body = null): void { + public function userTables(string $user, ?TableNode $body = null): void { $this->setCurrentUser($user); $this->sendRequest( 'GET', @@ -628,7 +628,7 @@ public function userTables(string $user, TableNode $body = null): void { * @param string $user * @param TableNode|null $body */ - public function tableViews(string $tableName, string $user, TableNode $body = null): void { + public function tableViews(string $tableName, string $user, ?TableNode $body = null): void { $this->setCurrentUser($user); $this->sendRequest( @@ -665,7 +665,7 @@ public function tableViews(string $tableName, string $user, TableNode $body = nu * @param string $viewName * @param string|null $emoji */ - public function createView(string $user, string $title, string $tableName, string $viewName, string $emoji = null): void { + public function createView(string $user, string $title, string $tableName, string $viewName, ?string $emoji = null): void { $this->setCurrentUser($user); $this->sendRequest( 'POST', @@ -703,7 +703,7 @@ public function createView(string $user, string $title, string $tableName, strin * @param string $tableName * @param string|null $emoji */ - public function createTable(string $user, string $title, string $tableName, string $emoji = null): void { + public function createTable(string $user, string $title, string $tableName, ?string $emoji = null): void { $this->setCurrentUser($user); $this->sendRequest( 'POST', @@ -1042,7 +1042,7 @@ private function getShareById(int $shareId): array { /** * @Then user :user has the following permissions */ - public function checkSharePermissions($user, TableNode $permissions = null) { + public function checkSharePermissions($user, ?TableNode $permissions = null) { $this->setCurrentUser($user); $share = $this->getShareById($this->shareId); @@ -1085,7 +1085,7 @@ public function updateSharePermission(string $user, string $permissionType, bool * @param string $title * @param TableNode|null $properties */ - public function createColumn(string $title, TableNode $properties = null): void { + public function createColumn(string $title, ?TableNode $properties = null): void { $props = ['title' => $title]; foreach ($properties->getRows() as $row) { $props[$row[0]] = $row[1]; @@ -1119,7 +1119,7 @@ public function createColumn(string $title, TableNode $properties = null): void * * @param TableNode|null $body */ - public function tableColumns(TableNode $body = null): void { + public function tableColumns(?TableNode $body = null): void { $this->sendRequest( 'GET', '/apps/tables/api/1/tables/'.$this->tableId.'/columns' @@ -1169,7 +1169,7 @@ public function deleteColumn(): void { * * @param TableNode|null $properties */ - public function updateColumn(TableNode $properties = null): void { + public function updateColumn(?TableNode $properties = null): void { $props = []; foreach ($properties->getRows() as $row) { $props[$row[0]] = $row[1]; @@ -1207,7 +1207,7 @@ public function updateColumn(TableNode $properties = null): void { * * @param TableNode|null $properties */ - public function createRow(TableNode $properties = null): void { + public function createRow(?TableNode $properties = null): void { $props = []; foreach ($properties->getRows() as $row) { $columnId = $this->tableColumns[$row[0]]; @@ -1245,7 +1245,7 @@ public function createRow(TableNode $properties = null): void { * * @param TableNode|null $properties */ - public function createRowLegacy(TableNode $properties = null): void { + public function createRowLegacy(?TableNode $properties = null): void { $props = []; foreach ($properties->getRows() as $row) { $columnId = $this->tableColumns[$row[0]]; @@ -1303,7 +1303,7 @@ public function deleteRow(): void { * * @param TableNode|null $properties */ - public function updateRow(TableNode $properties = null): void { + public function updateRow(?TableNode $properties = null): void { $props = []; foreach ($properties->getRows() as $row) { $columnId = $this->tableColumns[$row[0]]; @@ -1340,7 +1340,7 @@ public function updateRow(TableNode $properties = null): void { * * @param TableNode|null $properties */ - public function updateRowLegacy(TableNode $properties = null): void { + public function updateRowLegacy(?TableNode $properties = null): void { $props = []; foreach ($properties->getRows() as $row) { $columnId = $this->tableColumns[$row[0]];