Skip to content

Commit

Permalink
[4.x] Add generics (#545)
Browse files Browse the repository at this point in the history
* add generics

* more generics

* add template
  • Loading branch information
cosmastech authored Nov 15, 2024
1 parent 7856ef8 commit 819782c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/NewAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(PersonalAccessToken $accessToken, string $plainTextT
/**
* Get the instance as an array.
*
* @return array
* @return array<string, string>
*/
public function toArray()
{
Expand Down
6 changes: 3 additions & 3 deletions src/PersonalAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PersonalAccessToken extends Model implements HasAbilities
/**
* The attributes that should be cast to native types.
*
* @var array
* @var array<string, string>
*/
protected $casts = [
'abilities' => 'json',
Expand All @@ -21,7 +21,7 @@ class PersonalAccessToken extends Model implements HasAbilities
/**
* The attributes that are mass assignable.
*
* @var array
* @var array<int, string>
*/
protected $fillable = [
'name',
Expand All @@ -33,7 +33,7 @@ class PersonalAccessToken extends Model implements HasAbilities
/**
* The attributes that should be hidden for serialization.
*
* @var array
* @var array<int, string>
*/
protected $hidden = [
'token',
Expand Down
9 changes: 6 additions & 3 deletions src/Sanctum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

use Mockery;

/**
* @template TTokenModel of \Illuminate\Database\Eloquent\Model&\Laravel\Sanctum\Contracts\HasAbilities = \Laravel\Sanctum\PersonalAccessToken
*/
class Sanctum
{
/**
* The personal access client model class name.
*
* @var string
* @var class-string<TTokenModel>
*/
public static $personalAccessTokenModel = 'Laravel\\Sanctum\\PersonalAccessToken';

Expand Down Expand Up @@ -75,7 +78,7 @@ public static function actingAs($user, $abilities = [], $guard = 'sanctum')
/**
* Set the personal access token model name.
*
* @param string $model
* @param class-string<TTokenModel> $model
* @return void
*/
public static function usePersonalAccessTokenModel($model)
Expand Down Expand Up @@ -108,7 +111,7 @@ public static function authenticateAccessTokensUsing(callable $callback)
/**
* Get the token model class name.
*
* @return string
* @return class-string<TTokenModel>
*/
public static function personalAccessTokenModel()
{
Expand Down

0 comments on commit 819782c

Please sign in to comment.