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
88 changes: 88 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: Rector

on:
pull_request:

permissions:
contents: read

concurrency:
group: rector-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest-low
permissions:
contents: read
pull-requests: read

outputs:
src: ${{ steps.changes.outputs.src}}

steps:
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/**'
- 'appinfo/**'
- 'lib/**'
- 'tests/**'
- 'vendor-bin/**'
- 'composer.json'
- 'composer.lock'
- 'rector.php'
- '**.php'

strict:
runs-on: ubuntu-latest

needs: changes
if: ${{ needs.changes.outputs.src != 'false' && github.event_name != 'push' && github.repository_owner != 'nextcloud-gmbh' }}

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: true

- name: Set up php
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: 8.2
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: composer i

- name: Rector
run: composer run rector:check

- name: Show changes
if: always()
run: git diff --exit-code

summary:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: [changes, strict]

if: always()

name: rector-summary

steps:
- name: Summary status
run: if ${{ needs.changes.outputs.src != 'false' && needs.strict.result != 'success' }}; then exit 1; fi
4 changes: 1 addition & 3 deletions lib/Activity/ActivityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ public function __construct(
* @psalm-param string|null $author
*/
public function triggerEvent(string $objectType, Row2|Table|View|Column $object, string $subject, array|string|null $additionalParams = [], array|string|null $author = null) {
if ($author === null) {
$author = $this->userId;
}
$author ??= $this->userId;

try {
$event = $this->createEvent($objectType, $object, $subject, $additionalParams, $author);
Expand Down
8 changes: 2 additions & 6 deletions lib/Db/ContextMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ protected function formatResultRows(array $rows, ?string $userId) {
'display_mode_default' => (int)$item['display_mode_default'],
];
if ($userId !== null) {
if ($item['display_mode'] === null) {
$item['display_mode'] = $item['display_mode_default'];
}
$item['display_mode'] ??= $item['display_mode_default'];
$carry[$item['share_id']]['display_mode'] = (int)$item['display_mode'];
}
return $carry;
Expand All @@ -130,9 +128,7 @@ protected function formatResultRows(array $rows, ?string $userId) {
// empty Context
return $carry;
}
if (!isset($carry[$item['page_id']])) {
$carry[$item['page_id']] = ['content' => []];
}
$carry[$item['page_id']] ??= ['content' => []];
$carry[$item['page_id']]['id'] = (int)$item['page_id'];
$carry[$item['page_id']]['page_type'] = $item['page_type'];
if ($item['node_rel_id'] !== null) {
Expand Down
4 changes: 1 addition & 3 deletions lib/Db/Row2Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,7 @@ private function parseEntities(IResult $result, array $sleeves): array {

$column = $this->columnMapper->find($rowData['column_id']);
$columnType = $column->getType();
if (!isset($cellMapperCache[$columnType])) {
$cellMapperCache[$columnType] = $this->getCellMapperFromType($columnType);
}
$cellMapperCache[$columnType] ??= $this->getCellMapperFromType($columnType);
$value = $cellMapperCache[$columnType]->formatRowData($column, $rowData);
$compositeKey = (string)$rowData['row_id'] . ',' . (string)$rowData['column_id'];
if ($cellMapperCache[$columnType]->hasMultipleValues()) {
Expand Down
4 changes: 1 addition & 3 deletions lib/Migration/Version2020Date20260513185340.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ private function applyColumnOptionsUpdateIfNecessary(IQueryBuilder $query, int $
}

foreach ($selectionOptions as &$selectionOption) {
if (!isset($selectionOption['uuid'])) {
$selectionOption['uuid'] = Uuid::v7()->toRfc4122();
}
$selectionOption['uuid'] ??= Uuid::v7()->toRfc4122();
}

$updatedSelectionOptions = json_encode($selectionOptions);
Expand Down
4 changes: 1 addition & 3 deletions lib/Migration/Version2202Date20260825184226.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ private function applyColumnOptionsUpdateIfNecessary(IQueryBuilder $query, int $
}

foreach ($selectionOptions as &$selectionOption) {
if (!isset($selectionOption['uuid'])) {
$selectionOption['uuid'] = Uuid::v7()->toRfc4122();
}
$selectionOption['uuid'] ??= Uuid::v7()->toRfc4122();

}
unset($selectionOption);
Expand Down
9 changes: 2 additions & 7 deletions lib/Service/ColumnService.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,7 @@ public function delete(int $id, bool $skipRowCleanup = false, ?string $userId =
public function findOrCreateColumnsByTitleForTableAsArray(?int $tableId, ?int $viewId, array $titles, array $dataTypes, ?string $userId, bool $createUnknownColumns, int &$countCreatedColumns, int &$countMatchingColumns): array {
$result = [];

if ($userId === null) {
$userId = $this->userId;
}
$userId ??= $this->userId;
if ($viewId) {
$allColumns = $this->findAllByView($viewId, $userId);
} elseif ($tableId) {
Expand All @@ -638,10 +636,7 @@ public function findOrCreateColumnsByTitleForTableAsArray(?int $tableId, ?int $v
}
$result[$i] = '';
}
// if there are no columns at all
if (!isset($result[$i])) {
$result[$i] = '';
}
$result[$i] ??= '';
// if column was not found
if ($result[$i] === '' && $createUnknownColumns && $dataTypes[$i]['type'] !== Column::TYPE_META_ID) {
$description = $this->l->t('This column was automatically created by the import service.');
Expand Down
4 changes: 1 addition & 3 deletions lib/Service/PermissionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public function __construct(
* @throws InternalError
*/
public function preCheckUserId(?string $userId = null, bool $canBeEmpty = true): string {
if ($userId === null) {
$userId = $this->userId;
}
$userId ??= $this->userId;

if ($userId === null) {
$e = new \Exception();
Expand Down
4 changes: 1 addition & 3 deletions lib/Service/RelationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ private function groupColumnsByTarget(array $columns): array {
}

$target = sprintf('%s_%s_%s', $settings['relationType'], $settings['targetId'], $settings['labelColumn']);
if (!isset($groups[$target])) {
$groups[$target] = [];
}
$groups[$target] ??= [];
$groups[$target][] = $column;
}

Expand Down
4 changes: 1 addition & 3 deletions lib/Service/RowService.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,7 @@ public function updateSet(
throw new InternalError(static::class . ' - ' . __FUNCTION__ . ': ' . $e->getMessage());
}
} else {
if ($tableId === null) {
$tableId = $item->getTableId();
}
$tableId ??= $item->getTableId();
if ($tableId !== $item->getTableId()) {
$e = new \Exception('Row does not belong to table with id ' . $tableId);
$this->logger->error($e->getMessage(), ['exception' => $e]);
Expand Down
4 changes: 1 addition & 3 deletions lib/Service/TableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ public function findAll(?string $userId = null, bool $skipTableEnhancement = fal

// clean duplicates
foreach ($sharedTables as $sharedTable) {
if (!isset($allTables[$sharedTable->getId()])) {
$allTables[$sharedTable->getId()] = $sharedTable;
}
$allTables[$sharedTable->getId()] ??= $sharedTable;
}
}

Expand Down
4 changes: 1 addition & 3 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2143,9 +2143,7 @@ public function sendRequestFullUrl($verb, $fullUrl, $body = null, array $headers
}

protected function getUserCookieJar($user) {
if (!isset($this->cookieJars[$user])) {
$this->cookieJars[$user] = new CookieJar();
}
$this->cookieJars[$user] ??= new CookieJar();
return $this->cookieJars[$user];
}

Expand Down
Loading