mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-25 09:44:04 +01:00
Complete phpDocs type-hints
This commit is contained in:
parent
616a9348b2
commit
d84dd6659e
@ -18,7 +18,7 @@ class SettingController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$settings = Settings::all();
|
$settings = Settings::all();
|
||||||
$settingsResources = collect();
|
$settingsResources = collect([]);
|
||||||
$settings->each(function (mixed $item, string $key) use ($settingsResources) {
|
$settings->each(function (mixed $item, string $key) use ($settingsResources) {
|
||||||
$settingsResources->push([
|
$settingsResources->push([
|
||||||
'key' => $key,
|
'key' => $key,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Api\v1\Resources;
|
namespace App\Api\v1\Resources;
|
||||||
|
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
|
use App\Api\v1\Resources\TwoFAccountReadResource;
|
||||||
|
|
||||||
class TwoFAccountCollection extends ResourceCollection
|
class TwoFAccountCollection extends ResourceCollection
|
||||||
{
|
{
|
||||||
@ -11,14 +12,14 @@ class TwoFAccountCollection extends ResourceCollection
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $collects = 'App\Api\v1\Resources\TwoFAccountReadResource';
|
public $collects = TwoFAccountReadResource::class;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the resource collection into an array.
|
* Transform the resource collection into an array.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
* @return \Illuminate\Support\Collection<int|string, TwoFAccountReadResource>
|
||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ public function index()
|
|||||||
'lang' => App::currentLocale(),
|
'lang' => App::currentLocale(),
|
||||||
'isDemoApp' => config("2fauth.config.isDemoApp") ? 'true' : 'false',
|
'isDemoApp' => config("2fauth.config.isDemoApp") ? 'true' : 'false',
|
||||||
'isTestingApp' => config("2fauth.config.isTestingApp") ? 'true' : 'false',
|
'isTestingApp' => config("2fauth.config.isTestingApp") ? 'true' : 'false',
|
||||||
'locales' => collect(config("2fauth.locales"))->toJson()
|
'locales' => collect(config("2fauth.locales"))->toJson() /** @phpstan-ignore-line */
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ protected static function boot()
|
|||||||
/**
|
/**
|
||||||
* Get the TwoFAccounts of the group.
|
* Get the TwoFAccounts of the group.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<TwoFAccount>
|
||||||
*/
|
*/
|
||||||
public function twofaccounts()
|
public function twofaccounts()
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ class GroupService
|
|||||||
/**
|
/**
|
||||||
* Returns all existing groups
|
* Returns all existing groups
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection<int, Group>
|
||||||
*/
|
*/
|
||||||
public static function getAll() : Collection
|
public static function getAll() : Collection
|
||||||
{
|
{
|
||||||
@ -147,7 +147,7 @@ public static function assign($ids, Group $group = null) : void
|
|||||||
* Finds twofaccounts assigned to the group
|
* Finds twofaccounts assigned to the group
|
||||||
*
|
*
|
||||||
* @param \App\Models\Group $group The group
|
* @param \App\Models\Group $group The group
|
||||||
* @return Collection The assigned accounts
|
* @return Collection<int, TwoFAccount> The assigned accounts
|
||||||
*/
|
*/
|
||||||
public static function getAccounts(Group $group) : Collection
|
public static function getAccounts(Group $group) : Collection
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@ -10,7 +11,7 @@
|
|||||||
class LogoService
|
class LogoService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Illuminate\Support\Collection
|
* @var \Illuminate\Support\Collection<string, string>
|
||||||
*/
|
*/
|
||||||
protected $tfas;
|
protected $tfas;
|
||||||
|
|
||||||
@ -85,8 +86,8 @@ protected function setTfaCollection() : void
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->tfas = Storage::disk('logos')->exists(self::TFA_JSON)
|
$this->tfas = Storage::disk('logos')->exists(self::TFA_JSON)
|
||||||
? collect(json_decode(Storage::disk('logos')->get(self::TFA_JSON)))
|
? new Collection(json_decode(Storage::disk('logos')->get(self::TFA_JSON)))
|
||||||
: collect();
|
: collect([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ protected function cacheTfaDirectorySource() : void
|
|||||||
try {
|
try {
|
||||||
$response = Http::retry(3, 100)->get(self::TFA_URL);
|
$response = Http::retry(3, 100)->get(self::TFA_URL);
|
||||||
|
|
||||||
$coll = collect(json_decode(htmlspecialchars_decode($response->body()), true))
|
$coll = collect(json_decode(htmlspecialchars_decode($response->body()), true)) /** @phpstan-ignore-line */
|
||||||
->mapWithKeys(function ($item, $key) {
|
->mapWithKeys(function ($item, $key) {
|
||||||
return [
|
return [
|
||||||
strtolower(head($item)) => $item[1]["domain"]
|
strtolower(head($item)) => $item[1]["domain"]
|
||||||
|
@ -38,7 +38,7 @@ class AegisMigrator extends Migrator
|
|||||||
* Convert migration data to a TwoFAccounts collection.
|
* Convert migration data to a TwoFAccounts collection.
|
||||||
*
|
*
|
||||||
* @param mixed $migrationPayload
|
* @param mixed $migrationPayload
|
||||||
* @return \Illuminate\Support\Collection The converted accounts
|
* @return \Illuminate\Support\Collection<int|string, \App\Models\TwoFAccount> The converted accounts
|
||||||
*/
|
*/
|
||||||
public function migrate(mixed $migrationPayload) : Collection
|
public function migrate(mixed $migrationPayload) : Collection
|
||||||
{
|
{
|
||||||
|
@ -23,8 +23,7 @@ class GoogleAuthMigrator extends Migrator
|
|||||||
* Convert Google Authenticator migration URI to a set of TwoFAccount objects.
|
* Convert Google Authenticator migration URI to a set of TwoFAccount objects.
|
||||||
*
|
*
|
||||||
* @param mixed $migrationPayload migration uri provided by Google Authenticator export feature
|
* @param mixed $migrationPayload migration uri provided by Google Authenticator export feature
|
||||||
*
|
* @return \Illuminate\Support\Collection<int|string, \App\Models\TwoFAccount> The converted accounts
|
||||||
* @return \Illuminate\Support\Collection The converted accounts
|
|
||||||
*/
|
*/
|
||||||
public function migrate(mixed $migrationPayload) : Collection
|
public function migrate(mixed $migrationPayload) : Collection
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ abstract class Migrator
|
|||||||
* Convert migration data to a 2FAccounts collection.
|
* Convert migration data to a 2FAccounts collection.
|
||||||
*
|
*
|
||||||
* @param mixed $migrationPayload
|
* @param mixed $migrationPayload
|
||||||
* @return \Illuminate\Support\Collection The converted accounts
|
* @return \Illuminate\Support\Collection<int|string, \App\Models\TwoFAccount> The converted accounts
|
||||||
*/
|
*/
|
||||||
abstract public function migrate(mixed $migrationPayload) : Collection;
|
abstract public function migrate(mixed $migrationPayload) : Collection;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class PlainTextMigrator extends Migrator
|
|||||||
* Convert migration data to a TwoFAccounts collection.
|
* Convert migration data to a TwoFAccounts collection.
|
||||||
*
|
*
|
||||||
* @param mixed $migrationPayload
|
* @param mixed $migrationPayload
|
||||||
* @return \Illuminate\Support\Collection The converted accounts
|
* @return \Illuminate\Support\Collection<int|string, \App\Models\TwoFAccount> The converted accounts
|
||||||
*/
|
*/
|
||||||
public function migrate(mixed $migrationPayload) : Collection
|
public function migrate(mixed $migrationPayload) : Collection
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ class TwoFASMigrator extends Migrator
|
|||||||
* Convert migration data to a TwoFAccounts collection.
|
* Convert migration data to a TwoFAccounts collection.
|
||||||
*
|
*
|
||||||
* @param mixed $migrationPayload
|
* @param mixed $migrationPayload
|
||||||
* @return \Illuminate\Support\Collection The converted accounts
|
* @return \Illuminate\Support\Collection<int|string, \App\Models\TwoFAccount> The converted accounts
|
||||||
*/
|
*/
|
||||||
public function migrate(mixed $migrationPayload) : Collection
|
public function migrate(mixed $migrationPayload) : Collection
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ class SettingService
|
|||||||
/**
|
/**
|
||||||
* All user settings
|
* All user settings
|
||||||
*
|
*
|
||||||
* @var Collection
|
* @var Collection<string, mixed>
|
||||||
*/
|
*/
|
||||||
private Collection $settings;
|
private Collection $settings;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public function get($setting)
|
|||||||
/**
|
/**
|
||||||
* Get all settings
|
* Get all settings
|
||||||
*
|
*
|
||||||
* @return Collection the Settings collection
|
* @return Collection<string, mixed> the Settings collection
|
||||||
*/
|
*/
|
||||||
public function all() : Collection
|
public function all() : Collection
|
||||||
{
|
{
|
||||||
@ -122,7 +122,7 @@ private function build()
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Merge 2fauth/app config values as fallback values
|
// Merge 2fauth/app config values as fallback values
|
||||||
$settings = collect(config('2fauth.options'))->merge($userOptions);
|
$settings = collect(config('2fauth.options'))->merge($userOptions); /** @phpstan-ignore-line */
|
||||||
|
|
||||||
if(!Arr::has($settings, 'lang')) {
|
if(!Arr::has($settings, 'lang')) {
|
||||||
$settings['lang'] = 'browser';
|
$settings['lang'] = 'browser';
|
||||||
|
@ -51,7 +51,7 @@ public static function withdraw($ids) : void
|
|||||||
* Convert a migration payload to a set of TwoFAccount objects
|
* Convert a migration payload to a set of TwoFAccount objects
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload Migration payload from 2FA apps export feature
|
* @param string $migrationPayload Migration payload from 2FA apps export feature
|
||||||
* @return \Illuminate\Support\Collection The converted accounts
|
* @return \Illuminate\Support\Collection<int|string, TwoFAccount> The converted accounts
|
||||||
*/
|
*/
|
||||||
public function migrate(string $migrationPayload) : Collection
|
public function migrate(string $migrationPayload) : Collection
|
||||||
{
|
{
|
||||||
@ -83,8 +83,8 @@ public static function delete($ids) : int
|
|||||||
/**
|
/**
|
||||||
* Return the given collection with items marked as Duplicates (using id=-1) if a similar record exists in database
|
* Return the given collection with items marked as Duplicates (using id=-1) if a similar record exists in database
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Support\Collection $twofaccounts
|
* @param \Illuminate\Support\Collection<int|string, TwoFAccount> $twofaccounts
|
||||||
* @return \Illuminate\Support\Collection
|
* @return \Illuminate\Support\Collection<int|string, TwoFAccount>
|
||||||
*/
|
*/
|
||||||
private static function markAsDuplicate(Collection $twofaccounts) : Collection
|
private static function markAsDuplicate(Collection $twofaccounts) : Collection
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Group>
|
||||||
|
*/
|
||||||
class GroupFactory extends Factory
|
class GroupFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
use ParagonIE\ConstantTime\Base32;
|
use ParagonIE\ConstantTime\Base32;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TwoFAccount>
|
||||||
|
*/
|
||||||
class TwoFAccountFactory extends Factory
|
class TwoFAccountFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||||
|
*/
|
||||||
class UserFactory extends Factory
|
class UserFactory extends Factory
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -29,7 +32,7 @@ public function definition()
|
|||||||
/**
|
/**
|
||||||
* Indicate that the model's email address should be unverified.
|
* Indicate that the model's email address should be unverified.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
* @return \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||||
*/
|
*/
|
||||||
public function unverified()
|
public function unverified()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user