Skip to content

Commit

Permalink
fix(php): Formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody committed Jun 13, 2024
1 parent f518b72 commit c813449
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion lib/Command/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/CleanLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/Api1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/ApiColumnsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/TableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/Row2Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion lib/Db/TableMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/ViewMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions lib/Listener/TablesReferenceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<Event|RenderReferenceEvent>
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ColumnService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ColumnTypes/NumberStarsBusiness.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

}
2 changes: 1 addition & 1 deletion lib/Service/ContextService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/PermissionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/ShareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ViewService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
38 changes: 19 additions & 19 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
[
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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]];
Expand Down Expand Up @@ -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]];
Expand Down Expand Up @@ -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]];
Expand Down Expand Up @@ -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]];
Expand Down

0 comments on commit c813449

Please sign in to comment.