Skip to content

Commit

Permalink
Fix the CI (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar authored Jul 3, 2024
1 parent b518cd6 commit c208842
Show file tree
Hide file tree
Showing 27 changed files with 155 additions and 17 deletions.
1 change: 1 addition & 0 deletions composer-dependency-analyser.php → depcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
])
->ignoreErrorsOnPackage('contao/newsletter-bundle', [ErrorType::DEV_DEPENDENCY_IN_PROD]) // This is an optional integration
->ignoreErrorsOnPackage('psr/log', [ErrorType::SHADOW_DEPENDENCY]) // Logging is optional
->ignoreErrorsOnPackage('symfony/translation', [ErrorType::SHADOW_DEPENDENCY]) // The LocaleSwitcher is optional
;
5 changes: 4 additions & 1 deletion src/BulkyItem/BulkyItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ public function getName(): string;

/**
* Optional meta data to an item. Must be serializable.
*
* @return array<mixed>
*/
public function getMeta(): array;

/**
* Restores the item from the storage.
*
* @param resource $contents
* @param resource $contents
* @param array<mixed> $meta
*/
public static function restore($contents, array $meta): self;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function __invoke(ModuleModel $model, string $section): Response
return new Response($this->generate());
}

/**
* @param array<int> $arrNew
*/
protected function addRecipient($strEmail, $arrNew): void
{
// Remove old subscriptions that have not been activated yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function __invoke(ModuleModel $model, string $section): Response
return new Response($this->generate());
}

/**
* @param array<int> $arrRemove
*/
protected function removeRecipient($strEmail, $arrRemove): void
{
// Remove the subscriptions
Expand Down
3 changes: 3 additions & 0 deletions src/Controller/FrontendModule/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function __invoke(ModuleModel $model, string $section): Response
return new Response($this->generate());
}

/**
* @param array<mixed> $arrData
*/
protected function sendActivationMail($arrData): void
{
$optInToken = null;
Expand Down
15 changes: 8 additions & 7 deletions src/EventListener/AdminEmailTokenListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public function onCreateParcel(CreateParcelEvent $event): void
;
}

/**
* @return array<string>|null
*/
private function getEmailFromPage(): array|null
{
if (null === ($request = $this->requestStack->getCurrentRequest())) {
Expand All @@ -72,23 +75,21 @@ private function getEmailFromPage(): array|null

$pageModel->loadDetails();

return $pageModel->adminEmail ? $this->parseFriendlyEmail($pageModel->adminEmail) : null;
return $pageModel->adminEmail ? StringUtil::splitFriendlyEmail($pageModel->adminEmail) : null;
}

/**
* @return array<string>|null
*/
private function getEmailFromConfig(): array|null
{
$email = $this->contaoFramework->getAdapter(Config::class)->get('adminEmail');

return $email ? $this->parseFriendlyEmail($email) : null;
return $email ? StringUtil::splitFriendlyEmail($email) : null;
}

private function getTokenDefinition(string $token): TokenDefinitionInterface
{
return $this->tokenDefinitionFactory->create(EmailTokenDefinition::class, $token, $token);
}

private function parseFriendlyEmail(string $email): array
{
return $this->contaoFramework->getAdapter(StringUtil::class)->splitFriendlyEmail($email);
}
}
3 changes: 3 additions & 0 deletions src/EventListener/Backend/DataContainer/MessageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function __construct(
) {
}

/**
* @param array<string, mixed> $row
*/
#[AsCallback(table: 'tl_nc_message', target: 'list.sorting.child_record')]
public function onChildRecordCallback(array $row): string
{
Expand Down
7 changes: 7 additions & 0 deletions src/EventListener/Newsletter/ActivationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public function __construct(
) {
}

/**
* @param array<int> $recipientIds
* @param array<int> $channelIds
*/
public function __invoke(string $email, array $recipientIds, array $channelIds, Module $module): void
{
if (!$module instanceof ModuleSubscribe) {
Expand All @@ -43,6 +47,9 @@ public function __invoke(string $email, array $recipientIds, array $channelIds,
}
}

/**
* @param array<int> $channelIds
*/
private function sendNotification(string $email, array $channelIds, Module $module): void
{
$this->contaoFramework->initialize();
Expand Down
6 changes: 6 additions & 0 deletions src/EventListener/UpdatePersonalDataListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function storePersonalData(): void
$request->getSession()->set(self::OLD_SESSION_DATA_KEY, $user->getData());
}

/**
* @param array<int|string> $data
*/
#[AsHook('updatePersonalData')]
public function updatePersonalData(FrontendUser $member, array $data, Module $module): void
{
Expand Down Expand Up @@ -95,6 +98,9 @@ public function updatePersonalData(FrontendUser $member, array $data, Module $mo
$this->notificationCenter->sendNotification((int) $module->nc_notification, $tokens);
}

/**
* @param array<int|string, array{before: mixed, after: mixed}> $changes
*/
private function renderChanges(array $changes, string $format): string
{
if (0 === \count($changes)) {
Expand Down
3 changes: 3 additions & 0 deletions src/Exception/InvalidTokenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

class InvalidTokenException extends \InvalidArgumentException implements ExceptionInterface
{
/**
* @param array<string> $allowedTypes
*/
public static function becauseOfIncorrectType(array $allowedTypes, string $wrongType, int $code = 0, \Throwable|null $previous = null): self
{
return new self(sprintf('Cannot create a token from raw value. Must be one of "%s". "%s" given.', implode('|', $allowedTypes), $wrongType), $code, $previous);
Expand Down
8 changes: 6 additions & 2 deletions src/NotificationCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@ public function sealParcel(GatewayInterface $gateway, Parcel $parcel): Parcel
/**
* Shortcut to send an entire set of messages that belong to the same notification.
*
* @param string|null $locale The locale for the message. Passing none will try to automatically take
* the one of the current request.
* @param TokenCollection|array<string, mixed> $tokens
* @param string|null $locale The locale for the message. Passing none will try to automatically take
* the one of the current request.
*
* @throws CouldNotCreateParcelException in case the notification ID does not exist
*/
Expand All @@ -344,6 +345,9 @@ public function sendNotificationWithStamps(int $id, StampCollection $stamps): Re
return $collection;
}

/**
* @param TokenCollection|array<string, mixed> $tokens
*/
public function createBasicStampsForNotification(int $id, TokenCollection|array $tokens, string|null $locale = null): StampCollection
{
$notificationConfig = $this->configLoader->loadNotification($id);
Expand Down
9 changes: 9 additions & 0 deletions src/Parcel/Parcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public function hasStamps(array $classes): bool
return true;
}

/**
* @return array<class-string<StampInterface>>
*/
public function getStampClasses(): array
{
return $this->stampsBeforeSealing->getClasses();
Expand Down Expand Up @@ -112,6 +115,9 @@ public static function fromSerialized(string $serialized): self
return self::fromArray(Json::utf8SafeDecode($serialized));
}

/**
* @return array{messageConfig: array<string, mixed>, stampsBeforeSealing: array<class-string<StampInterface>, array<mixed>>, stampsAfterSealing: array<class-string<StampInterface>, array<mixed>>, sealed: bool}
*/
public function toArray(): array
{
return [
Expand Down Expand Up @@ -142,6 +148,9 @@ public function unseal(): self
return $parcel;
}

/**
* @param array{messageConfig: array<string, mixed>, stampsBeforeSealing: array<class-string<StampInterface>, array<mixed>>, stampsAfterSealing: array<class-string<StampInterface>, array<mixed>>, sealed: bool} $data
*/
public static function fromArray(array $data): self
{
$parcel = new self(
Expand Down
9 changes: 9 additions & 0 deletions src/Parcel/Stamp/BulkyItemsStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class BulkyItemsStamp implements StampInterface
{
/**
* @var array<string>
*/
private array $vouchers = [];

/**
Expand All @@ -30,6 +33,9 @@ public function get(string $voucher): string|null
return $this->vouchers[$voucher] ?? null;
}

/**
* @return array<string>
*/
public function toArray(): array
{
return array_values($this->vouchers);
Expand All @@ -40,6 +46,9 @@ public static function fromArray(array $data): self
return new self($data);
}

/**
* @return array<string>
*/
public function all(): array
{
return $this->toArray();
Expand Down
3 changes: 3 additions & 0 deletions src/Parcel/Stamp/Mailer/BackendAttachmentsStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class BackendAttachmentsStamp implements StampInterface
{
/**
* @param array<string> $vouchers
*/
public function __construct(private readonly array $vouchers)
{
}
Expand Down
6 changes: 6 additions & 0 deletions src/Parcel/Stamp/Mailer/EmailStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class EmailStamp implements StampInterface

private string $html = '';

/**
* @var array<string>
*/
private array $attachmentVouchers = [];

public function withFromName(string $fromName): self
Expand Down Expand Up @@ -111,6 +114,9 @@ public function withAttachmentVoucher(string $voucher): self
return $clone;
}

/**
* @return array<string>
*/
public function getAttachmentVouchers(): array
{
return $this->attachmentVouchers;
Expand Down
5 changes: 5 additions & 0 deletions src/Parcel/Stamp/StampInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ interface StampInterface
{
/**
* Must return a JSON serializable array.
*
* @return array<mixed>
*/
public function toArray(): array;

/**
* @param array<mixed> $data
*/
public static function fromArray(array $data): self;
}
6 changes: 6 additions & 0 deletions src/Parcel/StampCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public function getClasses(): array
return array_keys($this->stamps);
}

/**
* @return array<class-string<StampInterface>, array<mixed>>
*/
public function toArray(): array
{
$data = [];
Expand All @@ -76,6 +79,9 @@ public function toArray(): array
return $data;
}

/**
* @param array<class-string<StampInterface>, array<mixed>> $data
*/
public static function fromArray(array $data): self
{
$stamps = [];
Expand Down
9 changes: 9 additions & 0 deletions src/Token/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function getParserValue(): string
return $this->parserValue;
}

/**
* @return array{name: string, value: mixed, parserValue: string}
*/
public function toArray(): array
{
return [
Expand All @@ -37,6 +40,9 @@ public function toArray(): array
];
}

/**
* @param array{name: string, value: mixed, parserValue: string} $data
*/
public static function fromArray(array $data): self
{
return new self(
Expand All @@ -55,6 +61,9 @@ public static function fromValue(string $tokenName, mixed $tokenValue): self
};
}

/**
* @param array<mixed> $array
*/
private static function flattenArray(array $array): string
{
$chunks = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Token/TokenCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
class TokenCollection extends AbstractCollection
{
/**
* @param array<array{class: string, data: array{name: string, value: mixed, parserValue: string}}> $data
*/
public static function fromSerializedArray(array $data): self
{
$tokens = [];
Expand Down Expand Up @@ -107,7 +110,7 @@ public function has(string $name): bool
}

/**
* @return array<array{class: string, data: array}>
* @return array<array{class: string, data: array{name: string, value: mixed, parserValue: string}}>
*/
public function toSerializableArray(): array
{
Expand Down
4 changes: 4 additions & 0 deletions src/Token/TokenContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Terminal42\NotificationCenterBundle\Token\Definition\FileTokenDefinition;
use Terminal42\NotificationCenterBundle\Token\Definition\HtmlTokenDefinition;
use Terminal42\NotificationCenterBundle\Token\Definition\TextTokenDefinition;
use Terminal42\NotificationCenterBundle\Token\Definition\TokenDefinitionInterface;

enum TokenContext: string
{
Expand All @@ -17,6 +18,9 @@ enum TokenContext: string
case Html = 'html';
case File = 'file';

/**
* @return array<class-string<TokenDefinitionInterface>>
*/
public function definitions(): array
{
return match ($this) {
Expand Down
5 changes: 4 additions & 1 deletion src/Util/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

class Email
{
/**
* @return array<string>
*/
public static function splitEmailAddresses(string $recipients): array
{
$split = [];
Expand All @@ -24,7 +27,7 @@ public static function splitEmailAddresses(string $recipients): array
continue;
}

$split[] = $address;
$split[] = $email;
}

return $split;
Expand Down
Loading

0 comments on commit c208842

Please sign in to comment.