diff options
author | J0WI <J0WI@users.noreply.github.com> | 2021-04-14 17:05:19 +0200 |
---|---|---|
committer | J0WI <J0WI@users.noreply.github.com> | 2021-04-15 16:57:06 +0200 |
commit | 09368e7cf5395ad4f9d93867b63e22a458f702c1 (patch) | |
tree | 8e7442c2c812619d8baef0fbab247b320238709c /apps/twofactor_backupcodes | |
parent | 1c35b3801e49eb9011040a23e64d787172fa562e (diff) | |
download | nextcloud-server-09368e7cf5395ad4f9d93867b63e22a458f702c1.tar.gz nextcloud-server-09368e7cf5395ad4f9d93867b63e22a458f702c1.zip |
2FA backupcodes: add strict typing
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
Diffstat (limited to 'apps/twofactor_backupcodes')
18 files changed, 63 insertions, 9 deletions
diff --git a/apps/twofactor_backupcodes/appinfo/routes.php b/apps/twofactor_backupcodes/appinfo/routes.php index 8adc9c3901e..243ffb1d1f8 100644 --- a/apps/twofactor_backupcodes/appinfo/routes.php +++ b/apps/twofactor_backupcodes/appinfo/routes.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * 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..432a89bd25a 100644 --- a/apps/twofactor_backupcodes/lib/Controller/SettingsController.php +++ b/apps/twofactor_backupcodes/lib/Controller/SettingsController.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * @@ -56,7 +59,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..645c246ec6d 100644 --- a/apps/twofactor_backupcodes/lib/Db/BackupCode.php +++ b/apps/twofactor_backupcodes/lib/Db/BackupCode.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * diff --git a/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php b/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php index 84972a5171a..9912f6770e3 100644 --- a/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php +++ b/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * @@ -42,7 +45,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 +59,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/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..12854f6ff0b 100644 --- a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170926101419.php +++ b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170926101419.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * diff --git a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php index d85e00c0a8c..e9ec187c360 100644 --- a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php +++ b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * @@ -60,9 +63,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 +94,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 +103,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 +124,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/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..5617138f7b1 100644 --- a/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php +++ b/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * diff --git a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php index 8aadacec767..264dc822ab8 100644 --- a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php +++ b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * 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..a9cb7b8b2dd 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * diff --git a/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php b/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php index 683a196bf86..1b5b2c307a8 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * diff --git a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php index 74dfa80a30f..a4c29ca5ecc 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * * |