Skip to content

Commit

Permalink
build: Add rector
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Sep 18, 2024
1 parent 0ea6a8b commit 93a4856
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 7 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"psalm:update-baseline": "psalm --threads=$(nproc) --no-cache --update-baseline",
"psalm:fix": "psalm --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
"test:unit": "phpunit -c tests/phpunit.xml",
"test:unit:coverage": "XDEBUG_MODE=coverage phpunit -c tests/phpunit.xml"
"test:unit:coverage": "XDEBUG_MODE=coverage phpunit -c tests/phpunit.xml",
"rector": "rector && composer cs:fix"
},
"config": {
"allow-plugins": {
Expand Down
2 changes: 1 addition & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function boot(IBootContext $context): void {
$context->injectFn(function (IMountProviderCollection $mountProviderCollection, CacheListener $cacheListener, Group\Manager $groupManager): void {
$mountProviderCollection->registerProvider($this->getMountProvider());

$groupManager->listen('\OC\Group', 'postDelete', function (IGroup $group) {
$groupManager->listen('\OC\Group', 'postDelete', function (IGroup $group): void {
$this->getFolderManager()->deleteGroup($group->getGID());
});
$cacheListener->listen();
Expand Down
6 changes: 3 additions & 3 deletions lib/Command/ExpireGroup/ExpireGroupVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ protected function configure(): void {
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$this->expireManager->listen(GroupVersionsExpireManager::class, 'enterFolder', function (array $folder) use ($output) {
$this->expireManager->listen(GroupVersionsExpireManager::class, 'enterFolder', function (array $folder) use ($output): void {
$output->writeln("<info>Expiring version in '{$folder['mount_point']}'</info>");
});
$this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteVersion', function (IVersion $version) use ($output) {
$this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteVersion', function (IVersion $version) use ($output): void {
$id = $version->getRevisionId();
$file = $version->getSourceFileName();
$output->writeln("<info>Expiring version $id for '$file'</info>");
});

$this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteFile', function ($id) use ($output) {
$this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteFile', function ($id) use ($output): void {
$output->writeln("<info>Cleaning up versions for no longer existing file with id $id</info>");
});

Expand Down
4 changes: 2 additions & 2 deletions lib/Command/Scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
return -1;
}

$scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($output, &$statsRow) {
$scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($output, &$statsRow): void {
$output->writeln("\tFile\t<info>/$path</info>", OutputInterface::VERBOSITY_VERBOSE);
$statsRow[2]++;
// abortIfInterrupted doesn't exist in nc14
Expand All @@ -101,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}
});

$scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($output, &$statsRow) {
$scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($output, &$statsRow): void {
$output->writeln("\tFolder\t<info>/$path</info>", OutputInterface::VERBOSITY_VERBOSE);
$statsRow[1]++;
// abortIfInterrupted doesn't exist in nc14
Expand Down
15 changes: 15 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/lib',
__DIR__ . '/tests',
])
->withSkip([
__DIR__ . '/tests/stubs',
])
->withTypeCoverageLevel(0);
5 changes: 5 additions & 0 deletions vendor-bin/rector/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require-dev": {
"rector/rector": "^1.2"
}
}
136 changes: 136 additions & 0 deletions vendor-bin/rector/composer.lock

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

0 comments on commit 93a4856

Please sign in to comment.