From e7c38ee4ded9b08ea60dcdfd7d4e104f34f0de95 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Wed, 18 Sep 2024 12:39:10 +0200 Subject: [PATCH] build: Add rector Signed-off-by: provokateurin --- composer.json | 3 +- lib/AppInfo/Application.php | 2 +- .../ExpireGroup/ExpireGroupVersions.php | 6 +- lib/Command/Scan.php | 4 +- rector.php | 18 +++ vendor-bin/rector/composer.json | 5 + vendor-bin/rector/composer.lock | 136 ++++++++++++++++++ 7 files changed, 167 insertions(+), 7 deletions(-) create mode 100644 rector.php create mode 100644 vendor-bin/rector/composer.json create mode 100644 vendor-bin/rector/composer.lock diff --git a/composer.json b/composer.json index d96f30645..e790aa28f 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 89e6d64bc..a2e5bb6f5 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -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(); diff --git a/lib/Command/ExpireGroup/ExpireGroupVersions.php b/lib/Command/ExpireGroup/ExpireGroupVersions.php index e8404c7ca..44b74539a 100644 --- a/lib/Command/ExpireGroup/ExpireGroupVersions.php +++ b/lib/Command/ExpireGroup/ExpireGroupVersions.php @@ -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("Expiring version in '{$folder['mount_point']}'"); }); - $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("Expiring version $id for '$file'"); }); - $this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteFile', function ($id) use ($output) { + $this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteFile', function ($id) use ($output): void { $output->writeln("Cleaning up versions for no longer existing file with id $id"); }); diff --git a/lib/Command/Scan.php b/lib/Command/Scan.php index 9c17321bf..9e37058aa 100644 --- a/lib/Command/Scan.php +++ b/lib/Command/Scan.php @@ -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/$path", OutputInterface::VERBOSITY_VERBOSE); $statsRow[2]++; // abortIfInterrupted doesn't exist in nc14 @@ -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/$path", OutputInterface::VERBOSITY_VERBOSE); $statsRow[1]++; // abortIfInterrupted doesn't exist in nc14 diff --git a/rector.php b/rector.php new file mode 100644 index 000000000..47c5b5d7d --- /dev/null +++ b/rector.php @@ -0,0 +1,18 @@ +withPaths([ + __DIR__ . '/lib', + __DIR__ . '/tests', + ]) + ->withSkip([ + __DIR__ . '/tests/stubs', + ]) + ->withTypeCoverageLevel(0); diff --git a/vendor-bin/rector/composer.json b/vendor-bin/rector/composer.json new file mode 100644 index 000000000..a266a586d --- /dev/null +++ b/vendor-bin/rector/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "rector/rector": "^1.2" + } +} diff --git a/vendor-bin/rector/composer.lock b/vendor-bin/rector/composer.lock new file mode 100644 index 000000000..849e09482 --- /dev/null +++ b/vendor-bin/rector/composer.lock @@ -0,0 +1,136 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "eb58f3061bde78d58fa424c73947025f", + "packages": [], + "packages-dev": [ + { + "name": "phpstan/phpstan", + "version": "1.12.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "0fcbf194ab63d8159bb70d9aa3e1350051632009" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0fcbf194ab63d8159bb70d9aa3e1350051632009", + "reference": "0fcbf194ab63d8159bb70d9aa3e1350051632009", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-09-09T08:10:35+00:00" + }, + { + "name": "rector/rector", + "version": "1.2.5", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "e98aa793ca3fcd17e893cfaf9103ac049775d339" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/e98aa793ca3fcd17e893cfaf9103ac049775d339", + "reference": "e98aa793ca3fcd17e893cfaf9103ac049775d339", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.12.2" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/1.2.5" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2024-09-08T17:43:24+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +}