Lint
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2023-06-15 00:33:13 +02:00
parent a434388bcb
commit d38989f302
12 changed files with 85 additions and 10 deletions

View File

@ -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<int, MailEntry>
*/
public function getResults(Maildispatcher $dispatcher): Collection
{
return Member::search(data_get($dispatcher->filter, 'search', ''))->query(

View File

@ -33,6 +33,9 @@ class StoreAction
];
}
/**
* @return array<string, string>
*/
public function rules(): array
{
return [

View File

@ -33,6 +33,9 @@ class UpdateAction
];
}
/**
* @return array<string, string>
*/
public function rules(): array
{
return [

View File

@ -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);
}
}

View File

@ -29,6 +29,9 @@ class Maildispatcher extends Model
});
}
/**
* @return BelongsTo<Mailgateway, self>
*/
public function gateway(): BelongsTo
{
return $this->belongsTo(Mailgateway::class);

View File

@ -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<string, mixed>
*/
public function toArray($request)
{

View File

@ -9,6 +9,9 @@ use Lorisleiva\Actions\ActionRequest;
trait ValidatesRequests
{
/**
* @param array<string, mixed> $input
*/
public function checkIfWorks(array $input): void
{
if (!app(data_get($input, 'type.cls'))->setParams($input['type']['params'])->works()) {

View File

@ -2,8 +2,12 @@
namespace App\Mailgateway\Casts;
use App\Mailgateway\Types\Type;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
/**
* @implements CastsAttributes<Type, Type>
*/
class TypeCast implements CastsAttributes
{
/**
@ -11,6 +15,7 @@ class TypeCast implements CastsAttributes
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param mixed $value
* @param array<string, mixed> $attributes
*
* @return mixed
*/
@ -26,6 +31,7 @@ class TypeCast implements CastsAttributes
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param mixed $value
* @param array<string, mixed> $attributes
*
* @return mixed
*/

View File

@ -18,7 +18,7 @@ class MailgatewayResource extends JsonResource
*
* @param \Illuminate\Http\Request $request
*
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
* @return array<string, mixed>
*/
public function toArray($request)
{
@ -35,6 +35,9 @@ class MailgatewayResource extends JsonResource
];
}
/**
* @return array<string, mixed>
*/
public static function meta(): array
{
return [

View File

@ -32,6 +32,9 @@ abstract class Type
*/
abstract public function setParams(array $params): static;
/**
* @return array<string, string>
*/
public static function defaults(): array
{
return collect(static::fields())->mapWithKeys(fn ($field) => [
@ -39,6 +42,9 @@ abstract class Type
])->toArray();
}
/**
* @return array<int, MailgatewayParsedCustomField>
*/
public static function presentFields(string $validator): array
{
return array_map(fn ($field) => [
@ -47,6 +53,9 @@ abstract class Type
], static::fields());
}
/**
* @return array<string, mixed>
*/
public static function rules(string $validator): array
{
return collect(static::fields())->mapWithKeys(fn ($field) => [
@ -54,6 +63,9 @@ abstract class Type
])->toArray();
}
/**
* @return array<string, array<string, mixed>>
*/
public function toResource(): array
{
return [

View File

@ -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

View File

@ -19,6 +19,7 @@ parameters:
ContributionRequestArray: 'array{dateFrom: string, dateUntil: string, zipLocation: string, country: int, eventName: string, members: array<int, int>}'
ContributionApiRequestArray: 'array{dateFrom: string, dateUntil: string, zipLocation: string, country: int, eventName: string, member_data: array<int, ContributionMemberData>}'
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\\<int,class\\-string\\<App\\\\Setting\\\\LocalSettings\\>\\>\\:\\: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\\<int, App\\\\Member\\\\Member\\> 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