Skip to content

Commit

Permalink
chore(phpstan): 手动解决错误
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaiyuxin103 committed Oct 31, 2024
1 parent 9debe18 commit e99848c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions app/Actions/Jetstream/CreateTeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function create(User $user, array $input): Team
'name' => $input['name'],
'personal_team' => false,
]));
assert($team instanceof Team);

return $team;
}
Expand Down
2 changes: 2 additions & 0 deletions app/Actions/Jetstream/InviteTeamMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Actions\Jetstream;

use App\Models\Team;
use App\Models\TeamInvitation as TeamInvitationModel;
use App\Models\User;
use Closure;
use Illuminate\Database\Query\Builder;
Expand Down Expand Up @@ -36,6 +37,7 @@ public function invite(User $user, Team $team, string $email, ?string $role = nu
'role' => $role,
]);

assert($invitation instanceof TeamInvitationModel);
Mail::to($email)->send(new TeamInvitation($invitation));
}

Expand Down
8 changes: 6 additions & 2 deletions app/Enums/CacheEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ enum CacheEnum: string
// 警告:方法名不能相同
case AUTHORIZATION_USER = 'authorizationUser'; // 将调用下面定义的 authorizationUser 方法获取缓存过期时间

// 授权用户信息过期时间定义:将在 Jwt token 过期时一同失效
private static function authorizationUser()
/**
* @description 授权用户信息过期时间定义:将在 Jwt token 过期时一同失效
*
* @phpstan-ignore method.unused
*/
private static function authorizationUser(): float
{
$expiration = Carbon::now()->addMinutes((int) config('sanctum.expiration'));

Expand Down
5 changes: 4 additions & 1 deletion lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export default {
'*.php': ['./vendor/bin/pint --dirty'],
'*.php': [
'./vendor/bin/pint --dirty',
'vendor/bin/phpstan analyse --memory-limit=2G',
],
'*.{js,mjs,jsx,ts,tsx,json,css,scss,md,vue,yml,yaml}': [
'prettier . --write',
],
Expand Down
18 changes: 4 additions & 14 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,23 @@ parameters:

ignoreErrors:
- '#PHPDoc tag @var#'
-
message: '#Method App\\Actions\\Jetstream\\CreateTeam::create\(\) should return App\\Models\\Team but returns Illuminate\\Database\\Eloquent\\Model#'
path: app/Actions/Jetstream/CreateTeam.php
-
message: '#Parameter \#1 \$callback of method Illuminate\\Support\\Collection<int,Illuminate\\Database\\Eloquent\\Model>\:\:each\(\) expects callable\(Illuminate\\Database\\Eloquent\\Model, int\)\: mixed, Closure\(App\\Models\\Team\)\: void given#'
path: app/Actions/Jetstream/DeleteUser.php
-
message: '#Parameter \#1 \$invitation of class Laravel\\Jetstream\\Mail\\TeamInvitation constructor expects Laravel\\Jetstream\\TeamInvitation, Illuminate\\Database\\Eloquent\\Model given#'
path: app/Actions/Jetstream/InviteTeamMember.php
-
message: '#Access to an undefined property Illuminate\\Database\\Eloquent\\Model\:\:\$id#'
path: app/Actions/Jetstream/RemoveTeamMember.php
-
message: '#Parameter \#1 \$state of method Illuminate\\Database\\Eloquent\\Factories\\Factory<App\\Models\\Team>::state\(\) expects array<string, mixed>|(callable(array<string, mixed>, Illuminate\\Database\\Eloquent\\Model|null): array<string, mixed>), Closure(array, App\\Models\\User): array{name: non-falsy-string, user_id: int, personal_team: true} given#'
path: database/factories/UserFactory.php
-
message: '#Undefined variable: \$this#'
path: routes/console.php

excludePaths:
- ./*/*/FileToBeExcluded.php
- app/Filament/Resources/Shield/RoleResource.php
- database/seeders/ShieldSeeder.php
- .phpstorm.meta.php
- _ide_helper.php

scanFiles:
- _ide_helper_models.php

checkMissingIterableValueType: false

reportUnmatchedIgnoredErrors: false
reportUnmatchedIgnoredErrors: false

0 comments on commit e99848c

Please sign in to comment.