diff --git a/app-modules/activity/database/migrations/2023_01_18_211845_create_messages_table.php b/app-modules/activity/database/migrations/2023_01_18_211845_create_messages_table.php index e0180044..6b4f3829 100644 --- a/app-modules/activity/database/migrations/2023_01_18_211845_create_messages_table.php +++ b/app-modules/activity/database/migrations/2023_01_18_211845_create_messages_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('messages')) { + if (!Schema::hasTable('messages')) { Schema::create('messages', function (Blueprint $table): void { $table->uuid('id')->primary(); $table->foreignUuid('provider_id')->constrained('providers'); diff --git a/app-modules/activity/database/migrations/2023_02_10_224951_create_voice_messages_table.php b/app-modules/activity/database/migrations/2023_02_10_224951_create_voice_messages_table.php index e5a32576..294a1d3c 100644 --- a/app-modules/activity/database/migrations/2023_02_10_224951_create_voice_messages_table.php +++ b/app-modules/activity/database/migrations/2023_02_10_224951_create_voice_messages_table.php @@ -10,7 +10,7 @@ { public function up(): void { - if (! Schema::hasTable('voice_messages')) { + if (!Schema::hasTable('voice_messages')) { Schema::create('voice_messages', function (Blueprint $table): void { $table->id(); $table->foreignUuid('provider_id')->constrained('providers'); diff --git a/app-modules/activity/phpstan.ignore.neon b/app-modules/activity/phpstan.ignore.neon new file mode 100644 index 00000000..f51e71c3 --- /dev/null +++ b/app-modules/activity/phpstan.ignore.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/app-modules/activity/phpstan.neon b/app-modules/activity/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/activity/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/activity/src/Actions/NewVoiceMessage.php b/app-modules/activity/src/Actions/NewVoiceMessage.php index 98753c60..478c2fa1 100644 --- a/app-modules/activity/src/Actions/NewVoiceMessage.php +++ b/app-modules/activity/src/Actions/NewVoiceMessage.php @@ -17,6 +17,9 @@ public function __construct( private IncrementExperience $characterExperience, ) {} + /** + * @param array $payload + */ public function persist(array $payload): void { $voiceDTO = NewVoiceMessageDTO::make($payload); diff --git a/app-modules/activity/src/DTOs/NewMessageDTO.php b/app-modules/activity/src/DTOs/NewMessageDTO.php index 443e37ca..3c84496e 100644 --- a/app-modules/activity/src/DTOs/NewMessageDTO.php +++ b/app-modules/activity/src/DTOs/NewMessageDTO.php @@ -20,6 +20,9 @@ public function __construct( public DateTimeImmutable $sentAt, ) {} + /** + * @param array $payload + */ public static function make(array $payload): self { return new self( diff --git a/app-modules/activity/src/DTOs/NewVoiceMessageDTO.php b/app-modules/activity/src/DTOs/NewVoiceMessageDTO.php index 5ddba37f..136310f2 100644 --- a/app-modules/activity/src/DTOs/NewVoiceMessageDTO.php +++ b/app-modules/activity/src/DTOs/NewVoiceMessageDTO.php @@ -16,6 +16,9 @@ public function __construct( public string $channelName, ) {} + /** + * @param array $payload + */ public static function make(array $payload): self { return new self( diff --git a/app-modules/activity/src/Http/Controllers/MessagesController.php b/app-modules/activity/src/Http/Controllers/MessagesController.php index cff4f107..5951318e 100644 --- a/app-modules/activity/src/Http/Controllers/MessagesController.php +++ b/app-modules/activity/src/Http/Controllers/MessagesController.php @@ -7,6 +7,7 @@ use App\Http\Controllers\Controller; use He4rt\Activity\Actions\NewMessage; use He4rt\Activity\Actions\NewVoiceMessage; +use He4rt\Activity\DTOs\NewMessageDTO; use He4rt\Activity\Http\Requests\CreateMessageRequest; use He4rt\Activity\Http\Requests\CreateVoiceMessageRequest; use Illuminate\Http\Response; @@ -18,7 +19,7 @@ public function postMessage( string $provider, NewMessage $newMessage, ): Response { - $newMessage->persist($request->validated()); + $newMessage->persist(NewMessageDTO::make($request->validated())); return response()->noContent(); } diff --git a/app-modules/activity/src/Http/Requests/CreateMessageRequest.php b/app-modules/activity/src/Http/Requests/CreateMessageRequest.php index 2f247d5e..95b13c06 100644 --- a/app-modules/activity/src/Http/Requests/CreateMessageRequest.php +++ b/app-modules/activity/src/Http/Requests/CreateMessageRequest.php @@ -13,6 +13,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/activity/src/Http/Requests/CreateVoiceMessageRequest.php b/app-modules/activity/src/Http/Requests/CreateVoiceMessageRequest.php index 5c8d85d0..3c75d17d 100644 --- a/app-modules/activity/src/Http/Requests/CreateVoiceMessageRequest.php +++ b/app-modules/activity/src/Http/Requests/CreateVoiceMessageRequest.php @@ -13,6 +13,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/activity/src/Models/Message.php b/app-modules/activity/src/Models/Message.php index 62ece1ea..8f785682 100644 --- a/app-modules/activity/src/Models/Message.php +++ b/app-modules/activity/src/Models/Message.php @@ -14,6 +14,7 @@ final class Message extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/bot-discord/phpstan.ignore.neon b/app-modules/bot-discord/phpstan.ignore.neon new file mode 100644 index 00000000..ec1bd846 --- /dev/null +++ b/app-modules/bot-discord/phpstan.ignore.neon @@ -0,0 +1,50 @@ +parameters: + ignoreErrors: + - message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\Guild\\Guild::\$icon\.$#' + identifier: property.notFound + count: 1 + path: src/SlashCommands/DontAskCommand.php + - message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\Guild\\Guild::\$icon\.$#' + identifier: property.notFound + count: 1 + path: src/SlashCommands/EditProfileCommand.php + - message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\Guild\\Guild::\$icon\.$#' + identifier: property.notFound + count: 1 + path: src/SlashCommands/IntroductionCommand.php + - message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\Guild\\Guild::\$icon\.$#' + identifier: property.notFound + count: 1 + path: src/SlashCommands/ProfileCommand.php + - message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\User\\Member::\$user\.$#' + identifier: property.notFound + count: 7 + path: src/Events/WelcomeMember.php + - message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\User\\User::\$avatar\.$#' + identifier: property.notFound + count: 1 + path: src/SlashCommands/EditProfileCommand.php + - message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\User\\User::\$avatar\.$#' + identifier: property.notFound + count: 2 + path: src/SlashCommands/IntroductionCommand.php + - message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\WebSockets\\VoiceStateUpdate::\$channel_id\.$#' + identifier: property.notFound + count: 1 + path: src/Events/DynamicVoiceEvent.php + - message: '#^Method\ He4rt\\BotDiscord\\Tasks\\RichPresence::makeActivities\(\)\ should\ return\ array\ but\ returns\ array\.$#' + identifier: return.type + count: 1 + path: src/Tasks/RichPresence.php + - message: '#^Parameter\ \#1\ \$guild\ of\ method\ Discord\\Repository\\Guild\\ChannelRepository::build\(\)\ expects\ Discord\\Repository\\Guild\\Guild\|string,\ Discord\\Parts\\Guild\\Guild\|null\ given\.$#' + identifier: argument.type + count: 1 + path: src/SlashCommands/DynamicVoiceCommand.php + - message: '#^Unable\ to\ resolve\ the\ template\ type\ TKey\ in\ call\ to\ function\ collect$#' + identifier: argument.templateType + count: 1 + path: src/SlashCommands/EditVoiceChannelLimitCommand.php + - message: '#^Unable\ to\ resolve\ the\ template\ type\ TValue\ in\ call\ to\ function\ collect$#' + identifier: argument.templateType + count: 1 + path: src/SlashCommands/EditVoiceChannelLimitCommand.php diff --git a/app-modules/bot-discord/phpstan.neon b/app-modules/bot-discord/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/bot-discord/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/bot-discord/src/Actions/VoiceChannel/HandleStateChannelAction.php b/app-modules/bot-discord/src/Actions/VoiceChannel/HandleStateChannelAction.php index 85e24a2e..202f09a5 100644 --- a/app-modules/bot-discord/src/Actions/VoiceChannel/HandleStateChannelAction.php +++ b/app-modules/bot-discord/src/Actions/VoiceChannel/HandleStateChannelAction.php @@ -59,19 +59,19 @@ public function execute(int|string $userId, ?string $channelId): void private function isMovingBetweenChannels(?string $newChannelId, ?string $oldChannelId): bool { - return ! is_null($newChannelId) - && ! is_null($oldChannelId) + return !is_null($newChannelId) + && !is_null($oldChannelId) && $oldChannelId !== $newChannelId; } private function isLeavingVoice(?string $newChannelId, ?string $oldChannelId): bool { - return is_null($newChannelId) && ! is_null($oldChannelId); + return is_null($newChannelId) && !is_null($oldChannelId); } private function isJoiningChannel(?string $channelId, ?string $oldChannelId): bool { - return ! is_null($channelId) && is_null($oldChannelId); + return !is_null($channelId) && is_null($oldChannelId); } private function getUserLastChannel(string $userId): ?string @@ -92,6 +92,6 @@ private function clearUserLastChannel(string $userId): void private function isUpdatingInSameChannel(?string $newChannelId, ?string $oldChannelId): bool { - return ! is_null($newChannelId) && $oldChannelId === $newChannelId; + return !is_null($newChannelId) && $oldChannelId === $newChannelId; } } diff --git a/app-modules/bot-discord/src/Actions/VoiceChannel/JoiningChannelAction.php b/app-modules/bot-discord/src/Actions/VoiceChannel/JoiningChannelAction.php index 20496a71..ba38d75e 100644 --- a/app-modules/bot-discord/src/Actions/VoiceChannel/JoiningChannelAction.php +++ b/app-modules/bot-discord/src/Actions/VoiceChannel/JoiningChannelAction.php @@ -8,7 +8,10 @@ final class JoiningChannelAction { - public function execute(string $channelId, array $activeChannels, $user): void + /** + * @param array $activeChannels + */ + public function execute(string $channelId, array $activeChannels, string $user): void { foreach ($activeChannels as $index => $channel) { /** @var VoiceChannelDTO $channel */ @@ -23,6 +26,9 @@ public function execute(string $channelId, array $activeChannels, $user): void } } + /** + * @param array $activeChannels + */ private function saveActiveChannels(array $activeChannels): void { cache()->tags(['voice_channels'])->put('active_voice_channels_keys', $activeChannels); diff --git a/app-modules/bot-discord/src/Actions/VoiceChannel/LeftChannelAction.php b/app-modules/bot-discord/src/Actions/VoiceChannel/LeftChannelAction.php index 4dce81d7..897dfa6b 100644 --- a/app-modules/bot-discord/src/Actions/VoiceChannel/LeftChannelAction.php +++ b/app-modules/bot-discord/src/Actions/VoiceChannel/LeftChannelAction.php @@ -8,7 +8,10 @@ final class LeftChannelAction { - public function execute(array $activeChannels, $user): void + /** + * @param array $activeChannels + */ + public function execute(array $activeChannels, string $user): void { foreach ($activeChannels as $index => $channel) { /** @var VoiceChannelDTO $channel */ @@ -22,6 +25,9 @@ public function execute(array $activeChannels, $user): void } } + /** + * @param array $activeChannels + */ private function saveActiveChannels(array $activeChannels): void { cache()->tags(['voice_channels'])->put('active_voice_channels_keys', $activeChannels); diff --git a/app-modules/bot-discord/src/Commands/PingCommand.php b/app-modules/bot-discord/src/Commands/PingCommand.php index 6f7984f3..0495d1ef 100644 --- a/app-modules/bot-discord/src/Commands/PingCommand.php +++ b/app-modules/bot-discord/src/Commands/PingCommand.php @@ -40,6 +40,8 @@ class PingCommand extends Command /** * Handle the command. + * + * @param array $args */ public function handle(Message $message, array $args): void { @@ -53,6 +55,8 @@ public function handle(Message $message, array $args): void /** * The command interaction routes. + * + * @return array */ public function interactions(): array { diff --git a/app-modules/bot-discord/src/DTO/VoiceChannelDTO.php b/app-modules/bot-discord/src/DTO/VoiceChannelDTO.php index 9834fd91..dfca5af9 100644 --- a/app-modules/bot-discord/src/DTO/VoiceChannelDTO.php +++ b/app-modules/bot-discord/src/DTO/VoiceChannelDTO.php @@ -13,10 +13,14 @@ public function __construct( public readonly string $channelId, public readonly string $ownerId, public int $usersCount, + /** @var array */ public array $users, public ?CarbonInterface $lastJoinedAt = null, ) {} + /** + * @param array $data + */ public static function make(array $data): self { return new self( diff --git a/app-modules/bot-discord/src/SlashCommands/AbstractSlashCommand.php b/app-modules/bot-discord/src/SlashCommands/AbstractSlashCommand.php index b76f8f1c..0cdf0234 100644 --- a/app-modules/bot-discord/src/SlashCommands/AbstractSlashCommand.php +++ b/app-modules/bot-discord/src/SlashCommands/AbstractSlashCommand.php @@ -38,6 +38,7 @@ protected function processMiddleware(Interaction $interaction): mixed ])); } + /** @return Builder */ protected function getMemberProviderQuery(): Builder { return ExternalIdentity::query() diff --git a/app-modules/bot-discord/src/SlashCommands/CargoDelasCommand.php b/app-modules/bot-discord/src/SlashCommands/CargoDelasCommand.php index 3ab47c5d..08794941 100644 --- a/app-modules/bot-discord/src/SlashCommands/CargoDelasCommand.php +++ b/app-modules/bot-discord/src/SlashCommands/CargoDelasCommand.php @@ -29,7 +29,7 @@ class CargoDelasCommand extends SlashCommand /** * The command options. * - * @var array + * @var array */ protected $options = [ [ @@ -43,7 +43,7 @@ class CargoDelasCommand extends SlashCommand /** * The permissions required to use the command. * - * @var array + * @var array */ protected $permissions = []; @@ -71,7 +71,7 @@ public function handle(Interaction $interaction): void $hasComiteRole = $interaction->member->roles ->find(fn (Role $role) => $role->id === $comiteRoleId); - if (! $hasComiteRole) { + if (!$hasComiteRole) { $interaction->respondWithMessage('❌ Você não tem permissão para usar este comando.', true); return; @@ -80,7 +80,7 @@ public function handle(Interaction $interaction): void $targetUserId = $this->value('user'); $targetMember = $this->validateTarget($interaction, $targetUserId); - if (! $targetMember instanceof Member) { + if (!$targetMember instanceof Member) { return; } @@ -111,7 +111,7 @@ private function validateTarget(Interaction $interaction, string $targetUserId): { $targetMember = $interaction->guild->members->get('id', $targetUserId); - if (! $targetMember) { + if (!$targetMember) { $interaction->respondWithMessage('❌ Usuário mencionado não foi encontrado no servidor.', true); return null; @@ -127,7 +127,7 @@ private function validateTarget(Interaction $interaction, string $targetUserId): $targetHasPresentation = $targetMember->roles ->find(fn (Role $role) => $role->id === $presentationRoleId); - if (! $targetHasPresentation) { + if (!$targetHasPresentation) { $username = $targetMember->user->username ?? 'usuário'; $interaction->respondWithMessage(sprintf('❌ @%s precisa se apresentar primeiro (/apresentar).', $username), true); diff --git a/app-modules/bot-discord/src/SlashCommands/DontAskCommand.php b/app-modules/bot-discord/src/SlashCommands/DontAskCommand.php index 9bc2490b..7fcb819f 100644 --- a/app-modules/bot-discord/src/SlashCommands/DontAskCommand.php +++ b/app-modules/bot-discord/src/SlashCommands/DontAskCommand.php @@ -42,7 +42,7 @@ class DontAskCommand extends SlashCommand /** * The slash command options. * - * @var array + * @var array */ protected $options = [ [ diff --git a/app-modules/bot-discord/src/SlashCommands/DynamicVoiceCommand.php b/app-modules/bot-discord/src/SlashCommands/DynamicVoiceCommand.php index 56c33940..6c677dcb 100644 --- a/app-modules/bot-discord/src/SlashCommands/DynamicVoiceCommand.php +++ b/app-modules/bot-discord/src/SlashCommands/DynamicVoiceCommand.php @@ -34,14 +34,14 @@ class DynamicVoiceCommand extends SlashCommand /** * The command options. * - * @var array + * @var array */ protected $options = []; /** * The permissions required to use the command. * - * @var array + * @var array */ protected $permissions = []; @@ -90,6 +90,9 @@ public function handle(Interaction $interaction): void $this->interactionWithUser($interaction, $channel); } + /** + * @return array + */ public function options(): array { return [ @@ -110,6 +113,9 @@ public function options(): array ]; } + /** + * @return array + */ private function getVoiceChoices(): array { $items = [ diff --git a/app-modules/bot-discord/src/SlashCommands/EditProfileCommand.php b/app-modules/bot-discord/src/SlashCommands/EditProfileCommand.php index 3de315e3..96a82cfb 100644 --- a/app-modules/bot-discord/src/SlashCommands/EditProfileCommand.php +++ b/app-modules/bot-discord/src/SlashCommands/EditProfileCommand.php @@ -31,14 +31,14 @@ class EditProfileCommand extends AbstractSlashCommand /** * The command options. * - * @var array + * @var array */ protected $options = []; /** * The permissions required to use the command. * - * @var array + * @var array */ protected $permissions = []; @@ -61,7 +61,7 @@ class EditProfileCommand extends AbstractSlashCommand */ public function handle(Interaction $interaction): void { - if (! $this->memberProvider?->user?->information) { + if (!$this->memberProvider?->user?->information) { $interaction->respondWithMessage( 'Parece que você ainda não completou sua apresentação. Use o comando `/apresentar` para continuar.', true @@ -122,6 +122,9 @@ public function handle(Interaction $interaction): void ->show($interaction); } + /** + * @param Collection $components + */ private function persistData( Interaction $interaction, Collection $components diff --git a/app-modules/bot-discord/src/SlashCommands/EditVoiceChannelLimitCommand.php b/app-modules/bot-discord/src/SlashCommands/EditVoiceChannelLimitCommand.php index c8bbc688..45fb0880 100644 --- a/app-modules/bot-discord/src/SlashCommands/EditVoiceChannelLimitCommand.php +++ b/app-modules/bot-discord/src/SlashCommands/EditVoiceChannelLimitCommand.php @@ -26,7 +26,7 @@ public function handle(Interaction $interaction): void $userId = $interaction->member->id; $channelId = cache()->tags(['voice_tracking'])->get('user_last_channel_'.$userId); - if (! $channelId) { + if (!$channelId) { $this->message() ->content('❌ Você precisa estar em uma sala de voz para usar este comando!') ->reply($interaction, true); @@ -37,7 +37,7 @@ public function handle(Interaction $interaction): void $activeChannels = cache()->tags(['voice_channels'])->get('active_voice_channels_keys', []); $channelDto = collect($activeChannels)->firstWhere('channelId', $channelId); - if (! $channelDto) { + if (!$channelDto) { $this->message() ->content('❌ Este comando só funciona em salas criadas com /sala!') ->reply($interaction, true); @@ -55,7 +55,7 @@ public function handle(Interaction $interaction): void $voiceChannel = $interaction->guild->channels->get('id', $channelId); - if (! $voiceChannel) { + if (!$voiceChannel) { $this->message() ->content('❌ Canal de voz não encontrado!') ->reply($interaction, true); @@ -79,6 +79,9 @@ public function handle(Interaction $interaction): void } } + /** + * @return array + */ public function options(): array { return [ diff --git a/app-modules/bot-discord/src/SlashCommands/IntroductionCommand.php b/app-modules/bot-discord/src/SlashCommands/IntroductionCommand.php index b006c9c0..62ebf1f6 100644 --- a/app-modules/bot-discord/src/SlashCommands/IntroductionCommand.php +++ b/app-modules/bot-discord/src/SlashCommands/IntroductionCommand.php @@ -25,8 +25,10 @@ class IntroductionCommand extends SlashCommand protected $description = 'Apresente-se no servidor!'; + /** @var array */ protected $options = []; + /** @var array */ protected $permissions = []; protected $admin = false; @@ -112,6 +114,9 @@ public function handle(Interaction $interaction): void ->show($interaction); } + /** + * @param Collection $components + */ private function persistData(Interaction $interaction, Collection $components): void { $tenantProvider = ExternalIdentity::query() diff --git a/app-modules/bot-discord/src/SlashCommands/ProfileCommand.php b/app-modules/bot-discord/src/SlashCommands/ProfileCommand.php index d0535a7a..fd20cd46 100644 --- a/app-modules/bot-discord/src/SlashCommands/ProfileCommand.php +++ b/app-modules/bot-discord/src/SlashCommands/ProfileCommand.php @@ -29,7 +29,7 @@ class ProfileCommand extends AbstractSlashCommand /** * The command options. * - * @var array + * @var array */ protected $options = [ [ @@ -43,7 +43,7 @@ class ProfileCommand extends AbstractSlashCommand /** * The permissions required to use the command. * - * @var array + * @var array */ protected $permissions = []; @@ -75,7 +75,7 @@ public function handle(Interaction $interaction): void try { - if (! $this->memberProvider instanceof ExternalIdentity || ! $this->memberProvider->user->information) { + if (!$this->memberProvider instanceof ExternalIdentity || !$this->memberProvider->user->information) { $this ->message() ->content($mentionedUser.' ainda não se apresentou! Use o comando `/introduction` primeiro.') diff --git a/app-modules/community/database/migrations/2022_12_07_005119_create_meeting_types_table.php b/app-modules/community/database/migrations/2022_12_07_005119_create_meeting_types_table.php index a2186173..2b3e2c5b 100644 --- a/app-modules/community/database/migrations/2022_12_07_005119_create_meeting_types_table.php +++ b/app-modules/community/database/migrations/2022_12_07_005119_create_meeting_types_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('meeting_types')) { + if (!Schema::hasTable('meeting_types')) { Schema::create('meeting_types', function (Blueprint $table): void { $table->id(); $table->string('name'); diff --git a/app-modules/community/database/migrations/2022_12_07_005347_create_meetings_table.php b/app-modules/community/database/migrations/2022_12_07_005347_create_meetings_table.php index 9fa5ed89..50fc220a 100644 --- a/app-modules/community/database/migrations/2022_12_07_005347_create_meetings_table.php +++ b/app-modules/community/database/migrations/2022_12_07_005347_create_meetings_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('meetings')) { + if (!Schema::hasTable('meetings')) { Schema::create('meetings', function (Blueprint $table): void { $table->uuid('id')->primary(); $table->foreignUuid('admin_id')->constrained('users')->cascadeOnDelete(); diff --git a/app-modules/community/database/migrations/2022_12_07_005627_create_meeting_participants_table.php b/app-modules/community/database/migrations/2022_12_07_005627_create_meeting_participants_table.php index 34aee9e0..d040ff11 100644 --- a/app-modules/community/database/migrations/2022_12_07_005627_create_meeting_participants_table.php +++ b/app-modules/community/database/migrations/2022_12_07_005627_create_meeting_participants_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('meeting_participants')) { + if (!Schema::hasTable('meeting_participants')) { Schema::create('meeting_participants', function (Blueprint $table): void { $table->foreignUuid('meeting_id')->constrained('meetings')->cascadeOnDelete(); $table->foreignUuid('user_id')->constrained('users')->cascadeOnDelete(); diff --git a/app-modules/community/phpstan.ignore.neon b/app-modules/community/phpstan.ignore.neon new file mode 100644 index 00000000..f51e71c3 --- /dev/null +++ b/app-modules/community/phpstan.ignore.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/app-modules/community/phpstan.neon b/app-modules/community/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/community/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/community/src/Feedback/Actions/CreateFeedback.php b/app-modules/community/src/Feedback/Actions/CreateFeedback.php index 4c18af49..acbc57b0 100644 --- a/app-modules/community/src/Feedback/Actions/CreateFeedback.php +++ b/app-modules/community/src/Feedback/Actions/CreateFeedback.php @@ -15,6 +15,9 @@ public function __construct( private FindExternalIdentity $findExternalIdentity ) {} + /** + * @param array $payload + */ public function handle(array $payload): Feedback { $payload = $this->transformPeopleInvolvedIds($payload); @@ -26,6 +29,10 @@ public function handle(array $payload): Feedback ]); } + /** + * @param array $payload + * @return array + */ private function transformPeopleInvolvedIds(array $payload): array { $senderIdentity = $this->findExternalIdentity->handle(IdentityProvider::Discord->value, $payload['sender_id']); diff --git a/app-modules/community/src/Feedback/DTOs/FeedbackReviewDTO.php b/app-modules/community/src/Feedback/DTOs/FeedbackReviewDTO.php index 88f54e79..8be5bef8 100644 --- a/app-modules/community/src/Feedback/DTOs/FeedbackReviewDTO.php +++ b/app-modules/community/src/Feedback/DTOs/FeedbackReviewDTO.php @@ -31,6 +31,9 @@ public static function make( ); } + /** + * @return array + */ public function jsonSerialize(): array { return [ diff --git a/app-modules/community/src/Feedback/DTOs/NewFeedbackDTO.php b/app-modules/community/src/Feedback/DTOs/NewFeedbackDTO.php index 06956d2f..81a2e79e 100644 --- a/app-modules/community/src/Feedback/DTOs/NewFeedbackDTO.php +++ b/app-modules/community/src/Feedback/DTOs/NewFeedbackDTO.php @@ -15,6 +15,9 @@ public function __construct( private string $message ) {} + /** + * @param array $payload + */ public static function make(array $payload): self { return new self( @@ -25,6 +28,9 @@ public static function make(array $payload): self ); } + /** + * @return array + */ public function jsonSerialize(): array { return [ diff --git a/app-modules/community/src/Feedback/Enums/ReviewTypeEnum.php b/app-modules/community/src/Feedback/Enums/ReviewTypeEnum.php index b1f9e121..6cce2b8a 100644 --- a/app-modules/community/src/Feedback/Enums/ReviewTypeEnum.php +++ b/app-modules/community/src/Feedback/Enums/ReviewTypeEnum.php @@ -9,6 +9,9 @@ enum ReviewTypeEnum: string case APPROVED = 'approved'; case DECLINED = 'declined'; + /** + * @return array + */ public static function getTypes(): array { return [ diff --git a/app-modules/community/src/Feedback/Exceptions/FeedbackException.php b/app-modules/community/src/Feedback/Exceptions/FeedbackException.php index 19cc9325..9931635d 100644 --- a/app-modules/community/src/Feedback/Exceptions/FeedbackException.php +++ b/app-modules/community/src/Feedback/Exceptions/FeedbackException.php @@ -6,6 +6,7 @@ use Exception; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; final class FeedbackException extends Exception @@ -15,7 +16,7 @@ public static function idNotFound(int $id): self return new self(sprintf(trans('feedbacks.exceptions.id_not_found'), $id), Response::HTTP_NOT_FOUND); } - public function render($request): JsonResponse + public function render(Request $request): JsonResponse { return response()->json($this->getMessage(), $this->code); } diff --git a/app-modules/community/src/Feedback/Http/Requests/CreateFeedbackRequest.php b/app-modules/community/src/Feedback/Http/Requests/CreateFeedbackRequest.php index 5e3a4e29..adeb3961 100644 --- a/app-modules/community/src/Feedback/Http/Requests/CreateFeedbackRequest.php +++ b/app-modules/community/src/Feedback/Http/Requests/CreateFeedbackRequest.php @@ -13,6 +13,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/community/src/Feedback/Http/Requests/FeedbackReviewRequest.php b/app-modules/community/src/Feedback/Http/Requests/FeedbackReviewRequest.php index 7bb551c5..150b73c7 100644 --- a/app-modules/community/src/Feedback/Http/Requests/FeedbackReviewRequest.php +++ b/app-modules/community/src/Feedback/Http/Requests/FeedbackReviewRequest.php @@ -14,6 +14,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/community/src/Feedback/Models/Feedback.php b/app-modules/community/src/Feedback/Models/Feedback.php index fb89e29c..b535e508 100644 --- a/app-modules/community/src/Feedback/Models/Feedback.php +++ b/app-modules/community/src/Feedback/Models/Feedback.php @@ -15,6 +15,7 @@ final class Feedback extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/community/src/Feedback/Models/Review.php b/app-modules/community/src/Feedback/Models/Review.php index a841962c..9e203e33 100644 --- a/app-modules/community/src/Feedback/Models/Review.php +++ b/app-modules/community/src/Feedback/Models/Review.php @@ -14,6 +14,7 @@ final class Review extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/community/src/Meeting/Http/Requests/MeetingRequest.php b/app-modules/community/src/Meeting/Http/Requests/MeetingRequest.php index 2f8e6433..2763edbe 100644 --- a/app-modules/community/src/Meeting/Http/Requests/MeetingRequest.php +++ b/app-modules/community/src/Meeting/Http/Requests/MeetingRequest.php @@ -13,6 +13,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/community/src/Meeting/Models/Meeting.php b/app-modules/community/src/Meeting/Models/Meeting.php index 20e3867c..994e493d 100644 --- a/app-modules/community/src/Meeting/Models/Meeting.php +++ b/app-modules/community/src/Meeting/Models/Meeting.php @@ -16,6 +16,7 @@ final class Meeting extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/community/src/Meeting/Models/MeetingType.php b/app-modules/community/src/Meeting/Models/MeetingType.php index 5a681ecf..ed829605 100644 --- a/app-modules/community/src/Meeting/Models/MeetingType.php +++ b/app-modules/community/src/Meeting/Models/MeetingType.php @@ -18,6 +18,7 @@ */ final class MeetingType extends Model { + /** @use HasFactory */ use HasFactory; protected $table = 'meeting_types'; @@ -33,6 +34,9 @@ protected static function newFactory(): MeetingTypeFactory return MeetingTypeFactory::new(); } + /** + * @return Attribute + */ protected function startAt(): Attribute { return Attribute::make( @@ -40,6 +44,9 @@ protected function startAt(): Attribute ); } + /** + * @return Attribute + */ protected function meetingDayForHumans(): Attribute { return Attribute::get(fn () => match ($this->week_day) { @@ -50,6 +57,7 @@ protected function meetingDayForHumans(): Attribute 4 => 'Quinta Feira', 5 => 'Sexta Feira', 6 => 'Sábado', + default => '', }); } diff --git a/app-modules/docs/phpstan.ignore.neon b/app-modules/docs/phpstan.ignore.neon new file mode 100644 index 00000000..18381d67 --- /dev/null +++ b/app-modules/docs/phpstan.ignore.neon @@ -0,0 +1,22 @@ +parameters: + ignoreErrors: + - message: '#^Call\ to\ function\ assert\(\)\ with\ true\ will\ always\ evaluate\ to\ true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: src/CommonMark/Markdown/GithubFlavoredMarkdownConverter.php + - message: '#^Instanceof\ between\ League\\CommonMark\\Environment\\EnvironmentInterface\ and\ League\\CommonMark\\Environment\\EnvironmentInterface\ will\ always\ evaluate\ to\ true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: src/CommonMark/Markdown/GithubFlavoredMarkdownConverter.php + - message: '#^Method\ He4rt\\Docs\\Documentation::getToc\(\)\ should\ return\ array\ but\ returns\ list\|string\|null>>\.$#' + identifier: return.type + count: 1 + path: src/Documentation.php + - message: '#^Parameter\ \#1\ \$path\ of\ function\ resource_path\ expects\ string,\ Illuminate\\Support\\Stringable\ given\.$#' + identifier: argument.type + count: 1 + path: src/Documentation.php + - message: '#^Parameter\ \#2\ \$content\ of\ static\ method\ He4rt\\Docs\\Documentation::replaceLinks\(\)\ expects\ League\\CommonMark\\Output\\RenderedContent\|string,\ League\\CommonMark\\Output\\RenderedContentInterface\ given\.$#' + identifier: argument.type + count: 2 + path: src/Documentation.php diff --git a/app-modules/docs/phpstan.neon b/app-modules/docs/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/docs/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/docs/routes/docs-routes.php b/app-modules/docs/routes/docs-routes.php index 12aa4bdf..fbacc803 100644 --- a/app-modules/docs/routes/docs-routes.php +++ b/app-modules/docs/routes/docs-routes.php @@ -5,7 +5,7 @@ use He4rt\Docs\DocsController; use Illuminate\Support\Facades\Route; -if (! defined('DEFAULT_VERSION')) { +if (!defined('DEFAULT_VERSION')) { define('DEFAULT_VERSION', '3.x'); } diff --git a/app-modules/docs/src/DocsController.php b/app-modules/docs/src/DocsController.php index 45c5543b..d1183245 100644 --- a/app-modules/docs/src/DocsController.php +++ b/app-modules/docs/src/DocsController.php @@ -35,7 +35,7 @@ public function showRootPage(): Redirector|RedirectResponse public function index($version, Documentation $docs) { - if (! $this->isVersion($version)) { + if (!$this->isVersion($version)) { return redirect('docs/'.DEFAULT_VERSION.'/index.json', 301); } @@ -50,7 +50,7 @@ public function index($version, Documentation $docs) */ public function sidebar($version, Documentation $docs) { - if (! $this->isVersion($version)) { + if (!$this->isVersion($version)) { return redirect('docs/'.DEFAULT_VERSION.'/sidebar.json', 301); } @@ -62,11 +62,11 @@ public function sidebar($version, Documentation $docs) */ public function show(string $version, ?string $page = null): RedirectResponse|View|Response { - if (! $this->isVersion($version)) { + if (!$this->isVersion($version)) { return redirect('docs/'.DEFAULT_VERSION.'/'.$version, 301); } - if (! defined('CURRENT_VERSION')) { + if (!defined('CURRENT_VERSION')) { define('CURRENT_VERSION', $version); } @@ -85,7 +85,7 @@ public function show(string $version, ?string $page = null): RedirectResponse|Vi if ($this->docs->sectionExists($version, $page)) { $section .= '/'.$page; - } elseif (! is_null($page)) { + } elseif (!is_null($page)) { return redirect('/docs/'.$version); } diff --git a/app-modules/docs/src/Documentation.php b/app-modules/docs/src/Documentation.php index ea9faf0d..bd53934e 100644 --- a/app-modules/docs/src/Documentation.php +++ b/app-modules/docs/src/Documentation.php @@ -67,6 +67,8 @@ public function getIndex(string $version) /** * Get the given documentation page. + * + * @return array|null */ public function get(string $version, string $page): ?array { @@ -90,13 +92,15 @@ public function get(string $version, string $page): ?array /** * Get the array based index representation of the documentation. + * + * @return array */ public function indexArray(string $version): array { return $this->cache->remember('docs.{'.$version.'}.index', CarbonInterval::second(1), function () use ($version): array { $path = base_path('resources/docs/'.$version.'/documentation.md'); - if (! $this->files->exists($path)) { + if (!$this->files->exists($path)) { return []; } @@ -136,6 +140,8 @@ public function sectionExists(string $version, ?string $page): bool /** * Determine which versions a page exists in. + * + * @return Collection */ public function versionsContainingPage(string $page): Collection { @@ -145,13 +151,15 @@ public function versionsContainingPage(string $page): Collection /** * Get the sidebar documentation index. + * + * @return array */ public function getPages(string $version): array { return $this->cache->remember('docs.'.$version.'.sidebar', 5, function () use ($version): array { $path = base_path('resources/docs/'.$version.'/documentation.md'); - if (! $this->files->exists($path)) { + if (!$this->files->exists($path)) { return []; } @@ -199,6 +207,9 @@ public function getPages(string $version): array }); } + /** + * @return array + */ public function getToc(string $markdown): array { $headings = []; diff --git a/app-modules/economy/phpstan.ignore.neon b/app-modules/economy/phpstan.ignore.neon new file mode 100644 index 00000000..f51e71c3 --- /dev/null +++ b/app-modules/economy/phpstan.ignore.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/app-modules/economy/phpstan.neon b/app-modules/economy/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/economy/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/economy/src/Models/Transaction.php b/app-modules/economy/src/Models/Transaction.php index b80706a4..5da419bf 100644 --- a/app-modules/economy/src/Models/Transaction.php +++ b/app-modules/economy/src/Models/Transaction.php @@ -24,6 +24,7 @@ */ final class Transaction extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/economy/src/Models/Wallet.php b/app-modules/economy/src/Models/Wallet.php index fe4a5fdd..4e75b379 100644 --- a/app-modules/economy/src/Models/Wallet.php +++ b/app-modules/economy/src/Models/Wallet.php @@ -21,6 +21,7 @@ */ final class Wallet extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/events/src/Filament/Shared/EventLogin.php b/app-modules/events/src/Filament/Shared/EventLogin.php index 9d729bf9..4cf13439 100644 --- a/app-modules/events/src/Filament/Shared/EventLogin.php +++ b/app-modules/events/src/Filament/Shared/EventLogin.php @@ -96,7 +96,7 @@ public function authenticate(): ?LoginResponse $user = $authProvider->retrieveByCredentials($credentials); - if ((! $user) || (! $authProvider->validateCredentials($user, $credentials))) { + if ((!$user) || (!$authProvider->validateCredentials($user, $credentials))) { $this->userUndertakingMultiFactorAuthentication = null; $this->fireFailedEvent($authGuard, $user, $credentials); @@ -110,7 +110,7 @@ public function authenticate(): ?LoginResponse $this->multiFactorChallengeForm->validate(); } else { foreach (Filament::getMultiFactorAuthenticationProviders() as $multiFactorAuthenticationProvider) { - if (! $multiFactorAuthenticationProvider->isEnabled($user)) { + if (!$multiFactorAuthenticationProvider->isEnabled($user)) { continue; } @@ -130,8 +130,8 @@ public function authenticate(): ?LoginResponse } } - if (! $authGuard->attemptWhen($credentials, function (Authenticatable $user): bool { - if (! ($user instanceof FilamentUser)) { + if (!$authGuard->attemptWhen($credentials, function (Authenticatable $user): bool { + if (!($user instanceof FilamentUser)) { return true; } @@ -232,7 +232,7 @@ public function getSubheading(): string|Htmlable|null return __('filament-panels::auth/pages/login.multi_factor.subheading'); } - if (! filament()->hasRegistration()) { + if (!filament()->hasRegistration()) { return null; } @@ -370,7 +370,7 @@ protected function getMultiFactorProviderFormComponent(): ?Component ->afterStateUpdated(function (?string $state) use ($enabledMultiFactorAuthenticationProviders, $section, $user): void { $provider = $enabledMultiFactorAuthenticationProviders[$state] ?? null; - if (! $provider) { + if (!$provider) { return; } @@ -380,7 +380,7 @@ protected function getMultiFactorProviderFormComponent(): ?Component ->getChildSchema() ->fill(); - if (! ($provider instanceof HasBeforeChallengeHook)) { + if (!($provider instanceof HasBeforeChallengeHook)) { return; } diff --git a/app-modules/events/src/Filament/Shared/Widgets/ActiveEventsStats.php b/app-modules/events/src/Filament/Shared/Widgets/ActiveEventsStats.php index d440e778..10c81512 100644 --- a/app-modules/events/src/Filament/Shared/Widgets/ActiveEventsStats.php +++ b/app-modules/events/src/Filament/Shared/Widgets/ActiveEventsStats.php @@ -19,13 +19,13 @@ protected function getStats(): array $query = EventModel::query()->where('active', true); - if (! $user->isAdmin()) { + if (!$user->isAdmin()) { $query->where('tenant_id', Filament::getTenant()->getKey()); } $event = $query->first(); - if (! $event) { + if (!$event) { return [ Stat::make('Evento ativo', 'Nenhum') ->description('Sem evento em andamento') diff --git a/app-modules/events/src/Models/EventModel.php b/app-modules/events/src/Models/EventModel.php index 44387e8e..b116d3c6 100644 --- a/app-modules/events/src/Models/EventModel.php +++ b/app-modules/events/src/Models/EventModel.php @@ -110,7 +110,7 @@ public function leave(mixed $userId): bool { $eventAttend = $this->attendees()->where('user_id', $userId)->first(); - if (! $eventAttend) { + if (!$eventAttend) { return false; } diff --git a/app-modules/gamification/database/migrations/2023_01_14_053138_create_characters_table.php b/app-modules/gamification/database/migrations/2023_01_14_053138_create_characters_table.php index e76a76be..1f7a694e 100644 --- a/app-modules/gamification/database/migrations/2023_01_14_053138_create_characters_table.php +++ b/app-modules/gamification/database/migrations/2023_01_14_053138_create_characters_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('characters')) { + if (!Schema::hasTable('characters')) { Schema::create('characters', function (Blueprint $table): void { $table->uuid('id')->primary(); $table->foreignUuid('user_id')->constrained('users')->cascadeOnDelete(); diff --git a/app-modules/gamification/database/migrations/2023_01_20_193234_create_badges_table.php b/app-modules/gamification/database/migrations/2023_01_20_193234_create_badges_table.php index b4f66da5..7ab9a725 100644 --- a/app-modules/gamification/database/migrations/2023_01_20_193234_create_badges_table.php +++ b/app-modules/gamification/database/migrations/2023_01_20_193234_create_badges_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('badges')) { + if (!Schema::hasTable('badges')) { Schema::create('badges', function (Blueprint $table): void { $table->id(); $table->string('provider'); diff --git a/app-modules/gamification/database/migrations/2023_01_22_152940_create_characters_badges_table.php b/app-modules/gamification/database/migrations/2023_01_22_152940_create_characters_badges_table.php index ce7279d3..cd818516 100644 --- a/app-modules/gamification/database/migrations/2023_01_22_152940_create_characters_badges_table.php +++ b/app-modules/gamification/database/migrations/2023_01_22_152940_create_characters_badges_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('characters_badges')) { + if (!Schema::hasTable('characters_badges')) { Schema::create('characters_badges', function (Blueprint $table): void { $table->foreignUuid('character_id')->constrained('characters')->cascadeOnDelete(); $table->foreignId('badge_id')->constrained('badges')->cascadeOnDelete(); diff --git a/app-modules/gamification/database/migrations/2023_01_30_174411_create_seasons_table.php b/app-modules/gamification/database/migrations/2023_01_30_174411_create_seasons_table.php index 06fba4a4..5d9a222d 100644 --- a/app-modules/gamification/database/migrations/2023_01_30_174411_create_seasons_table.php +++ b/app-modules/gamification/database/migrations/2023_01_30_174411_create_seasons_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('seasons')) { + if (!Schema::hasTable('seasons')) { Schema::create('seasons', function (Blueprint $table): void { $table->uuid('id'); $table->string('name'); diff --git a/app-modules/gamification/phpstan.ignore.neon b/app-modules/gamification/phpstan.ignore.neon new file mode 100644 index 00000000..f51e71c3 --- /dev/null +++ b/app-modules/gamification/phpstan.ignore.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/app-modules/gamification/phpstan.neon b/app-modules/gamification/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/gamification/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/gamification/src/Badge/Actions/CreateBadge.php b/app-modules/gamification/src/Badge/Actions/CreateBadge.php index f2193aef..96c9bdb0 100644 --- a/app-modules/gamification/src/Badge/Actions/CreateBadge.php +++ b/app-modules/gamification/src/Badge/Actions/CreateBadge.php @@ -10,6 +10,9 @@ { public function __construct(private PersistBadge $persistBadge) {} + /** + * @param array $payload + */ public function handle(array $payload): mixed { $newBadgeDTO = NewBadgeDTO::make($payload); diff --git a/app-modules/gamification/src/Badge/DTOs/NewBadgeDTO.php b/app-modules/gamification/src/Badge/DTOs/NewBadgeDTO.php index aace2483..719c6f3e 100644 --- a/app-modules/gamification/src/Badge/DTOs/NewBadgeDTO.php +++ b/app-modules/gamification/src/Badge/DTOs/NewBadgeDTO.php @@ -17,6 +17,9 @@ public function __construct( private int $tenant_id ) {} + /** + * @param array $payload + */ public static function make(array $payload): self { return new self( @@ -29,6 +32,9 @@ public static function make(array $payload): self ); } + /** + * @return array + */ public function jsonSerialize(): array { return [ diff --git a/app-modules/gamification/src/Badge/Http/Requests/CreateBadgeRequest.php b/app-modules/gamification/src/Badge/Http/Requests/CreateBadgeRequest.php index d981a4d2..83f33898 100644 --- a/app-modules/gamification/src/Badge/Http/Requests/CreateBadgeRequest.php +++ b/app-modules/gamification/src/Badge/Http/Requests/CreateBadgeRequest.php @@ -13,6 +13,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/gamification/src/Badge/Models/Badge.php b/app-modules/gamification/src/Badge/Models/Badge.php index 04badd3a..bba98e15 100644 --- a/app-modules/gamification/src/Badge/Models/Badge.php +++ b/app-modules/gamification/src/Badge/Models/Badge.php @@ -18,6 +18,7 @@ final class Badge extends Model implements HasMedia { + /** @use HasFactory */ use HasFactory; use InteractsWithMedia; diff --git a/app-modules/gamification/src/Character/Actions/ManageReputation.php b/app-modules/gamification/src/Character/Actions/ManageReputation.php index e796eb31..2a543459 100644 --- a/app-modules/gamification/src/Character/Actions/ManageReputation.php +++ b/app-modules/gamification/src/Character/Actions/ManageReputation.php @@ -5,6 +5,7 @@ namespace He4rt\Gamification\Character\Actions; use He4rt\Gamification\Character\Models\Character; +use InvalidArgumentException; final readonly class ManageReputation { @@ -15,6 +16,7 @@ public function handle(string $characterId, string $type): void match ($type) { 'increment' => $character->increment('reputation'), 'decrement' => $character->decrement('reputation'), + default => throw new InvalidArgumentException('Invalid reputation type: '.$type), }; } } diff --git a/app-modules/gamification/src/Character/Http/Requests/ClaimBadgeRequest.php b/app-modules/gamification/src/Character/Http/Requests/ClaimBadgeRequest.php index cbfebeb5..e76a21ae 100644 --- a/app-modules/gamification/src/Character/Http/Requests/ClaimBadgeRequest.php +++ b/app-modules/gamification/src/Character/Http/Requests/ClaimBadgeRequest.php @@ -13,6 +13,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/gamification/src/Character/Models/Character.php b/app-modules/gamification/src/Character/Models/Character.php index 38f40931..38a01ad3 100644 --- a/app-modules/gamification/src/Character/Models/Character.php +++ b/app-modules/gamification/src/Character/Models/Character.php @@ -17,18 +17,22 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\Pivot; use Illuminate\Support\Facades\Date; /** * @property int $user_id - * @property int reputation + * @property int $reputation * @property int $experience - * @property Carbon $daily_bonus_claimed_at + * @property Carbon|null $daily_bonus_claimed_at + * @property int $level + * @property float $percentage_experience + * @property bool $can_claim_daily_bonus + * @property int|null $tenant_id */ final class Character extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; use HasWallet; @@ -85,14 +89,6 @@ public function tenant(): BelongsTo return $this->belongsTo(Tenant::class); } - /** - * @return HasOne - */ - public function wallet(): HasOne - { - return $this->hasOne(Wallet::class); - } - /** * @return BelongsToMany */ @@ -129,6 +125,9 @@ protected function getRankingAttribute(): int ->first() + 1; } + /** + * @return Attribute + */ protected function level(): Attribute { return Attribute::get(function (): int { @@ -144,6 +143,9 @@ protected function level(): Attribute }); } + /** + * @return Attribute + */ protected function experienceProgress(): Attribute { return Attribute::get(function (): int { @@ -155,6 +157,9 @@ protected function experienceProgress(): Attribute }); } + /** + * @return Attribute + */ protected function percentageExperience(): Attribute { return Attribute::get(function (): float { @@ -171,15 +176,21 @@ protected function percentageExperience(): Attribute }); } + /** + * @return Attribute + */ protected function experiencePercentageRemaining(): Attribute { return Attribute::get(fn (): float => round(100.0 - $this->percentage_experience, 2)); } + /** + * @return Attribute + */ protected function canClaimDailyBonus(): Attribute { return Attribute::get(function (): bool { - if (! $this->daily_bonus_claimed_at) { + if (!$this->daily_bonus_claimed_at) { return true; } diff --git a/app-modules/gamification/src/Character/Models/PastSeason.php b/app-modules/gamification/src/Character/Models/PastSeason.php index 8aef97c7..bbae82c9 100644 --- a/app-modules/gamification/src/Character/Models/PastSeason.php +++ b/app-modules/gamification/src/Character/Models/PastSeason.php @@ -14,6 +14,7 @@ final class PastSeason extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/gamification/src/Season/Models/Season.php b/app-modules/gamification/src/Season/Models/Season.php index 45f99bd6..cbc13323 100644 --- a/app-modules/gamification/src/Season/Models/Season.php +++ b/app-modules/gamification/src/Season/Models/Season.php @@ -29,6 +29,7 @@ */ final class Season extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/he4rt/phpstan.ignore.neon b/app-modules/he4rt/phpstan.ignore.neon new file mode 100644 index 00000000..f51e71c3 --- /dev/null +++ b/app-modules/he4rt/phpstan.ignore.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/app-modules/he4rt/phpstan.neon b/app-modules/he4rt/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/he4rt/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/identity/database/migrations/2014_10_12_000000_create_users_table.php b/app-modules/identity/database/migrations/2014_10_12_000000_create_users_table.php index 07cc986f..9b2c757a 100644 --- a/app-modules/identity/database/migrations/2014_10_12_000000_create_users_table.php +++ b/app-modules/identity/database/migrations/2014_10_12_000000_create_users_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('users')) { + if (!Schema::hasTable('users')) { Schema::create('users', function (Blueprint $table): void { $table->uuid('id')->primary(); $table->string('username')->unique()->index(); diff --git a/app-modules/identity/database/migrations/2014_10_12_100000_create_password_resets_table.php b/app-modules/identity/database/migrations/2014_10_12_100000_create_password_resets_table.php index 6a23b574..6f71eb19 100644 --- a/app-modules/identity/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/app-modules/identity/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('password_resets')) { + if (!Schema::hasTable('password_resets')) { Schema::create('password_resets', function (Blueprint $table): void { $table->string('email')->primary(); $table->string('token'); diff --git a/app-modules/identity/database/migrations/2023_01_18_210724_create_providers_table.php b/app-modules/identity/database/migrations/2023_01_18_210724_create_providers_table.php index 107a9e89..79717388 100644 --- a/app-modules/identity/database/migrations/2023_01_18_210724_create_providers_table.php +++ b/app-modules/identity/database/migrations/2023_01_18_210724_create_providers_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('providers')) { + if (!Schema::hasTable('providers')) { Schema::create('providers', function (Blueprint $table): void { $table->uuid('id')->primary(); $table->foreignUuid('user_id')->constrained('users')->cascadeOnDelete(); diff --git a/app-modules/identity/database/migrations/2025_11_07_162624_create_providers_tokens_table.php b/app-modules/identity/database/migrations/2025_11_07_162624_create_providers_tokens_table.php index 8a160319..d82dcb40 100644 --- a/app-modules/identity/database/migrations/2025_11_07_162624_create_providers_tokens_table.php +++ b/app-modules/identity/database/migrations/2025_11_07_162624_create_providers_tokens_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('provider_tokens')) { + if (!Schema::hasTable('provider_tokens')) { Schema::create('provider_tokens', function (Blueprint $table): void { $table->uuid('id')->primary(); $table->foreignUuid('provider_id')->constrained('providers')->cascadeOnDelete(); diff --git a/app-modules/identity/phpstan.ignore.neon b/app-modules/identity/phpstan.ignore.neon new file mode 100644 index 00000000..05ac3ea9 --- /dev/null +++ b/app-modules/identity/phpstan.ignore.neon @@ -0,0 +1,38 @@ +parameters: + ignoreErrors: + - message: '#^Access\ to\ an\ undefined\ property\ Illuminate\\Contracts\\Auth\\Authenticatable\&Illuminate\\Database\\Eloquent\\Model::\$address\.$#' + identifier: property.notFound + count: 1 + path: src/Filament/User/Pages/UserProfile.php + - message: '#^Access\ to\ an\ undefined\ property\ Illuminate\\Contracts\\Auth\\Authenticatable\&Illuminate\\Database\\Eloquent\\Model::\$id\.$#' + identifier: property.notFound + count: 2 + path: src/Filament/User/Pages/UserProfile.php + - message: '#^Access\ to\ an\ undefined\ property\ Illuminate\\Contracts\\Auth\\Authenticatable\&Illuminate\\Database\\Eloquent\\Model::\$information\.$#' + identifier: property.notFound + count: 1 + path: src/Filament/User/Pages/UserProfile.php + - message: '#^Call\ to\ an\ undefined\ method\ Filament\\Panel::currentPanel\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Providers/IdentityServiceProvider.php + - message: '#^Call\ to\ an\ undefined\ method\ Illuminate\\Database\\Eloquent\\Model::notify\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Filament/User/Pages/UserProfile.php + - message: '#^Expression\ on\ left\ side\ of\ \?\?\ is\ not\ nullable\.$#' + identifier: nullCoalesce.expr + count: 1 + path: src/Filament/User/Pages/UserProfile.php + - message: '#^Method\ He4rt\\Identity\\Filament\\User\\Pages\\UserProfile::getRedirectUrl\(\)\ never\ returns\ string\ so\ it\ can\ be\ removed\ from\ the\ return\ type\.$#' + identifier: return.unusedType + count: 1 + path: src/Filament/User/Pages/UserProfile.php + - message: '#^Parameter\ \#1\ \$profileDTO\ of\ method\ He4rt\\Identity\\User\\Actions\\UpdateProfile::handle\(\)\ expects\ He4rt\\Identity\\User\\DTOs\\UpdateProfileDTO,\ string\ given\.$#' + identifier: argument.type + count: 1 + path: src/User/Http/Controllers/UsersController.php + - message: '#^Property\ He4rt\\Identity\\User\\Models\\User::\$username\ \(string\)\ does\ not\ accept\ Illuminate\\Support\\Stringable\.$#' + identifier: assign.propertyType + count: 1 + path: src/User/Observers/UserObserver.php diff --git a/app-modules/identity/phpstan.neon b/app-modules/identity/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/identity/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/identity/src/Auth/Actions/AuthenticateAction.php b/app-modules/identity/src/Auth/Actions/AuthenticateAction.php index 4e130725..6b65a14a 100644 --- a/app-modules/identity/src/Auth/Actions/AuthenticateAction.php +++ b/app-modules/identity/src/Auth/Actions/AuthenticateAction.php @@ -44,7 +44,7 @@ private function authenticateTenant(OAuthStateDTO $state, IdentityProvider $oaut ->where('external_account_id', $user->providerId) ->first(); - if (! $provider) { + if (!$provider) { $provider = $this->registerNewUser($user, $tenant); } @@ -60,7 +60,7 @@ private function registerNewUser(OAuthUserDTO $userDTO, Tenant $tenant): Externa ->orWhere('email', $userDTO->email) ->first(); - if (! $user) { + if (!$user) { $user = User::query()->create([ 'id' => Uuid::uuid4()->toString(), 'username' => $userDTO->username, diff --git a/app-modules/identity/src/Auth/DTOs/OAuthAccessDTO.php b/app-modules/identity/src/Auth/DTOs/OAuthAccessDTO.php index ad2c2321..e9b43483 100644 --- a/app-modules/identity/src/Auth/DTOs/OAuthAccessDTO.php +++ b/app-modules/identity/src/Auth/DTOs/OAuthAccessDTO.php @@ -15,8 +15,14 @@ public function __construct( public ?int $expiresIn ) {} + /** + * @param array $payload + */ abstract public static function make(array $payload): self; + /** + * @return array + */ final public function toDatabase(): array { return [ diff --git a/app-modules/identity/src/Auth/DTOs/OAuthStateDTO.php b/app-modules/identity/src/Auth/DTOs/OAuthStateDTO.php index ac3409eb..7646a545 100644 --- a/app-modules/identity/src/Auth/DTOs/OAuthStateDTO.php +++ b/app-modules/identity/src/Auth/DTOs/OAuthStateDTO.php @@ -25,6 +25,9 @@ public static function fromHashedString(string $state): self return new self(...json_decode(Crypt::decryptString($state), true)); } + /** + * @return array + */ public function jsonSerialize(): array { diff --git a/app-modules/identity/src/Auth/DTOs/OAuthUserDTO.php b/app-modules/identity/src/Auth/DTOs/OAuthUserDTO.php index 73d764a2..22f1ce35 100644 --- a/app-modules/identity/src/Auth/DTOs/OAuthUserDTO.php +++ b/app-modules/identity/src/Auth/DTOs/OAuthUserDTO.php @@ -18,8 +18,14 @@ public function __construct( public ?string $avatarUrl, ) {} + /** + * @param array $payload + */ abstract public static function make(OAuthAccessDTO $credentials, array $payload): self; + /** + * @return array + */ final public function toDatabase(): array { return [ diff --git a/app-modules/identity/src/ExternalIdentity/DTOs/NewProviderDTO.php b/app-modules/identity/src/ExternalIdentity/DTOs/NewProviderDTO.php index ada0d390..c9fa67ba 100644 --- a/app-modules/identity/src/ExternalIdentity/DTOs/NewProviderDTO.php +++ b/app-modules/identity/src/ExternalIdentity/DTOs/NewProviderDTO.php @@ -15,6 +15,9 @@ public function __construct( private string $externalAccountId ) {} + /** + * @return array + */ public function jsonSerialize(): array { return [ diff --git a/app-modules/identity/src/ExternalIdentity/DTOs/ResolveUserProviderDTO.php b/app-modules/identity/src/ExternalIdentity/DTOs/ResolveUserProviderDTO.php index ef1b74bf..ecc6d966 100644 --- a/app-modules/identity/src/ExternalIdentity/DTOs/ResolveUserProviderDTO.php +++ b/app-modules/identity/src/ExternalIdentity/DTOs/ResolveUserProviderDTO.php @@ -18,6 +18,9 @@ public function __construct( public ?string $avatar = null, ) {} + /** + * @param array $data + */ public static function make(array $data): self { return new self( diff --git a/app-modules/identity/src/ExternalIdentity/Enums/IdentityProvider.php b/app-modules/identity/src/ExternalIdentity/Enums/IdentityProvider.php index 79a0b4fe..837bc19f 100644 --- a/app-modules/identity/src/ExternalIdentity/Enums/IdentityProvider.php +++ b/app-modules/identity/src/ExternalIdentity/Enums/IdentityProvider.php @@ -13,7 +13,6 @@ use He4rt\Identity\Auth\DTOs\OAuthStateDTO; use He4rt\IntegrationDiscord\OAuth\DiscordOAuthClient; use He4rt\IntegrationTwitch\OAuth\Contracts\TwitchOAuthService; -use Illuminate\Contracts\Support\Htmlable; enum IdentityProvider: string implements HasColor, HasDescription, HasIcon, HasLabel { @@ -49,7 +48,7 @@ public function getLabel(): string return $this->name; } - public function getDescription(): string|Htmlable|null + public function getDescription(): string { return match ($this) { self::Discord => 'Conecte sua conta do Discord para gameficações e eventos.', @@ -57,6 +56,9 @@ public function getDescription(): string|Htmlable|null }; } + /** + * @return array + */ public function getScopes(): array { $scopes = match ($this) { diff --git a/app-modules/identity/src/ExternalIdentity/Http/Requests/CreateProviderRequest.php b/app-modules/identity/src/ExternalIdentity/Http/Requests/CreateProviderRequest.php index cbe336d1..7c736232 100644 --- a/app-modules/identity/src/ExternalIdentity/Http/Requests/CreateProviderRequest.php +++ b/app-modules/identity/src/ExternalIdentity/Http/Requests/CreateProviderRequest.php @@ -13,6 +13,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/identity/src/ExternalIdentity/Models/ExternalIdentity.php b/app-modules/identity/src/ExternalIdentity/Models/ExternalIdentity.php index 1b275084..91591568 100644 --- a/app-modules/identity/src/ExternalIdentity/Models/ExternalIdentity.php +++ b/app-modules/identity/src/ExternalIdentity/Models/ExternalIdentity.php @@ -42,6 +42,7 @@ */ final class ExternalIdentity extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; use SoftDeletes; @@ -68,6 +69,7 @@ final class ExternalIdentity extends Model 'messages_count', ]; + /** @return MorphTo */ public function model(): MorphTo { return $this->morphTo(); diff --git a/app-modules/identity/src/Filament/User/Pages/Dashboard.php b/app-modules/identity/src/Filament/User/Pages/Dashboard.php index 7592ea3c..f266bea8 100644 --- a/app-modules/identity/src/Filament/User/Pages/Dashboard.php +++ b/app-modules/identity/src/Filament/User/Pages/Dashboard.php @@ -23,7 +23,7 @@ public function mount(): void } #[Computed] - public function stats() + public function stats(): mixed { return auth()->user()->character()->where('tenant_id', '=', $this->tenant->getKey())->first(); } diff --git a/app-modules/identity/src/Filament/User/Pages/UserProfile.php b/app-modules/identity/src/Filament/User/Pages/UserProfile.php index a10efad4..8024d73e 100644 --- a/app-modules/identity/src/Filament/User/Pages/UserProfile.php +++ b/app-modules/identity/src/Filament/User/Pages/UserProfile.php @@ -60,8 +60,14 @@ class UserProfile extends Page */ public ?array $data = []; + /** + * @var array | null + */ public ?array $informationData = []; + /** + * @var array | null + */ public ?array $addressData = []; protected static bool $isDiscovered = false; @@ -224,7 +230,7 @@ public function saveAddress(): void public function defaultForm(Schema $schema): Schema { return $schema - ->inlineLabel(! self::isSimple()) + ->inlineLabel(!self::isSimple()) ->model($this->getUser()) ->operation('edit') ->statePath('data'); @@ -395,14 +401,14 @@ public function getFormContentComponent(): Form Actions::make($this->getFormActions()) ->alignment($this->getFormActionsAlignment()) ->fullWidth($this->hasFullWidthFormActions()) - ->sticky((! self::isSimple()) && $this->areFormActionsSticky()) + ->sticky((!self::isSimple()) && $this->areFormActionsSticky()) ->key('form-actions'), ]); } public function getMultiFactorAuthenticationContentComponent(): ?Component { - if (! Filament::hasMultiFactorAuthentication()) { + if (!Filament::hasMultiFactorAuthentication()) { return null; } @@ -529,7 +535,7 @@ private function getEmailChangeVerificationSentNotification(string $newEmail): F ['email' => $newEmail])); } - private function getSavedNotificationTitle(): ?string + private function getSavedNotificationTitle(): string { return __('filament-panels::auth/pages/edit-profile.notifications.saved.title'); } diff --git a/app-modules/identity/src/Tenant/Concerns/InteractsWithTenants.php b/app-modules/identity/src/Tenant/Concerns/InteractsWithTenants.php index cc70c0f5..4c4d10f4 100644 --- a/app-modules/identity/src/Tenant/Concerns/InteractsWithTenants.php +++ b/app-modules/identity/src/Tenant/Concerns/InteractsWithTenants.php @@ -28,7 +28,7 @@ public function canAccessTenant(Model $tenant): bool } /** - * @return array | Collection + * @return array|Collection */ public function getTenants(Panel $panel): array|Collection { diff --git a/app-modules/identity/src/Tenant/Models/Tenant.php b/app-modules/identity/src/Tenant/Models/Tenant.php index 471739b4..a90d2b3d 100644 --- a/app-modules/identity/src/Tenant/Models/Tenant.php +++ b/app-modules/identity/src/Tenant/Models/Tenant.php @@ -34,6 +34,7 @@ */ class Tenant extends Model { + /** @use HasFactory */ use HasFactory; use SoftDeletes; diff --git a/app-modules/identity/src/User/Actions/ResolveUserContext.php b/app-modules/identity/src/User/Actions/ResolveUserContext.php index 1df348c0..e6881f96 100644 --- a/app-modules/identity/src/User/Actions/ResolveUserContext.php +++ b/app-modules/identity/src/User/Actions/ResolveUserContext.php @@ -5,6 +5,7 @@ namespace He4rt\Identity\User\Actions; use He4rt\Gamification\Character\Actions\CharacterInitializerAction; +use He4rt\Identity\ExternalIdentity\Actions\LinkExternalIdentity; use He4rt\Identity\ExternalIdentity\Actions\ResolveExternalIdentity; use He4rt\Identity\ExternalIdentity\DTOs\ResolveUserProviderDTO; use He4rt\Identity\User\ValueObjects\UserContext; diff --git a/app-modules/identity/src/User/DTOs/UpdateProfileDTO.php b/app-modules/identity/src/User/DTOs/UpdateProfileDTO.php index d16ee1e2..f2d530a4 100644 --- a/app-modules/identity/src/User/DTOs/UpdateProfileDTO.php +++ b/app-modules/identity/src/User/DTOs/UpdateProfileDTO.php @@ -20,6 +20,9 @@ public function __construct( public ?string $about = null, ) {} + /** + * @param array $payload + */ public static function fromPayload(array $payload): self { return new self( @@ -35,6 +38,9 @@ public static function fromPayload(array $payload): self ); } + /** + * @return array + */ public function toProfile(): array { return [ diff --git a/app-modules/identity/src/User/DTOs/UpsertInformationDTO.php b/app-modules/identity/src/User/DTOs/UpsertInformationDTO.php index 2f95885d..31bf201c 100644 --- a/app-modules/identity/src/User/DTOs/UpsertInformationDTO.php +++ b/app-modules/identity/src/User/DTOs/UpsertInformationDTO.php @@ -18,6 +18,9 @@ public function __construct( public ?string $birthdate, ) {} + /** + * @param array $data + */ public static function make(array $data): self { return new self( diff --git a/app-modules/identity/src/User/Http/Controllers/UsersController.php b/app-modules/identity/src/User/Http/Controllers/UsersController.php index 57fe842b..5b5ac971 100644 --- a/app-modules/identity/src/User/Http/Controllers/UsersController.php +++ b/app-modules/identity/src/User/Http/Controllers/UsersController.php @@ -33,7 +33,7 @@ public function getProfile(string $value): JsonResponse { $user = User::query()->where('username', $value)->first(); - if (! $user) { + if (!$user) { $provider = ExternalIdentity::query()->where('external_account_id', $value)->first(); throw_unless($provider, ProfileException::notFound()); @@ -55,9 +55,9 @@ public function getProfile(string $value): JsonResponse 'username' => $user->username, 'character' => $user->character, 'connectedProviders' => $user->providers, - 'badges' => $user->character?->badges ?? [], + 'badges' => $user->character->badges ?? [], 'address' => $user->address, - 'pastSeasons' => $user->character?->pastSeasons ?? [], + 'pastSeasons' => $user->character->pastSeasons ?? [], ]); } diff --git a/app-modules/identity/src/User/Http/Requests/UpdateProfileRequest.php b/app-modules/identity/src/User/Http/Requests/UpdateProfileRequest.php index b97732ab..146d410d 100644 --- a/app-modules/identity/src/User/Http/Requests/UpdateProfileRequest.php +++ b/app-modules/identity/src/User/Http/Requests/UpdateProfileRequest.php @@ -13,6 +13,9 @@ public function authorize(): bool return true; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app-modules/identity/src/User/Models/Address.php b/app-modules/identity/src/User/Models/Address.php index c783c2e6..64ecca12 100644 --- a/app-modules/identity/src/User/Models/Address.php +++ b/app-modules/identity/src/User/Models/Address.php @@ -20,6 +20,7 @@ */ final class Address extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/identity/src/User/Models/Information.php b/app-modules/identity/src/User/Models/Information.php index adabad8a..378dd304 100644 --- a/app-modules/identity/src/User/Models/Information.php +++ b/app-modules/identity/src/User/Models/Information.php @@ -10,8 +10,18 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +/** + * @property string $name + * @property string $nickname + * @property string|null $about + * @property string|null $linkedin_url + * @property string|null $github_url + * @property string|null $birthdate + * @property int $user_id + */ final class Information extends Model { + /** @use HasFactory */ use HasFactory; use HasUuids; diff --git a/app-modules/identity/src/User/Models/User.php b/app-modules/identity/src/User/Models/User.php index 8577f715..3feada07 100644 --- a/app-modules/identity/src/User/Models/User.php +++ b/app-modules/identity/src/User/Models/User.php @@ -38,6 +38,7 @@ #[ObservedBy(UserObserver::class)] final class User extends Authenticatable implements FilamentUser, HasMedia, HasName, HasTenants { + /** @use HasFactory */ use HasFactory; use HasUuids; use InteractsWithMedia; @@ -68,7 +69,7 @@ public function address(): HasOne } /** - * @return BelongsToMany + * @return BelongsToMany */ public function events(): BelongsToMany { @@ -146,6 +147,9 @@ protected static function newFactory(): UserFactory return UserFactory::new(); } + /** + * @return Attribute + */ protected function shortName(): Attribute { return Attribute::get(function (): string { @@ -155,7 +159,10 @@ protected function shortName(): Attribute $firstName = $name->shift(); $lastName = $name->pop(); - return sprintf('%s %s', $firstName, $lastName); + /** @var string $result */ + $result = sprintf('%s %s', $firstName, $lastName); + + return $result; }); } diff --git a/app-modules/integration-discord/phpstan.ignore.neon b/app-modules/integration-discord/phpstan.ignore.neon new file mode 100644 index 00000000..f51e71c3 --- /dev/null +++ b/app-modules/integration-discord/phpstan.ignore.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/app-modules/integration-discord/phpstan.neon b/app-modules/integration-discord/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/integration-discord/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/integration-discord/src/OAuth/DiscordOAuthAccessDTO.php b/app-modules/integration-discord/src/OAuth/DiscordOAuthAccessDTO.php index acb70710..a283ffa3 100644 --- a/app-modules/integration-discord/src/OAuth/DiscordOAuthAccessDTO.php +++ b/app-modules/integration-discord/src/OAuth/DiscordOAuthAccessDTO.php @@ -8,6 +8,9 @@ final class DiscordOAuthAccessDTO extends OAuthAccessDTO { + /** + * @param array $payload + */ public static function make(array $payload): self { return new self( diff --git a/app-modules/integration-discord/src/OAuth/DiscordOAuthUser.php b/app-modules/integration-discord/src/OAuth/DiscordOAuthUser.php index 3e1ec949..395b36d6 100644 --- a/app-modules/integration-discord/src/OAuth/DiscordOAuthUser.php +++ b/app-modules/integration-discord/src/OAuth/DiscordOAuthUser.php @@ -10,6 +10,9 @@ class DiscordOAuthUser extends OAuthUserDTO { + /** + * @param array $payload + */ public static function make(OAuthAccessDTO $credentials, array $payload): OAuthUserDTO { return new self( diff --git a/app-modules/integration-twitch/phpstan.ignore.neon b/app-modules/integration-twitch/phpstan.ignore.neon new file mode 100644 index 00000000..f51e71c3 --- /dev/null +++ b/app-modules/integration-twitch/phpstan.ignore.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/app-modules/integration-twitch/phpstan.neon b/app-modules/integration-twitch/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/integration-twitch/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app-modules/integration-twitch/src/OAuth/DTO/TwitchOAuthAccessDTO.php b/app-modules/integration-twitch/src/OAuth/DTO/TwitchOAuthAccessDTO.php index 6e13ce21..6f9abdcb 100644 --- a/app-modules/integration-twitch/src/OAuth/DTO/TwitchOAuthAccessDTO.php +++ b/app-modules/integration-twitch/src/OAuth/DTO/TwitchOAuthAccessDTO.php @@ -8,6 +8,9 @@ class TwitchOAuthAccessDTO extends OAuthAccessDTO { + /** + * @param array $payload + */ public static function make(array $payload): self { return new self( diff --git a/app-modules/integration-twitch/src/OAuth/DTO/TwitchOAuthDTO.php b/app-modules/integration-twitch/src/OAuth/DTO/TwitchOAuthDTO.php index 92dcfad3..dabc795d 100644 --- a/app-modules/integration-twitch/src/OAuth/DTO/TwitchOAuthDTO.php +++ b/app-modules/integration-twitch/src/OAuth/DTO/TwitchOAuthDTO.php @@ -10,6 +10,9 @@ final class TwitchOAuthDTO extends OAuthUserDTO { + /** + * @param array $payload + */ public static function make(OAuthAccessDTO $credentials, array $payload): self { $user = $payload['data'][0]; diff --git a/app-modules/integration-twitch/src/Subscriber/Contracts/TwitchSubscribersService.php b/app-modules/integration-twitch/src/Subscriber/Contracts/TwitchSubscribersService.php index 22e0cb11..aa4ece28 100644 --- a/app-modules/integration-twitch/src/Subscriber/Contracts/TwitchSubscribersService.php +++ b/app-modules/integration-twitch/src/Subscriber/Contracts/TwitchSubscribersService.php @@ -5,8 +5,9 @@ namespace He4rt\IntegrationTwitch\Subscriber\Contracts; use He4rt\Identity\Auth\DTOs\OAuthAccessDTO; +use He4rt\IntegrationTwitch\Subscriber\DTO\TwitchSubscriberDTO; interface TwitchSubscribersService { - public function getSubscriptionState(OAuthAccessDTO $dto, string $twitchId, string $channelId); + public function getSubscriptionState(OAuthAccessDTO $dto, string $twitchId, string $channelId): ?TwitchSubscriberDTO; } diff --git a/app-modules/integration-twitch/src/Subscriber/DTO/TwitchSubscriberDTO.php b/app-modules/integration-twitch/src/Subscriber/DTO/TwitchSubscriberDTO.php index 52bc70b3..5a8cf3ea 100644 --- a/app-modules/integration-twitch/src/Subscriber/DTO/TwitchSubscriberDTO.php +++ b/app-modules/integration-twitch/src/Subscriber/DTO/TwitchSubscriberDTO.php @@ -18,6 +18,9 @@ public function __construct( public ?string $gifterName = null, ) {} + /** + * @param array $payload + */ public static function make(array $payload): self { return new self( diff --git a/app-modules/panel-admin/src/Filament/Resources/ExternalIdentities/Schemas/ExternalIdentityForm.php b/app-modules/panel-admin/src/Filament/Resources/ExternalIdentities/Schemas/ExternalIdentityForm.php index 04735504..2888c13c 100644 --- a/app-modules/panel-admin/src/Filament/Resources/ExternalIdentities/Schemas/ExternalIdentityForm.php +++ b/app-modules/panel-admin/src/Filament/Resources/ExternalIdentities/Schemas/ExternalIdentityForm.php @@ -36,7 +36,7 @@ public static function configure(Schema $schema): Schema Placeholder::make('status') ->label('Connection Status') ->content(function (?ExternalIdentity $record): string { - if (! $record instanceof ExternalIdentity) { + if (!$record instanceof ExternalIdentity) { return '-'; } diff --git a/app-modules/panel-admin/src/Filament/Resources/Feedback/Tables/FeedbackTable.php b/app-modules/panel-admin/src/Filament/Resources/Feedback/Tables/FeedbackTable.php index 7dd107bb..4e623e4c 100644 --- a/app-modules/panel-admin/src/Filament/Resources/Feedback/Tables/FeedbackTable.php +++ b/app-modules/panel-admin/src/Filament/Resources/Feedback/Tables/FeedbackTable.php @@ -56,7 +56,7 @@ public static function configure(Table $table): Table 'declined' => 'Declined', ]) ->query(function ($query, array $data) { - if (! $data['value']) { + if (!$data['value']) { return $query; } diff --git a/app-modules/portal/phpstan.ignore.neon b/app-modules/portal/phpstan.ignore.neon new file mode 100644 index 00000000..f51e71c3 --- /dev/null +++ b/app-modules/portal/phpstan.ignore.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/app-modules/portal/phpstan.neon b/app-modules/portal/phpstan.neon new file mode 100644 index 00000000..b577d0f2 --- /dev/null +++ b/app-modules/portal/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - phpstan.ignore.neon + +parameters: + paths: + - src/ diff --git a/app/Http/Middleware/BotAuthentication.php b/app/Http/Middleware/BotAuthentication.php index 0272439d..652151ef 100644 --- a/app/Http/Middleware/BotAuthentication.php +++ b/app/Http/Middleware/BotAuthentication.php @@ -14,7 +14,7 @@ public function handle(Request $request, Closure $next): Response { $apiKey = $request->header('X-He4rt-Authorization'); - if (! $apiKey) { + if (!$apiKey) { return response()->json(['error' => 'Chave não encontrada'], Response::HTTP_UNAUTHORIZED); } diff --git a/app/Http/Middleware/GuestTenantIdentifier.php b/app/Http/Middleware/GuestTenantIdentifier.php index dd09ff70..c6ad5995 100644 --- a/app/Http/Middleware/GuestTenantIdentifier.php +++ b/app/Http/Middleware/GuestTenantIdentifier.php @@ -20,11 +20,11 @@ public function handle(Request $request, Closure $next): Response { $panel = Filament::getCurrentOrDefaultPanel(); - if (! $panel->hasTenancy()) { + if (!$panel->hasTenancy()) { return $next($request); } - if (! $request->route()->hasParameter('tenant')) { + if (!$request->route()->hasParameter('tenant')) { return $next($request); } diff --git a/app/Http/Middleware/VerifyIfHasTenantProviderMiddleware.php b/app/Http/Middleware/VerifyIfHasTenantProviderMiddleware.php index c30a8950..65690ac1 100644 --- a/app/Http/Middleware/VerifyIfHasTenantProviderMiddleware.php +++ b/app/Http/Middleware/VerifyIfHasTenantProviderMiddleware.php @@ -15,13 +15,13 @@ final class VerifyIfHasTenantProviderMiddleware { public function handle(Request $request, Closure $next): mixed { - if (! $request->hasHeader('X-He4rt-Provider') || ! $request->hasHeader('X-He4rt-Provider-Id')) { + if (!$request->hasHeader('X-He4rt-Provider') || !$request->hasHeader('X-He4rt-Provider-Id')) { return response()->json(['error' => 'Provider not registered for any tenant.'], Response::HTTP_UNAUTHORIZED); } $provider = IdentityProvider::tryFrom($request->header('X-He4rt-Provider') ?? 'not-found'); - if (! $provider) { + if (!$provider) { return response()->json(['error' => 'Provider not registered for any tenant.'], Response::HTTP_UNAUTHORIZED); } @@ -34,7 +34,7 @@ public function handle(Request $request, Closure $next): mixed ->first() ); - if (! $providerModel) { + if (!$providerModel) { return response()->json(['error' => 'Provider not registered for any tenant.'], Response::HTTP_UNAUTHORIZED); } diff --git a/app/Providers/FilamentServiceProvider.php b/app/Providers/FilamentServiceProvider.php index 06fb813b..fabd3b0b 100644 --- a/app/Providers/FilamentServiceProvider.php +++ b/app/Providers/FilamentServiceProvider.php @@ -31,7 +31,7 @@ private function configureMacros(): void $themeDirectory = sprintf('app-modules/he4rt/resources/css/themes/%s/theme.css', $tenantSlug); - if (! file_exists(base_path($themeDirectory))) { + if (!file_exists(base_path($themeDirectory))) { $themeDirectory = 'app-modules/he4rt/resources/css/theme.css'; } diff --git a/app/Providers/Tools/DebugbarServiceProvider.php b/app/Providers/Tools/DebugbarServiceProvider.php index b5d0946e..9cc97834 100644 --- a/app/Providers/Tools/DebugbarServiceProvider.php +++ b/app/Providers/Tools/DebugbarServiceProvider.php @@ -11,7 +11,7 @@ class DebugbarServiceProvider extends ServiceProvider { public function boot(Dispatcher $events): void { - if (! $this->canBoot()) { + if (!$this->canBoot()) { return; } diff --git a/app/Providers/Tools/TelescopeServiceProvider.php b/app/Providers/Tools/TelescopeServiceProvider.php index c7a5a8ea..b59592bf 100644 --- a/app/Providers/Tools/TelescopeServiceProvider.php +++ b/app/Providers/Tools/TelescopeServiceProvider.php @@ -24,7 +24,7 @@ public function register(): void public function boot(): void { - if (! $this->canBoot()) { + if (!$this->canBoot()) { return; } diff --git a/app/Rules/AvailableTalkSchedule.php b/app/Rules/AvailableTalkSchedule.php index f59d16f5..eb9ac184 100644 --- a/app/Rules/AvailableTalkSchedule.php +++ b/app/Rules/AvailableTalkSchedule.php @@ -32,7 +32,7 @@ public function validate(string $attribute, mixed $value, Closure $fail): void ->availableHours(start: $start, end: $end) ->exists(); - if (! $isAvailable) { + if (!$isAvailable) { $fail(sprintf('O Horário %s até %s não está disponível.', $end, $start)); } } diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index dd3dd44f..59e97ffe 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -2,7 +2,7 @@ declare(strict_types=1); -if (! function_exists('modules_path')) { +if (!function_exists('modules_path')) { /** * Get the path to the modules' folder. * diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index 1ffa1abd..e9726367 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('failed_jobs')) { + if (!Schema::hasTable('failed_jobs')) { Schema::create('failed_jobs', function (Blueprint $table): void { $table->id(); $table->string('uuid')->unique(); diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php index 7eea5d4e..a03de20c 100644 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - if (! Schema::hasTable('personal_access_tokens')) { + if (!Schema::hasTable('personal_access_tokens')) { Schema::create('personal_access_tokens', function (Blueprint $table): void { $table->id(); $table->morphs('tokenable'); diff --git a/database/migrations/2026_03_21_192333_convert_morph_types_to_aliases.php b/database/migrations/2026_03_21_192333_convert_morph_types_to_aliases.php index 59dc2723..5640970d 100644 --- a/database/migrations/2026_03_21_192333_convert_morph_types_to_aliases.php +++ b/database/migrations/2026_03_21_192333_convert_morph_types_to_aliases.php @@ -62,7 +62,7 @@ public function up(): void { foreach (self::TABLES as $table => $column) { - if (! Schema::hasTable($table)) { + if (!Schema::hasTable($table)) { continue; } @@ -89,7 +89,7 @@ public function down(): void ]; foreach (self::TABLES as $table => $column) { - if (! Schema::hasTable($table)) { + if (!Schema::hasTable($table)) { continue; } diff --git a/database/migrations/2026_03_21_200000_cleanup_orphan_users.php b/database/migrations/2026_03_21_200000_cleanup_orphan_users.php index 42cf806b..a265a5a7 100644 --- a/database/migrations/2026_03_21_200000_cleanup_orphan_users.php +++ b/database/migrations/2026_03_21_200000_cleanup_orphan_users.php @@ -49,7 +49,7 @@ public function up(): void $orphanInfo = DB::table('user_information')->where('user_id', $orphanId)->first(); $keptInfo = DB::table('user_information')->where('user_id', $keptId)->first(); - if (! $orphanInfo || ! $keptInfo) { + if (!$orphanInfo || !$keptInfo) { continue; } diff --git a/database/migrations/2026_03_22_000001_normalize_linkedin_urls.php b/database/migrations/2026_03_22_000001_normalize_linkedin_urls.php index 3e948bdf..d4d8ee23 100644 --- a/database/migrations/2026_03_22_000001_normalize_linkedin_urls.php +++ b/database/migrations/2026_03_22_000001_normalize_linkedin_urls.php @@ -126,7 +126,7 @@ private function tryFixUrl(string $lower): ?string if (preg_match('#^https?://(?:www\.)?linkedin\.com/([\w\-]{3,})$#', $lower, $m)) { $path = $m[1]; - if (! in_array($path, ['feed', 'jobs', 'company', 'me', 'messaging', 'notifications', 'search'], true)) { + if (!in_array($path, ['feed', 'jobs', 'company', 'me', 'messaging', 'notifications', 'search'], true)) { return 'https://linkedin.com/in/'.$path; } } diff --git a/pint.json b/pint.json index a6aeb1df..b5a99f21 100644 --- a/pint.json +++ b/pint.json @@ -15,11 +15,7 @@ "final_internal_class": false, "final_public_method_for_abstract_class": false, "fully_qualified_strict_types": true, - "global_namespace_import": { - "import_classes": true, - "import_constants": true, - "import_functions": true - }, + "global_namespace_import": { "import_classes": true, "import_constants": true, "import_functions": true }, "mb_str_functions": true, "modernize_types_casting": true, "new_with_parentheses": false, @@ -58,14 +54,12 @@ "self_static_accessor": true, "strict_comparison": true, "visibility_required": true, - "class_attributes_separation": { - "elements": { - "method": "one" - } - }, + "class_attributes_separation": { "elements": { "method": "one" } }, "no_empty_comment": true, "declare_parentheses": true, "assign_null_coalescing_to_coalesce_equal": true, - "align_multiline_comment": true + "align_multiline_comment": true, + "not_operator_with_successor_space": false, + "unary_operator_spaces": true } }