diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-04-16 11:14:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-16 11:14:53 +0300 |
commit | 3d1015c87a482a3ad0b19c7c4327eeb173407d24 (patch) | |
tree | 7a14fcd407715649901a00dd5cf877decb63682a /apps | |
parent | 7d8ff2792808042c6107a56d746c9340fee2c9a9 (diff) | |
parent | 899413b506cce8482827a278e5095982cd7d6300 (diff) |
Merge pull request #26560 from J0WI/backupcodes-strict
2FA backupcodes: add strict typing
Diffstat (limited to 'apps')
28 files changed, 63 insertions, 51 deletions
diff --git a/apps/twofactor_backupcodes/appinfo/routes.php b/apps/twofactor_backupcodes/appinfo/routes.php index 8adc9c3901e..926c1d55d52 100644 --- a/apps/twofactor_backupcodes/appinfo/routes.php +++ b/apps/twofactor_backupcodes/appinfo/routes.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * * @license GNU AGPL version 3 or any later version diff --git a/apps/twofactor_backupcodes/lib/Activity/Provider.php b/apps/twofactor_backupcodes/lib/Activity/Provider.php index 12c71f68d1c..37122c33e1b 100644 --- a/apps/twofactor_backupcodes/lib/Activity/Provider.php +++ b/apps/twofactor_backupcodes/lib/Activity/Provider.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at> * @@ -53,7 +56,7 @@ class Provider implements IProvider { $this->l10n = $l10n; } - public function parse($language, IEvent $event, IEvent $previousEvent = null) { + public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent { if ($event->getApp() !== 'twofactor_backupcodes') { throw new InvalidArgumentException(); } diff --git a/apps/twofactor_backupcodes/lib/Controller/SettingsController.php b/apps/twofactor_backupcodes/lib/Controller/SettingsController.php index 04ec2e19e95..c6a07f6ca5b 100644 --- a/apps/twofactor_backupcodes/lib/Controller/SettingsController.php +++ b/apps/twofactor_backupcodes/lib/Controller/SettingsController.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @@ -56,7 +57,7 @@ class SettingsController extends Controller { * * @return JSONResponse */ - public function createCodes() { + public function createCodes(): JSONResponse { $user = $this->userSession->getUser(); $codes = $this->storage->createCodes($user); return new JSONResponse([ diff --git a/apps/twofactor_backupcodes/lib/Db/BackupCode.php b/apps/twofactor_backupcodes/lib/Db/BackupCode.php index 8b173890e3c..b56ea4fad1c 100644 --- a/apps/twofactor_backupcodes/lib/Db/BackupCode.php +++ b/apps/twofactor_backupcodes/lib/Db/BackupCode.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * * @license GNU AGPL version 3 or any later version diff --git a/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php b/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php index 84972a5171a..4ef6c97bcd3 100644 --- a/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php +++ b/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -42,7 +43,7 @@ class BackupCodeMapper extends QBMapper { * @param IUser $user * @return BackupCode[] */ - public function getBackupCodes(IUser $user) { + public function getBackupCodes(IUser $user): array { /* @var IQueryBuilder $qb */ $qb = $this->db->getQueryBuilder(); @@ -56,14 +57,14 @@ class BackupCodeMapper extends QBMapper { /** * @param IUser $user */ - public function deleteCodes(IUser $user) { + public function deleteCodes(IUser $user): void { $this->deleteCodesByUserId($user->getUID()); } /** * @param string $uid */ - public function deleteCodesByUserId($uid) { + public function deleteCodesByUserId(string $uid): void { /* @var IQueryBuilder $qb */ $qb = $this->db->getQueryBuilder(); diff --git a/apps/twofactor_backupcodes/lib/Event/CodesGenerated.php b/apps/twofactor_backupcodes/lib/Event/CodesGenerated.php index d1e5e29d4b5..c5d05433766 100644 --- a/apps/twofactor_backupcodes/lib/Event/CodesGenerated.php +++ b/apps/twofactor_backupcodes/lib/Event/CodesGenerated.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * * @license GNU AGPL version 3 or any later version diff --git a/apps/twofactor_backupcodes/lib/Listener/ActivityPublisher.php b/apps/twofactor_backupcodes/lib/Listener/ActivityPublisher.php index d7240677b6c..0785b7de42d 100644 --- a/apps/twofactor_backupcodes/lib/Listener/ActivityPublisher.php +++ b/apps/twofactor_backupcodes/lib/Listener/ActivityPublisher.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * * @license GNU AGPL version 3 or any later version diff --git a/apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php b/apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php index 011950a0979..899ed654b6a 100644 --- a/apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php +++ b/apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * * @license GNU AGPL version 3 or any later version diff --git a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607104347.php b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607104347.php index 68f0d5b3421..ffbb8023007 100644 --- a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607104347.php +++ b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607104347.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> * diff --git a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php index 771c74853d1..cfd76fefd00 100644 --- a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php +++ b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> * diff --git a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170919123342.php b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170919123342.php index dc42ad2545c..97863583ad2 100644 --- a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170919123342.php +++ b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170919123342.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> * diff --git a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170926101419.php b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170926101419.php index f8df9e69844..797cde70435 100644 --- a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170926101419.php +++ b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170926101419.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * diff --git a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20180821043638.php b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20180821043638.php index 1138bcd6bd2..087ba9eb1e1 100644 --- a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20180821043638.php +++ b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20180821043638.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Roeland Jago Douma <roeland@famdouma.nl> * diff --git a/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php b/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php index 9b7ce1ed7de..99fadd04a01 100644 --- a/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php +++ b/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> diff --git a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php index d85e00c0a8c..a1291e52e72 100644 --- a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php +++ b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -60,9 +61,10 @@ class BackupCodeStorage { /** * @param IUser $user + * @param int $number * @return string[] */ - public function createCodes(IUser $user, $number = 10) { + public function createCodes(IUser $user, int $number = 10): array { $result = []; // Delete existing ones @@ -90,7 +92,7 @@ class BackupCodeStorage { * @param IUser $user * @return bool */ - public function hasBackupCodes(IUser $user) { + public function hasBackupCodes(IUser $user): bool { $codes = $this->mapper->getBackupCodes($user); return count($codes) > 0; } @@ -99,7 +101,7 @@ class BackupCodeStorage { * @param IUser $user * @return array */ - public function getBackupCodesState(IUser $user) { + public function getBackupCodesState(IUser $user): array { $codes = $this->mapper->getBackupCodes($user); $total = count($codes); $used = 0; @@ -120,7 +122,7 @@ class BackupCodeStorage { * @param string $code * @return bool */ - public function validateCode(IUser $user, $code) { + public function validateCode(IUser $user, string $code): bool { $dbCodes = $this->mapper->getBackupCodes($user); foreach ($dbCodes as $dbCode) { diff --git a/apps/twofactor_backupcodes/lib/Settings/Personal.php b/apps/twofactor_backupcodes/lib/Settings/Personal.php index 062016d0d05..85c2bdcdf54 100644 --- a/apps/twofactor_backupcodes/lib/Settings/Personal.php +++ b/apps/twofactor_backupcodes/lib/Settings/Personal.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Arthur Schiwon <blizzz@arthur-schiwon.de> * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Roeland Jago Douma <roeland@famdouma.nl> diff --git a/apps/twofactor_backupcodes/templates/challenge.php b/apps/twofactor_backupcodes/templates/challenge.php index d269fb4b47e..e4792c8256a 100644 --- a/apps/twofactor_backupcodes/templates/challenge.php +++ b/apps/twofactor_backupcodes/templates/challenge.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + style('twofactor_backupcodes', 'style'); ?> diff --git a/apps/twofactor_backupcodes/templates/personal.php b/apps/twofactor_backupcodes/templates/personal.php index c57a589a26a..12def69bbed 100644 --- a/apps/twofactor_backupcodes/templates/personal.php +++ b/apps/twofactor_backupcodes/templates/personal.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + script('twofactor_backupcodes', 'settings'); ?> diff --git a/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php b/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php index 17155c266de..d66818742eb 100644 --- a/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php +++ b/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> diff --git a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php index 8aadacec767..70bf5be4f22 100644 --- a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php +++ b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> diff --git a/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php b/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php index fce23f2ada5..85923bfe0df 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2017 Christoph Wurst <christoph@winzerhof-wurst.at> * diff --git a/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php b/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php index fc085472529..db048a42749 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> diff --git a/apps/twofactor_backupcodes/tests/Unit/Event/CodesGeneratedTest.php b/apps/twofactor_backupcodes/tests/Unit/Event/CodesGeneratedTest.php index b8922b2cbbe..d4c07e56cd3 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Event/CodesGeneratedTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Event/CodesGeneratedTest.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * * @license GNU AGPL version 3 or any later version diff --git a/apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php b/apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php index a786d5b7f5b..4a32faf0f67 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Roeland Jago Douma <roeland@famdouma.nl> * diff --git a/apps/twofactor_backupcodes/tests/Unit/Listener/RegistryUpdaterTest.php b/apps/twofactor_backupcodes/tests/Unit/Listener/RegistryUpdaterTest.php index 8820905458f..912a1977d19 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Listener/RegistryUpdaterTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Listener/RegistryUpdaterTest.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Roeland Jago Douma <roeland@famdouma.nl> * diff --git a/apps/twofactor_backupcodes/tests/Unit/Migration/CheckBackupCodeTest.php b/apps/twofactor_backupcodes/tests/Unit/Migration/CheckBackupCodeTest.php index 123d6cdc1f8..7df80609bf9 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Migration/CheckBackupCodeTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Migration/CheckBackupCodeTest.php @@ -3,8 +3,6 @@ declare(strict_types=1); /** - * - * * @author Roeland Jago Douma <roeland@famdouma.nl> * * @license GNU AGPL version 3 or any later version diff --git a/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php b/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php index 683a196bf86..17bb86ff2ef 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> diff --git a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php index 74dfa80a30f..7b57273b53e 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php @@ -1,7 +1,8 @@ <?php + +declare(strict_types=1); + /** - * - * * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> |