Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated types #33

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/Http/Controllers/Auth/TwoFaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function update(TwoFaUpdateRequest $request, TwoFactorAuth $twoFactorAuth
{
$validated = $request->validated();

//@phpstan-ignore-next-line
$valid = $twoFactorAuth->verifyCode($request->user()->two_fa_secret_key, $validated['code']);

if ($valid === false) {
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Auth/VerifyEmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class VerifyEmailController extends Controller
public function __invoke(EmailVerificationRequest $request): RedirectResponse
{
if ($request->user()->markEmailAsVerified()) {
// @phpstan-ignore-next-line
event(new Verified($request->user()));
}

Expand Down
3 changes: 3 additions & 0 deletions app/Livewire/Admin/AuditTrails.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function render(): View
return view('livewire.admin.audit-trails', compact('sections', 'types', 'users'));
}

/**
* @return Builder<AuditTrail>
*/
public function builder(): Builder
{
return AuditTrail::with('user')->orderBy($this->sortField, $this->sortAsc ? 'asc' : 'desc');
Expand Down
3 changes: 3 additions & 0 deletions app/Livewire/Admin/NotificationsMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

class NotificationsMenu extends Component
{
/**
* @var Collection<int, Notification>
*/
public Collection $notifications;

public int $unseenCount = 0;
Expand Down
3 changes: 3 additions & 0 deletions app/Livewire/Admin/Roles/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function sortBy(string $field): void
$this->sortField = $field;
}

/**
* @return LengthAwarePaginator<Role>
*/
public function roles(): LengthAwarePaginator
{
return $this->builder()
Expand Down
1 change: 0 additions & 1 deletion app/Livewire/Admin/Users/Edit/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public function update(): void
$token = md5(random_int(1, 10).microtime());
$name = $token.'.jpg';
$img = Image::make($this->image)->encode('jpg')->resize(100, null, function (object $constraint) {
// @phpstan-ignore-next-line
$constraint->aspectRatio();
});
$img->stream();
Expand Down
3 changes: 3 additions & 0 deletions app/Livewire/Admin/Users/Edit/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class Roles extends Component
{
public User $user;

/**
* @var Collection <Role>
*/
public Collection $roles;

/**
Expand Down
11 changes: 10 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
class User extends Authenticatable implements MustVerifyEmail
{
use HasApiTokens;

/** @use HasFactory<UserFactory> */
use HasFactory;

use HasRoles;
use HasUuid;
use Notifiable;
Expand Down Expand Up @@ -76,13 +79,19 @@ public function route(string $id): string
return route('admin.users.show', ['user' => $id]);
}

/**
* Scope a query to only include active users.
*
* @param Builder<User> $query
* @return Builder<User>
*/
public function scopeIsActive(Builder $query): Builder
{
return $query->where('is_active', 1);
}

public function invite(): HasOne
{
return $this->hasOne(__CLASS__, 'id', 'invited_by');
return $this->hasOne(User::class, 'id', 'invited_by');
}
}
3 changes: 3 additions & 0 deletions database/factories/AuditTrailsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use App\Models\AuditTrail;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends Factory<AuditTrail>
*/
class AuditTrailsFactory extends Factory
{
protected $model = AuditTrail::class;
Expand Down
4 changes: 4 additions & 0 deletions database/factories/NotificationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

namespace Database\Factories;

use App\Models\Notification;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends Factory<Notification>
*/
class NotificationFactory extends Factory
{
public function definition(): array
Expand Down
4 changes: 4 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

namespace Database\Factories;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
public function definition(): array
Expand Down
17 changes: 10 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
includes:
- vendor/larastan/larastan/extension.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon

parameters:

inferPrivatePropertyTypeFromConstructor: true
checkUninitializedProperties: false

paths:
- app/
- app
- bootstrap
- database/factories

# Level 9 is the highest level
level: 8
level: 5

ignoreErrors:
- '#Cannot access property \$[a-zA-Z0-9\\_]+ on App\\Models\\User\|null#'
- '#Cannot call method [a-zA-Z0-9\\_]+\(\) on App\\Models\\User\|null#'

checkGenericClassInNonGenericObjectType: false
#- '#Cannot access property \$[a-zA-Z0-9\\_]+ on App\\Models\\User\|null#'
#- '#Cannot call method [a-zA-Z0-9\\_]+\(\) on App\\Models\\User\|null#'