Skip to content
Closed
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
82 changes: 82 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
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

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

steps:
- uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/**'
- '**/lib/**'
- '**/tests/**'
- '**/vendor-bin/**'
- '.php-cs-fixer.dist.php'
- 'composer.json'
- 'composer.lock'
- '**.php'

rector:
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 #v2.37.2
with:
php-version: '8.3'
extensions: apcu,ctype,curl,dom,fileinfo,ftp,gd,imagick,intl,json,ldap,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Composer install
run: composer i

- name: Rector
run: composer run rector

- name: Show changes
if: always()
run: git diff --exit-code -- . ':!lib/composer'

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

if: always()

name: rector-summary

steps:
- name: Summary status
run: if ${{ needs.changes.outputs.src != 'false' && needs.rector.result != 'success' }}; then exit 1; fi
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
build/
\.idea/
build/
node_modules/
vendor/
img/twemoji/
cypress/downloads/
cypress/screenshots/
cypress/snapshots/
cypress/videos/
cypress/downloads/
dist/
/playwright-report/
.php-cs-fixer.cache
/test-results/
/tests/clover.xml
/tests/.phpunit.result.cache
dist/
/vendor/
/vendor-bin/*/vendor
webpack-stats.json

# js folder, to be updated wth --force
Expand Down
15 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,20 @@
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar",
"test:unit": "phpunit -c tests/phpunit.xml"
"rector": "vendor/bin/rector process && composer cs:fix",
"test:unit": "phpunit -c tests/phpunit.xml",
"post-install-cmd": [
"[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all install --ansi"
],
"post-update-cmd": [
"[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all update --ansi"
]
},
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": true
}
},
"autoload-dev": {
"psr-4": {
Expand Down
57 changes: 57 additions & 0 deletions composer.lock

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

7 changes: 3 additions & 4 deletions lib/Command/ResetDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
use Symfony\Component\Console\Output\OutputInterface;

class ResetDocument extends Command {
protected DocumentService $documentService;

public function __construct(DocumentService $documentService) {
public function __construct(
protected DocumentService $documentService,
) {
parent::__construct();
$this->documentService = $documentService;
}

protected function configure(): void {
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/AiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AiController extends ApiController {
public function __construct(
string $appName,
IRequest $request,
private AiTagService $aiTagService,
private readonly AiTagService $aiTagService,
) {
parent::__construct($appName, $request);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class NavigationController extends Controller {

/**
*
* @NoCSRFRequired
* @NoAdminRequired
*
* @return TemplateResponse
*/
#[\OCP\AppFramework\Http\Attribute\NoCSRFRequired]
#[\OCP\AppFramework\Http\Attribute\NoAdminRequired]
public function navigate(): TemplateResponse {
return new TemplateResponse(Application::APP_NAME, 'main');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/PublicSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function isValidToken(): bool {
try {
$this->share = $this->shareManager->getShareByToken($this->getToken());
return true;
} catch (ShareNotFound $e) {
} catch (ShareNotFound) {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class SettingsController extends Controller {
public function __construct(
string $appName,
IRequest $request,
private IUserConfig $userConfig,
private ?string $userId,
private readonly IUserConfig $userConfig,
private readonly ?string $userId,
) {
parent::__construct($appName, $request);
}
Expand Down
18 changes: 9 additions & 9 deletions lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class WorkspaceController extends OCSController {
public function __construct(
string $appName,
IRequest $request,
private IRootFolder $rootFolder,
private IManager $shareManager,
private IDirectEditingManager $directEditingManager,
private IURLGenerator $urlGenerator,
private WorkspaceService $workspaceService,
private IEventDispatcher $eventDispatcher,
private LoggerInterface $logger,
private ISession $session,
private ?string $userId,
private readonly IRootFolder $rootFolder,
private readonly IManager $shareManager,
private readonly IDirectEditingManager $directEditingManager,
private readonly IURLGenerator $urlGenerator,
private readonly WorkspaceService $workspaceService,
private readonly IEventDispatcher $eventDispatcher,
private readonly LoggerInterface $logger,
private readonly ISession $session,
private readonly ?string $userId,
) {
parent::__construct($appName, $request);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/DAV/WorkspacePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class WorkspacePlugin extends ServerPlugin {
private Server $server;

public function __construct(
private WorkspaceService $workspaceService,
private ICacheFactory $cacheFactory,
private ConfigService $configService,
private LoggerInterface $logger,
private ?string $userId,
private readonly WorkspaceService $workspaceService,
private readonly ICacheFactory $cacheFactory,
private readonly ConfigService $configService,
private readonly LoggerInterface $logger,
private readonly ?string $userId,
) {
}

Expand All @@ -55,7 +55,7 @@ public function __construct(
public function initialize(Server $server) {
$this->server = $server;

$this->server->on('propFind', [$this, 'propFind']);
$this->server->on('propFind', $this->propFind(...));
}


Expand Down
6 changes: 3 additions & 3 deletions lib/Db/DocumentMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function find(int $documentId): Document {
->where($qb->expr()->eq('id', $qb->createNamedParameter($documentId)))
->executeQuery();

$data = $result->fetch();
$data = $result->fetchAssociative();
$result->closeCursor();
if ($data === false) {
throw new DoesNotExistException('Document doesn\'t exist');
Expand All @@ -46,7 +46,7 @@ public function findAll(): Generator {
->from($this->getTableName())
->executeQuery();
try {
while ($row = $result->fetch()) {
while ($row = $result->fetchAssociative()) {
yield $this->mapRowToEntity($row);
}
} finally {
Expand All @@ -62,7 +62,7 @@ public function findAllWithNoActiveSessions(): Generator {
->where($qb->expr()->isNull('s.id'))
->executeQuery();
try {
while ($row = $result->fetch()) {
while ($row = $result->fetchAssociative()) {
yield $this->mapRowToEntity($row);
}
} finally {
Expand Down
16 changes: 5 additions & 11 deletions lib/Db/SessionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function find(int $documentId, int $sessionId, string $token): Session {
->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token)))
->executeQuery();

$data = $result->fetch();
$data = $result->fetchAssociative();
$result->closeCursor();
if ($data === false) {
throw new DoesNotExistException('Session is invalid');
Expand Down Expand Up @@ -122,9 +122,7 @@ public function deleteInactiveWithoutSteps(?int $documentId = null): int {
$inactiveSessionBuilder->andWhere($inactiveSessionBuilder->expr()->eq('s.document_id', $inactiveSessionBuilder->createNamedParameter($documentId)));
}
$result = $inactiveSessionBuilder->executeQuery();
$documentIds = array_map(function ($row) {
return (int)$row['id'];
}, $result->fetchAll());
$documentIds = array_map(fn ($row) => (int)$row['id'], $result->fetchAllAssociative());
$result->closeCursor();

$chunks = array_chunk($documentIds, 500);
Expand Down Expand Up @@ -157,9 +155,7 @@ public function deleteOldSessions(int $ageInSeconds): int {
->setMaxResults($batchSize)
->executeQuery();

$sessionIds = array_map(function ($row) {
return (int)$row['id'];
}, $result->fetchAll());
$sessionIds = array_map(fn ($row) => (int)$row['id'], $result->fetchAllAssociative());
$result->closeCursor();

if (empty($sessionIds)) {
Expand Down Expand Up @@ -202,9 +198,7 @@ public function deleteOrphanedSteps(int $ageInSeconds): int {
->setMaxResults($batchSize);

$result = $orphanedStepsQb->executeQuery();
$stepIds = array_map(function ($row) {
return (int)$row['id'];
}, $result->fetchAll());
$stepIds = array_map(fn ($row) => (int)$row['id'], $result->fetchAllAssociative());
$result->closeCursor();

if (empty($stepIds)) {
Expand Down Expand Up @@ -245,7 +239,7 @@ public function isUserInDocument(int $documentId, string $userId): bool {
->setMaxResults(1)
->executeQuery();

$data = $result->fetch();
$data = $result->fetchAssociative();
$result->closeCursor();
if ($data === false) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions lib/Db/StepMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getLatestVersion(int $documentId): ?int {
->orderBy('id', 'DESC')
->executeQuery();

$data = $result->fetch();
$data = $result->fetchAssociative();
if ($data === false) {
return null;
}
Expand All @@ -66,7 +66,7 @@ public function getBeforeVersion(int $documentId, int $version, int $offset): in
->orderBy('id', 'DESC')
->executeQuery();

$rows = $result->fetchAll();
$rows = $result->fetchAllAssociative();
$data = end($rows);
if ($data === false) {
return $version;
Expand Down
Loading