Skip to content

Commit

Permalink
Merge pull request #1051 from kenjis/docs-update-phpdoc-array
Browse files Browse the repository at this point in the history
docs: update PHPDoc array types
  • Loading branch information
kenjis authored Feb 26, 2024
2 parents 904e3d1 + f282bae commit 933da42
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function getProvider(): UserModel
* own, additional, features on top of the required ones,
* like "remember-me" functionality.
*
* @param string[] $args
* @param list<string> $args
*
* @throws AuthenticationException
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Authentication/Authenticators/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ private function setAuthAction(): bool
/**
* Gets identities for action
*
* @return UserIdentity[]
* @return list<UserIdentity>
*/
private function getIdentitiesForAction(User $user): array
{
Expand All @@ -512,7 +512,7 @@ private function getIdentitiesForAction(User $user): array
}

/**
* @return string[]
* @return list<string>
*/
private function getActionTypes(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Authentication/JWT/JWSAdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface JWSAdapterInterface
/**
* Issues Signed JWT (JWS)
*
* @param array<mixed> $payload The payload.
* @param array<string, mixed> $payload The payload.
* @param string $keyset The key group.
* The array key of Config\AuthJWT::$keys.
* @param array<string, string>|null $headers An array with header elements to attach.
Expand Down
6 changes: 3 additions & 3 deletions src/Authentication/Traits/HasAccessTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ trait HasAccessTokens
/**
* Generates a new personal access token for this user.
*
* @param string $name Token name
* @param string[] $scopes Permissions the token grants
* @param string $name Token name
* @param list<string> $scopes Permissions the token grants
*/
public function generateAccessToken(string $name, array $scopes = ['*']): AccessToken
{
Expand Down Expand Up @@ -81,7 +81,7 @@ public function revokeAllAccessTokens(): void
/**
* Retrieves all personal access tokens for this user.
*
* @return AccessToken[]
* @return list<AccessToken>
*/
public function accessTokens(): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/Authentication/Traits/HasHmacTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ trait HasHmacTokens
/**
* Generates a new personal HMAC token for this user.
*
* @param string $name Token name
* @param string[] $scopes Permissions the token grants
* @param string $name Token name
* @param list<string> $scopes Permissions the token grants
*
* @throws ReflectionException
*/
Expand Down Expand Up @@ -73,7 +73,7 @@ public function revokeAllHmacTokens(): void
/**
* Retrieves all personal HMAC tokens for this user.
*
* @return AccessToken[]
* @return list<AccessToken>
*/
public function hmacTokens(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Authorization/Traits/Authorizable.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ private function saveGroupsOrPermissions(string $type, $model, array $cache): vo
}

/**
* @return string[]
* @return list<string>
*/
private function getConfigGroups(): array
{
return array_keys(setting('AuthGroups.groups'));
}

/**
* @return string[]
* @return list<string>
*/
private function getConfigPermissions(): array
{
Expand Down
5 changes: 2 additions & 3 deletions src/Config/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ class Auth extends BaseConfig
* when using the 'chain' filter. Each Authenticator listed will be checked.
* If no match is found, then the next in the chain will be checked.
*
* @var string[]
* @phpstan-var list<string>
* @var list<string>
*/
public array $authenticationChain = [
'session',
Expand Down Expand Up @@ -264,7 +263,7 @@ class Auth extends BaseConfig
* You can add custom classes as long as they adhere to the
* CodeIgniter\Shield\Authentication\Passwords\ValidatorInterface.
*
* @var class-string<ValidatorInterface>[]
* @var list<class-string<ValidatorInterface>>
*/
public array $passwordValidators = [
CompositionValidator::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Config/AuthJWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AuthJWT extends BaseConfig
* The key of the array is the key group name.
* The first key of the group is used for signing.
*
* @var array<string, array<int, array<string, string>>>
* @var array<string, array<int, array<string, string>>>
* @phpstan-var array<string, list<array<string, string>>>
*/
public array $keys = [
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ActionController extends BaseController
/**
* Perform an initial check if we have a valid action or not.
*
* @param string[] $params
* @param list<string> $params
*
* @return Response|string
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Controllers/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public function loginAction(): RedirectResponse
/**
* Returns the rules that should be used for validation.
*
* @return array<string, array<string, array<string>|string>>
* @phpstan-return array<string, array<string, string|list<string>>>
* @return array<string, array<string, list<string>|string>>
*/
protected function getValidationRules(): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controllers/MagicLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ private function recordLoginAttempt(
/**
* Returns the rules that should be used for validation.
*
* @return array<string, array<string, array<string>|string>>
* @phpstan-return array<string, array<string, string|list<string>>>
* @return array<string, array<string, list<string>|string>>
*/
protected function getValidationRules(): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controllers/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ protected function getUserEntity(): User
/**
* Returns the rules that should be used for validation.
*
* @return array<string, array<string, array<string>|string>>
* @phpstan-return array<string, array<string, string|list<string>>>
* @return array<string, array<string, list<string>|string>>
*/
protected function getValidationRules(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class Entity extends FrameworkEntity
/**
* Custom convert handlers
*
* @var array<string, string>
* @var array<string, string>
* @phpstan-var array<string, class-string>
*/
protected $castHandlers = [
Expand Down
22 changes: 10 additions & 12 deletions src/Entities/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
use CodeIgniter\Shield\Traits\Resettable;

/**
* @property string|null $email
* @property int|string|null $id
* @property UserIdentity[]|null $identities
* @property Time|null $last_active
* @property string|null $password
* @property string|null $password_hash
* @property string|null $username
* @property string|null $email
* @property int|string|null $id
* @property list<UserIdentity>|null $identities
* @property Time|null $last_active
* @property string|null $password
* @property string|null $password_hash
* @property string|null $username
*/
class User extends Entity
{
Expand All @@ -44,7 +44,7 @@ class User extends Entity
use Bannable;

/**
* @var UserIdentity[]|null
* @var list<UserIdentity>|null
*/
private ?array $identities = null;

Expand All @@ -53,9 +53,7 @@ class User extends Entity
private ?string $password_hash = null;

/**
* @var string[]
* @phpstan-var list<string>
* @psalm-var list<string>
* @var list<string>
*/
protected $dates = [
'created_at',
Expand Down Expand Up @@ -107,7 +105,7 @@ private function populateIdentities(): void
*
* @param string $type 'all' returns all identities.
*
* @return UserIdentity[]
* @return list<UserIdentity>
*/
public function getIdentities(string $type = 'all'): array
{
Expand Down
4 changes: 1 addition & 3 deletions src/Entities/UserIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class UserIdentity extends Entity
];

/**
* @var string[]
* @phpstan-var list<string>
* @psalm-var list<string>
* @var list<string>
*/
protected $dates = [
'expires',
Expand Down
24 changes: 12 additions & 12 deletions src/Models/UserIdentityModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ public function createCodeIdentity(
/**
* Generates a new personal access token for the user.
*
* @param string $name Token name
* @param string[] $scopes Permissions the token grants
* @param string $name Token name
* @param list<string> $scopes Permissions the token grants
*/
public function generateAccessToken(User $user, string $name, array $scopes = ['*']): AccessToken
{
Expand Down Expand Up @@ -210,7 +210,7 @@ public function getAccessTokenById($id, User $user): ?AccessToken
}

/**
* @return AccessToken[]
* @return list<AccessToken>
*/
public function getAllAccessTokens(User $user): array
{
Expand Down Expand Up @@ -242,8 +242,8 @@ public function getHmacTokenByKey(string $key): ?AccessToken
/**
* Generates a new personal access token for the user.
*
* @param string $name Token name
* @param string[] $scopes Permissions the token grants
* @param string $name Token name
* @param list<string> $scopes Permissions the token grants
*
* @throws Exception
* @throws ReflectionException
Expand Down Expand Up @@ -321,7 +321,7 @@ public function getHmacTokenById($id, User $user): ?AccessToken
*
* @param User $user User object
*
* @return AccessToken[]
* @return list<AccessToken>
*/
public function getAllHmacTokens(User $user): array
{
Expand Down Expand Up @@ -384,7 +384,7 @@ public function getIdentityBySecret(string $type, ?string $secret): ?UserIdentit
/**
* Returns all identities.
*
* @return UserIdentity[]
* @return list<UserIdentity>
*/
public function getIdentities(User $user): array
{
Expand All @@ -394,9 +394,9 @@ public function getIdentities(User $user): array
}

/**
* @param int[]|string[] $userIds
* @param list<int>|list<string> $userIds
*
* @return UserIdentity[]
* @return list<UserIdentity>
*/
public function getIdentitiesByUserIds(array $userIds): array
{
Expand All @@ -419,9 +419,9 @@ public function getIdentityByType(User $user, string $type): ?UserIdentity
/**
* Returns all identities for the specific types.
*
* @param string[] $types
* @param list<string> $types
*
* @return UserIdentity[]
* @return list<UserIdentity>
*/
public function getIdentitiesByTypes(User $user, array $types): array
{
Expand Down Expand Up @@ -507,7 +507,7 @@ public function revokeAllAccessTokens(User $user): void
/**
* Force password reset for multiple users.
*
* @param int[]|string[] $userIds
* @param list<int>|list<string> $userIds
*/
public function forceMultiplePasswordReset(array $userIds): void
{
Expand Down
6 changes: 3 additions & 3 deletions src/Models/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ protected function fetchIdentities(array $data): array
/**
* Map our users by ID to make assigning simpler
*
* @param array $data Event $data
* @param UserIdentity[] $identities
* @param array $data Event $data
* @param list<UserIdentity> $identities
*
* @return User[] UserId => User object
* @return list<User> UserId => User object
* @phpstan-return array<int|string, User> UserId => User object
*/
private function assignIdentities(array $data, array $identities): array
Expand Down
2 changes: 1 addition & 1 deletion tests/Authentication/HasAccessTokensTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testAccessTokens(): void
['user_id' => $this->user->id, 'type' => 'access_token', 'secret' => 'secretToken2']
);

/** @var AccessToken[] $tokens */
/** @var list<AccessToken> $tokens */
$tokens = $this->user->accessTokens();

$this->assertCount(2, $tokens);
Expand Down
7 changes: 3 additions & 4 deletions tests/Language/AbstractTranslationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ abstract class AbstractTranslationTestCase extends TestCase
* class and the contained values will be skipped in
* testAllIncludedLanguageKeysAreTranslated.
*
* @var string[]
* @phpstan-var list<string>
* @var list<string>
*/
protected array $excludedLocaleKeyTranslations = [];

Expand Down Expand Up @@ -360,7 +359,7 @@ final public function testAllLocalizationParametersAreNotTranslated(string $loca
}

/**
* @return string[][]
* @return array<string, list<string>>
*/
final public static function localesProvider(): iterable
{
Expand Down Expand Up @@ -393,7 +392,7 @@ final public function testLocaleHasCorrespondingTestCaseFile(string $locale): vo
/**
* Get all the ISO 639-1 and 639-2 locale codes.
*
* @return array<string, array<string>>
* @return array<string, list<string>>
*/
final public function translationKeys(): array
{
Expand Down

0 comments on commit 933da42

Please sign in to comment.