diff --git a/app/Maildispatcher/Actions/ResyncAction.php b/app/Maildispatcher/Actions/ResyncAction.php index a357fdef..671d2434 100644 --- a/app/Maildispatcher/Actions/ResyncAction.php +++ b/app/Maildispatcher/Actions/ResyncAction.php @@ -13,13 +13,16 @@ class ResyncAction { use AsAction; - public function handle() + public function handle(): void { foreach (Maildispatcher::get() as $dispatcher) { $dispatcher->gateway->type->sync($dispatcher->name, $dispatcher->gateway->domain, $this->getResults($dispatcher)); } } + /** + * @return Collection + */ public function getResults(Maildispatcher $dispatcher): Collection { return Member::search(data_get($dispatcher->filter, 'search', ''))->query( diff --git a/app/Maildispatcher/Actions/StoreAction.php b/app/Maildispatcher/Actions/StoreAction.php index d558453f..7ce74ce4 100644 --- a/app/Maildispatcher/Actions/StoreAction.php +++ b/app/Maildispatcher/Actions/StoreAction.php @@ -33,6 +33,9 @@ class StoreAction ]; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app/Maildispatcher/Actions/UpdateAction.php b/app/Maildispatcher/Actions/UpdateAction.php index 5f1bfaaf..574188ed 100644 --- a/app/Maildispatcher/Actions/UpdateAction.php +++ b/app/Maildispatcher/Actions/UpdateAction.php @@ -33,6 +33,9 @@ class UpdateAction ]; } + /** + * @return array + */ public function rules(): array { return [ diff --git a/app/Maildispatcher/Models/Localmaildispatcher.php b/app/Maildispatcher/Models/Localmaildispatcher.php index 2df6c8cf..476bb574 100644 --- a/app/Maildispatcher/Models/Localmaildispatcher.php +++ b/app/Maildispatcher/Models/Localmaildispatcher.php @@ -5,7 +5,6 @@ namespace App\Maildispatcher\Models; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; class Localmaildispatcher extends Model { @@ -15,9 +14,4 @@ class Localmaildispatcher extends Model public $guarded = []; public $timestamps = false; - - public function dispatcher(): BelongsTo - { - return $this->belongsTo(Maildispatcher::class); - } } diff --git a/app/Maildispatcher/Models/Maildispatcher.php b/app/Maildispatcher/Models/Maildispatcher.php index f67ef411..b8246a16 100644 --- a/app/Maildispatcher/Models/Maildispatcher.php +++ b/app/Maildispatcher/Models/Maildispatcher.php @@ -29,6 +29,9 @@ class Maildispatcher extends Model }); } + /** + * @return BelongsTo + */ public function gateway(): BelongsTo { return $this->belongsTo(Mailgateway::class); diff --git a/app/Maildispatcher/Resources/MaildispatcherResource.php b/app/Maildispatcher/Resources/MaildispatcherResource.php index 949c3f2b..7250d916 100644 --- a/app/Maildispatcher/Resources/MaildispatcherResource.php +++ b/app/Maildispatcher/Resources/MaildispatcherResource.php @@ -3,12 +3,16 @@ namespace App\Maildispatcher\Resources; use App\Lib\HasMeta; +use App\Maildispatcher\Models\Maildispatcher; use App\Mailgateway\Models\Mailgateway; use App\Mailgateway\Resources\MailgatewayResource; use App\Member\FilterScope; use App\Member\Member; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @mixin Maildispatcher + */ class MaildispatcherResource extends JsonResource { use HasMeta; @@ -18,7 +22,7 @@ class MaildispatcherResource extends JsonResource * * @param \Illuminate\Http\Request $request * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @return array */ public function toArray($request) { diff --git a/app/Mailgateway/Actions/ValidatesRequests.php b/app/Mailgateway/Actions/ValidatesRequests.php index 8397ea3b..50df8bf0 100644 --- a/app/Mailgateway/Actions/ValidatesRequests.php +++ b/app/Mailgateway/Actions/ValidatesRequests.php @@ -9,6 +9,9 @@ use Lorisleiva\Actions\ActionRequest; trait ValidatesRequests { + /** + * @param array $input + */ public function checkIfWorks(array $input): void { if (!app(data_get($input, 'type.cls'))->setParams($input['type']['params'])->works()) { diff --git a/app/Mailgateway/Casts/TypeCast.php b/app/Mailgateway/Casts/TypeCast.php index 8f9bc9e2..7fa30867 100644 --- a/app/Mailgateway/Casts/TypeCast.php +++ b/app/Mailgateway/Casts/TypeCast.php @@ -2,8 +2,12 @@ namespace App\Mailgateway\Casts; +use App\Mailgateway\Types\Type; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; +/** + * @implements CastsAttributes + */ class TypeCast implements CastsAttributes { /** @@ -11,6 +15,7 @@ class TypeCast implements CastsAttributes * * @param \Illuminate\Database\Eloquent\Model $model * @param mixed $value + * @param array $attributes * * @return mixed */ @@ -26,6 +31,7 @@ class TypeCast implements CastsAttributes * * @param \Illuminate\Database\Eloquent\Model $model * @param mixed $value + * @param array $attributes * * @return mixed */ diff --git a/app/Mailgateway/Resources/MailgatewayResource.php b/app/Mailgateway/Resources/MailgatewayResource.php index 3328a867..7816220c 100644 --- a/app/Mailgateway/Resources/MailgatewayResource.php +++ b/app/Mailgateway/Resources/MailgatewayResource.php @@ -18,7 +18,7 @@ class MailgatewayResource extends JsonResource * * @param \Illuminate\Http\Request $request * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @return array */ public function toArray($request) { @@ -35,6 +35,9 @@ class MailgatewayResource extends JsonResource ]; } + /** + * @return array + */ public static function meta(): array { return [ diff --git a/app/Mailgateway/Types/Type.php b/app/Mailgateway/Types/Type.php index b9dc60d8..cab82bda 100644 --- a/app/Mailgateway/Types/Type.php +++ b/app/Mailgateway/Types/Type.php @@ -32,6 +32,9 @@ abstract class Type */ abstract public function setParams(array $params): static; + /** + * @return array + */ public static function defaults(): array { return collect(static::fields())->mapWithKeys(fn ($field) => [ @@ -39,6 +42,9 @@ abstract class Type ])->toArray(); } + /** + * @return array + */ public static function presentFields(string $validator): array { return array_map(fn ($field) => [ @@ -47,6 +53,9 @@ abstract class Type ], static::fields()); } + /** + * @return array + */ public static function rules(string $validator): array { return collect(static::fields())->mapWithKeys(fn ($field) => [ @@ -54,6 +63,9 @@ abstract class Type ])->toArray(); } + /** + * @return array> + */ public function toResource(): array { return [ diff --git a/app/Mailman/Support/MailmanService.php b/app/Mailman/Support/MailmanService.php index 46a82250..bcaaa4ad 100644 --- a/app/Mailman/Support/MailmanService.php +++ b/app/Mailman/Support/MailmanService.php @@ -85,7 +85,7 @@ class MailmanService { $response = $this->http()->delete("members/{$member->memberId}"); - throw_unless($response->status(204), MailmanServiceException::class, 'Removing member failed'); + throw_unless(204 === $response->status(), MailmanServiceException::class, 'Removing member failed'); } private function http(): PendingRequest diff --git a/phpstan.neon b/phpstan.neon index a30b1e9d..d0d6e83c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -19,6 +19,7 @@ parameters: ContributionRequestArray: 'array{dateFrom: string, dateUntil: string, zipLocation: string, country: int, eventName: string, members: array}' ContributionApiRequestArray: 'array{dateFrom: string, dateUntil: string, zipLocation: string, country: int, eventName: string, member_data: array}' MailgatewayCustomField: 'array{name: string, label: string, type: string, storeValidator: string, updateValidator: string, default: string}' + MailgatewayParsedCustomField: 'array{name: string, label: string, type: string, storeValidator: string, updateValidator: string, default: string, is_required: bool}' ignoreErrors: - @@ -634,3 +635,43 @@ parameters: message: "#^Return type of call to method Illuminate\\\\Support\\\\Collection\\\\>\\:\\:map\\(\\) contains unresolvable type\\.$#" count: 1 path: app/Setting/SettingFactory.php + + - + message: "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:\\$email\\.$#" + count: 2 + path: app/Maildispatcher/Actions/ResyncAction.php + + - + message: "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:\\$email_parents\\.$#" + count: 2 + path: app/Maildispatcher/Actions/ResyncAction.php + + - + message: "#^Unable to resolve the template type TKey in call to function collect$#" + count: 2 + path: app/Mailgateway/Actions/StoreAction.php + + - + message: "#^Unable to resolve the template type TValue in call to function collect$#" + count: 2 + path: app/Mailgateway/Actions/StoreAction.php + + - + message: "#^Unable to resolve the template type TKey in call to function collect$#" + count: 2 + path: app/Mailgateway/Actions/UpdateAction.php + + - + message: "#^Unable to resolve the template type TValue in call to function collect$#" + count: 2 + path: app/Mailgateway/Actions/UpdateAction.php + + - + message: "#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:map\\(\\) contains unresolvable type\\.$#" + count: 1 + path: app/Mailgateway/Resources/MailgatewayResource.php + + - + message: "#^Generic type Illuminate\\\\Pagination\\\\LengthAwarePaginator\\ in PHPDoc tag @return specifies 2 template types, but class Illuminate\\\\Pagination\\\\LengthAwarePaginator supports only 1\\: TValue$#" + count: 1 + path: app/Member/Actions/SearchAction.php