From e462f05d5555f9be185dfe88b2392cbd2f88ce53 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Wed, 27 May 2026 13:46:22 +0200 Subject: [PATCH] correct old bugs --- Dockerfile | 10 ++- assets/controllers/progress_bar_controller.js | 8 +- .../user_highlight_tooltip_controller.js | 34 ++++---- src/Command/ArticleHighlightsAuditCommand.php | 5 +- src/Command/PrewarmCommand.php | 77 ++++++------------- src/Controller/ArticleController.php | 13 ++-- src/Controller/AuthorController.php | 2 +- src/Controller/CommentReplyController.php | 4 +- src/Controller/DefaultController.php | 3 - src/Controller/SeoController.php | 10 +-- .../CommaSeparatedToArrayTransformer.php | 9 --- src/Nostr/MagazineEventKeys.php | 2 +- src/Nostr/Nip10Kind1ArticleReplyTags.php | 10 +-- src/Nostr/Nip19Codec.php | 8 +- src/Nostr/Nip22CommentTags.php | 4 +- src/Repository/EventRepository.php | 2 +- src/Service/ArticleBodyHighlightInjector.php | 13 +--- src/Service/ArticleCommentThreadLoader.php | 20 ++--- src/Service/CacheService.php | 28 ++----- src/Service/CommentReplyService.php | 2 +- src/Service/HighlightSyncService.php | 5 +- src/Service/MagazineContentService.php | 38 ++++----- src/Service/MagazineRefresher.php | 4 +- src/Service/Nip05VerificationService.php | 2 +- src/Service/Nip09DeletionApplier.php | 3 - src/Service/NostrClient.php | 27 +++---- src/Service/NostrShareMenuBuilder.php | 2 +- src/Service/ProfileIdentityLinksBuilder.php | 10 +-- src/Service/ProfilePaymentLinksBuilder.php | 26 +++---- src/Twig/Components/IndexTabs.php | 3 - .../Components/Molecules/CategoryLink.php | 2 +- .../Components/Organisms/FeaturedList.php | 2 +- src/Util/NostrEventTags.php | 6 +- .../ArticleBodyHighlightInjectorTest.php | 2 +- ...ArticleHighlightCommonMarkPipelineTest.php | 3 - tests/bootstrap.php | 4 +- 36 files changed, 158 insertions(+), 245 deletions(-) diff --git a/Dockerfile b/Dockerfile index 050c660..4337782 100644 --- a/Dockerfile +++ b/Dockerfile @@ -108,10 +108,12 @@ RUN set -eux; \ composer dump-env prod; \ rm -f .env; \ # Strip deployment secrets from the compiled .env.local.php so they cannot be read from the - # image layers. APP_SECRET, DATABASE_URL, and MYSQL_* passwords must be injected as real - # environment variables at runtime. If they are absent at runtime Symfony will raise an error - # rather than silently using the public .env.dist defaults. - php -r '$e=include(".env.local.php"); unset($e["APP_SECRET"],$e["DATABASE_URL"],$e["MYSQL_USER"],$e["MYSQL_PASSWORD"],$e["MYSQL_ROOT_PASSWORD"]); file_put_contents(".env.local.php"," { this._inTip = true; this._cancelHide(); }; + this._onTipLeave ??= () => { this._inTip = false; this._scheduleHide(); }; + this.tip.addEventListener('mouseenter', this._onTipEnter); + this.tip.addEventListener('mouseleave', this._onTipLeave); + } this.activeMark = null; this._hideT = 0; @@ -84,15 +96,6 @@ export default class extends Controller { this._scheduleHide(); }; - this.tip.addEventListener('mouseenter', () => { - this._inTip = true; - this._cancelHide(); - }); - this.tip.addEventListener('mouseleave', () => { - this._inTip = false; - this._scheduleHide(); - }); - this._onFocus = (e) => { const t = e.target; if (!(t instanceof Element)) { @@ -182,7 +185,12 @@ export default class extends Controller { window.removeEventListener('hashchange', this._onHashChange); } this._cancelHide(); - this.tip.remove(); + if (this.tip) { + this.tip.removeEventListener('mouseenter', this._onTipEnter); + this.tip.removeEventListener('mouseleave', this._onTipLeave); + this.tip.remove(); + this.tip = null; + } } _cancelHide() { diff --git a/src/Command/ArticleHighlightsAuditCommand.php b/src/Command/ArticleHighlightsAuditCommand.php index a90035c..ca28dd6 100644 --- a/src/Command/ArticleHighlightsAuditCommand.php +++ b/src/Command/ArticleHighlightsAuditCommand.php @@ -76,7 +76,7 @@ final class ArticleHighlightsAuditCommand extends Command $io->title('Article highlights audit: '.$slug); $io->writeln('Author npub: '.$expectedNpub.''); $io->writeln('Article id: '.(string) $article->getId().' · kind: '. - ($article->getKind()?->value ?? 'null').''); + $article->getKind()->value.''); $highlights = $this->articleHighlightRepository->findByArticle($article); $io->writeln('Rows from findByArticle: '.\count($highlights).''); @@ -99,9 +99,6 @@ final class ArticleHighlightsAuditCommand extends Command $rows = []; $isolatedOk = 0; foreach ($highlights as $h) { - if (! $h instanceof ArticleHighlight) { - continue; - } $eid = \strtolower($h->getEventId()); $one = $this->articleBodyHighlightInjector->inject($html, [$h]); $found = 1 === \preg_match( diff --git a/src/Command/PrewarmCommand.php b/src/Command/PrewarmCommand.php index 0dbbd97..f44c199 100644 --- a/src/Command/PrewarmCommand.php +++ b/src/Command/PrewarmCommand.php @@ -105,29 +105,7 @@ final class PrewarmCommand extends Command } elseif ($phase === 'after_root') { $hb->silent = true; $this->cancelPcntlAlarm(); - $planned = $p['slugs'] ?? null; - if (!\is_array($planned)) { - $planned = []; - } - if ($planned === []) { - $io->writeln(' Magazine root has no child a tag categories; only the root index was stored.'); - } else { - $n = \count($planned); - $io->writeln(sprintf(' Magazine child categories in root (%d):', $n)); - foreach ($planned as $slug) { - $s = (string) $slug; - if (strlen($s) > 120) { - $s = substr($s, 0, 117).'…'; - } - $io->writeln(sprintf(' · %s', $s)); - } - $io->writeln(sprintf( - ' Progress bar: %d steps = 1 (root) + %d (categor%s).', - 1 + $n, - $n, - $n === 1 ? 'y' : 'ies' - )); - } + $io->writeln(' Magazine root has no child a tag categories; only the root index was stored.'); $bar = $this->createPrewarmProgressBar( $io, max(1, (int) ($p['total_steps'] ?? 1)), @@ -245,7 +223,7 @@ final class PrewarmCommand extends Command $until = time(); $deletionPubkeys = []; foreach ($this->articleRepository->findDistinctAuthorPubkeys() as $pk) { - if (\is_string($pk) && 64 === \strlen($pk)) { + if (64 === \strlen($pk)) { $deletionPubkeys[] = $pk; } } @@ -289,7 +267,7 @@ final class PrewarmCommand extends Command $st['articles_removed'], $st['magazine_roots'], $st['magazine_categories'], - $st['magazine_curation_30004'] ?? 0 + $st['magazine_curation_30004'] )); } catch (\Throwable $e) { $this->logger->error('app:prewarm NIP-09 failed', ['exception' => $e]); @@ -322,7 +300,7 @@ final class PrewarmCommand extends Command } $pubkeysSeen = []; foreach ($pubkeys as $pk) { - if (!\is_string($pk) || 64 !== \strlen($pk)) { + if (64 !== \strlen($pk)) { continue; } $h = strtolower($pk); @@ -357,7 +335,7 @@ final class PrewarmCommand extends Command $fetched = $this->nostrClient->fetchProfilePrewarmWireBundlesForAuthors($chunk, $batchSize); $n += $this->cacheService->putPrewarmMetadataBatch($chunk, $fetched); $bar->advance(\count($chunk)); - $p0 = (string) ($chunk[0] ?? ''); + $p0 = $chunk[0]; $bar->setMessage('Batch up to · '.substr($p0, 0, 8).'…'); } } catch (\Throwable $e) { @@ -399,7 +377,7 @@ final class PrewarmCommand extends Command $hex = strtolower($hex); $npub = $this->nostrKeyHelper->convertPublicKeyToBech32($hex); $bundle = $this->cacheService->getMetadataBundle($npub); - $rows = $this->profileIdentityLinks->buildNip05($bundle['content'], $bundle['kind0_tags'] ?? []); + $rows = $this->profileIdentityLinks->buildNip05($bundle['content'], $bundle['kind0_tags']); $fa = $this->featuredAuthorRepository->findOneByPubkeyHex($hex); if ($fa !== null && $fa->isListed() && $domain !== '') { $rows = $this->profileIdentityLinks->mergeSiteNip05IntoList( @@ -409,7 +387,7 @@ final class PrewarmCommand extends Command } foreach ($rows as $r) { ++$nt; - $label = (string) ($r['label'] ?? ''); + $label = $r['label']; if ($this->nip05Verification->verifyAndCache($hex, $label)) { ++$nv; } @@ -466,7 +444,7 @@ final class PrewarmCommand extends Command continue; } - $kind = $article->getKind()?->value ?? 30023; + $kind = $article->getKind()->value; $coordinate = $kind.':'.$pubkey.':'.$slug; $msg = $slug; if (strlen($msg) > 56) { @@ -672,9 +650,6 @@ final class PrewarmCommand extends Command private function createPrewarmProgressBar(SymfonyStyle $io, int $max, string $message = ''): ProgressBar { $bar = $io->createProgressBar($max); - if (method_exists($bar, 'setMinSecondsBetweenRedraws')) { - $bar->setMinSecondsBetweenRedraws(5.0); - } $bar->setFormat(' %current%/%max% [%bar%] %percent:3s%%'."\n".' %message% %elapsed:6s% '); $bar->setMessage($message); @@ -711,9 +686,7 @@ final class PrewarmCommand extends Command $max = (int) $bar->getMaxSteps(); $done = (int) $bar->getProgress(); if ($max > 0 && $done < $max && $done === 0) { - if (method_exists($bar, 'clear')) { - $bar->clear(); - } + $bar->clear(); } else { if ($max > 0 && $done < $max && $done > 0) { $bar->setMaxSteps($done); @@ -787,33 +760,33 @@ final class PrewarmCommand extends Command private function printCategoryCoverageSummary(SymfonyStyle $io, array $report): void { $io->section('Category index -> DB coverage'); - $tot = $report['totals'] ?? ['categories' => 0, 'listed' => 0, 'resolved' => 0, 'missing' => 0]; + $tot = $report['totals']; $io->writeln(sprintf( 'Categories: %d · listed coordinates: %d · in DB: %d · missing: %d', - (int) ($tot['categories'] ?? 0), - (int) ($tot['listed'] ?? 0), - (int) ($tot['resolved'] ?? 0), - (int) ($tot['missing'] ?? 0), + (int) $tot['categories'], + (int) $tot['listed'], + (int) $tot['resolved'], + (int) $tot['missing'], )); - foreach ($report['categories'] ?? [] as $cat) { - $title = trim((string) ($cat['title'] ?? '')); - $slug = (string) ($cat['slug'] ?? ''); - $eventId = (string) ($cat['event_id'] ?? ''); + foreach ($report['categories'] as $cat) { + $title = trim((string) $cat['title']); + $slug = (string) $cat['slug']; + $eventId = (string) $cat['event_id']; $io->writeln(sprintf( ' - %s (%s) · event %s · listed %d, in DB %d, missing %d', $title !== '' ? $title : $slug, $slug, $eventId !== '' ? $eventId : 'n/a', - (int) ($cat['listed_total'] ?? 0), - (int) ($cat['resolved_total'] ?? 0), - (int) ($cat['missing_total'] ?? 0), + (int) $cat['listed_total'], + (int) $cat['resolved_total'], + (int) $cat['missing_total'], )); - foreach ($cat['entries'] ?? [] as $entry) { - $coord = (string) ($entry['coordinate'] ?? ''); + foreach ($cat['entries'] as $entry) { + $coord = (string) $entry['coordinate']; if ($coord === '') { continue; } - $status = (string) ($entry['status'] ?? 'missing'); + $status = (string) $entry['status']; if ($status === 'resolved') { $titleOut = trim((string) ($entry['article_title'] ?? '')); $io->writeln(sprintf( @@ -822,7 +795,7 @@ final class PrewarmCommand extends Command $titleOut !== '' ? ' -> '.$titleOut : '' )); } else { - $reason = (string) ($entry['reason'] ?? 'unknown'); + $reason = (string) $entry['reason']; $io->writeln(sprintf(' - MISSING %s (%s)', $coord, $reason)); } } diff --git a/src/Controller/ArticleController.php b/src/Controller/ArticleController.php index 154d3fc..37a2cb5 100644 --- a/src/Controller/ArticleController.php +++ b/src/Controller/ArticleController.php @@ -140,7 +140,7 @@ class ArticleController extends AbstractController string $articleTitle ): array { $coordparts = explode(':', $coordinate, 3); - $articleKind = isset($coordparts[0]) && ctype_digit($coordparts[0]) ? (int) $coordparts[0] : 30023; + $articleKind = ctype_digit($coordparts[0]) ? (int) $coordparts[0] : 30023; $articleAuthorPubkey = strtolower(trim((string) ($coordparts[1] ?? ''))); $articleReplyTags = null; @@ -170,11 +170,8 @@ class ArticleController extends AbstractController if ($userMayReply) { /** @var array $list */ - $list = $data['list'] ?? []; + $list = $data['list']; foreach ($list as $row) { - if (!\is_object($row)) { - continue; - } $k = (int) ($row->kind ?? 0); if ($k !== KindsEnum::COMMENTS->value && $k !== KindsEnum::TEXT_NOTE->value) { continue; @@ -375,7 +372,7 @@ class ArticleController extends AbstractController $npub = $nostrKeyHelper->convertPublicKeyToBech32($article->getPubkey()); $author = $cacheService->getMetadata($npub); - $kind = $article->getKind()?->value ?? 30023; + $kind = $article->getKind()->value; $pubkey = (string) $article->getPubkey(); $articleSlug = (string) $article->getSlug(); $coordinate = $kind.':'.$pubkey.':'.$articleSlug; @@ -394,7 +391,7 @@ class ArticleController extends AbstractController $eid, $articleTitle ); - $commentReplyContext = $commentsData['comment_reply_context'] ?? $commentReplyContext; + $commentReplyContext = $commentsData['comment_reply_context']; $commentsPreloaded = true; } @@ -489,7 +486,7 @@ class ArticleController extends AbstractController } if ($html === '' && $previewData === null) { $html = 'No event found on the default relay for this preview.'; - } elseif ($html === '' && \is_object($previewData)) { + } elseif ($html === '') { $previewData->type = $descriptor->type; $html = $this->renderView('components/Molecules/NostrPreviewContent.html.twig', [ 'preview' => $previewData, diff --git a/src/Controller/AuthorController.php b/src/Controller/AuthorController.php index 1785784..cb3e230 100644 --- a/src/Controller/AuthorController.php +++ b/src/Controller/AuthorController.php @@ -46,7 +46,7 @@ class AuthorController extends AbstractController $bundle = $cacheService->getMetadataBundle($npub); $author = $bundle['content']; $kind0Tags = $bundle['kind0_tags']; - $nip30Emojis = $bundle['nip30_custom_emojis'] ?? []; + $nip30Emojis = $bundle['nip30_custom_emojis']; $perPage = 25; $page = max(1, $request->query->getInt('page', 1)); $total = $articleRepository->countByPubkey($pubkey); diff --git a/src/Controller/CommentReplyController.php b/src/Controller/CommentReplyController.php index 9858d34..b730867 100644 --- a/src/Controller/CommentReplyController.php +++ b/src/Controller/CommentReplyController.php @@ -57,8 +57,8 @@ final class CommentReplyController extends AbstractController return $this->json([ 'ok' => true, 'id' => $out['id'], - 'ok_relays' => $out['ok_relays'] ?? null, - 'total_relays' => $out['total_relays'] ?? null, + 'ok_relays' => $out['ok_relays'], + 'total_relays' => $out['total_relays'], ]); } diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index e29830c..5525857 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -64,9 +64,6 @@ class DefaultController extends AbstractController try { $embed = new \Embed\Embed(); $info = $embed->get($url); - if (!$info) { - throw new Exception('No OG data found'); - } return $this->render('components/Molecules/OgPreview.html.twig', [ 'og' => [ diff --git a/src/Controller/SeoController.php b/src/Controller/SeoController.php index 69b885f..d883378 100644 --- a/src/Controller/SeoController.php +++ b/src/Controller/SeoController.php @@ -140,12 +140,12 @@ final class SeoController extends AbstractController private function buildRelaysByPubkey(array $names): array { $raw = $this->params->get('profile_relays'); - if (!\is_array($raw) || $raw === []) { + if ($raw === []) { return []; } $urls = []; foreach ($raw as $u) { - if (\is_string($u) && (str_starts_with($u, 'wss://') || str_starts_with($u, 'ws://'))) { + if (str_starts_with($u, 'wss://') || str_starts_with($u, 'ws://')) { $urls[] = $u; } } @@ -193,9 +193,9 @@ final class SeoController extends AbstractController } $site = (string) $this->params->get('name'); $data = $this->magazineContent->getCategoryPageData($slug); - $rawList = $data['list'] ?? []; - $catTitle = (string) ($data['category']['title'] ?? $this->magazineContent->getCategoryDisplayTitle($slug)); - $summary = (string) ($data['category']['summary'] ?? ''); + $rawList = $data['list']; + $catTitle = (string) ($data['category']['title']); + $summary = (string) ($data['category']['summary']); $list = array_values( array_filter( diff --git a/src/Form/DataTransformer/CommaSeparatedToArrayTransformer.php b/src/Form/DataTransformer/CommaSeparatedToArrayTransformer.php index 321c738..9dc9dac 100644 --- a/src/Form/DataTransformer/CommaSeparatedToArrayTransformer.php +++ b/src/Form/DataTransformer/CommaSeparatedToArrayTransformer.php @@ -3,7 +3,6 @@ namespace App\Form\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; class CommaSeparatedToArrayTransformer implements DataTransformerInterface { @@ -19,10 +18,6 @@ class CommaSeparatedToArrayTransformer implements DataTransformerInterface return ''; } - if (!is_array($array)) { - throw new TransformationFailedException('Expected an array.'); - } - return implode(', ', $array); } @@ -38,10 +33,6 @@ class CommaSeparatedToArrayTransformer implements DataTransformerInterface return []; } - if (!is_string($string)) { - throw new TransformationFailedException('Expected a string.'); - } - // Split by commas, trim whitespace, and filter out empty values $items = array_filter(array_map('trim', explode(',', $string)), function ($value) { return $value !== ''; diff --git a/src/Nostr/MagazineEventKeys.php b/src/Nostr/MagazineEventKeys.php index f5b1e35..ea1e1ab 100644 --- a/src/Nostr/MagazineEventKeys.php +++ b/src/Nostr/MagazineEventKeys.php @@ -81,6 +81,6 @@ final class MagazineEventKeys $h = ''; } - return (\is_string($h) && 64 === \strlen($h) && ctype_xdigit($h)) ? strtolower($h) : ''; + return (64 === \strlen($h) && ctype_xdigit($h)) ? strtolower($h) : ''; } } diff --git a/src/Nostr/Nip10Kind1ArticleReplyTags.php b/src/Nostr/Nip10Kind1ArticleReplyTags.php index 49402cb..0ad751d 100644 --- a/src/Nostr/Nip10Kind1ArticleReplyTags.php +++ b/src/Nostr/Nip10Kind1ArticleReplyTags.php @@ -111,7 +111,7 @@ final class Nip10Kind1ArticleReplyTags { $want = strtolower($eventIdHex); foreach ($rawTags as $row) { - if (!\is_array($row) || \count($row) < 2) { + if (\count($row) < 2) { continue; } if (strtolower((string) ($row[0] ?? '')) !== 'e') { @@ -141,7 +141,7 @@ final class Nip10Kind1ArticleReplyTags { $out = []; foreach ($rawTags as $row) { - if (!\is_array($row) || \count($row) < 2) { + if (\count($row) < 2) { continue; } if (strtolower((string) ($row[0] ?? '')) !== 'p') { @@ -186,7 +186,7 @@ final class Nip10Kind1ArticleReplyTags }; foreach ($rawTags as $row) { - if (!\is_array($row) || !$isE($row) || \count($row) < 2) { + if (!$isE($row) || \count($row) < 2) { continue; } if (($row[3] ?? '') === 'root') { @@ -199,7 +199,7 @@ final class Nip10Kind1ArticleReplyTags if ($articleHex !== null) { foreach ($rawTags as $row) { - if (!\is_array($row) || !$isE($row) || \count($row) < 2) { + if (!$isE($row) || \count($row) < 2) { continue; } $id = self::normEventId($row[1] ?? null); @@ -211,7 +211,7 @@ final class Nip10Kind1ArticleReplyTags $eIds = []; foreach ($rawTags as $row) { - if (!\is_array($row) || !$isE($row) || \count($row) < 2) { + if (!$isE($row) || \count($row) < 2) { continue; } $id = self::normEventId($row[1] ?? null); diff --git a/src/Nostr/Nip19Codec.php b/src/Nostr/Nip19Codec.php index 87dea31..abd33c3 100644 --- a/src/Nostr/Nip19Codec.php +++ b/src/Nostr/Nip19Codec.php @@ -32,7 +32,7 @@ final class Nip19Codec $out = new \stdClass(); if ($hrp === 'npub' || $hrp === 'nsec') { - if (!\is_array($raw) || !isset($raw[1]) || !\is_array($raw[1])) { + if (!isset($raw[1]) || !\is_array($raw[1])) { throw new \RuntimeException('Unexpected npub/nsec decode shape'); } $out->type = $hrp; @@ -48,7 +48,7 @@ final class Nip19Codec } if ($hrp === 'note') { - if (!\is_array($raw) || !isset($raw['event_id']) || !\is_string($raw['event_id'])) { + if (!isset($raw['event_id']) || !\is_string($raw['event_id'])) { throw new \RuntimeException('Unexpected note decode shape'); } $out->type = 'note'; @@ -60,10 +60,6 @@ final class Nip19Codec return $out; } - if (!\is_array($raw)) { - throw new \RuntimeException('Unexpected NIP-19 decode shape'); - } - $out->type = $hrp; $d = new \stdClass(); if ($hrp === 'nprofile') { diff --git a/src/Nostr/Nip22CommentTags.php b/src/Nostr/Nip22CommentTags.php index c8ca60f..61c198b 100644 --- a/src/Nostr/Nip22CommentTags.php +++ b/src/Nostr/Nip22CommentTags.php @@ -19,7 +19,7 @@ final class Nip22CommentTags public static function forReplyToArticle(string $coordinate, string $articleAuthorPubkeyHex): array { $parts = explode(':', $coordinate, 2); - $k = \count($parts) >= 1 && ctype_digit((string) $parts[0]) ? (string) (int) $parts[0] : '30023'; + $k = ctype_digit((string) $parts[0]) ? (string) (int) $parts[0] : '30023'; return [ ['A', $coordinate, ''], @@ -90,7 +90,7 @@ final class Nip22CommentTags { foreach ([$upper, $lower] as $n) { foreach ($rawTags as $row) { - if (!\is_array($row) || ($row[0] ?? null) === null) { + if (($row[0] ?? null) === null) { continue; } if ((string) $row[0] === $n) { diff --git a/src/Repository/EventRepository.php b/src/Repository/EventRepository.php index 94d8386..110d6ce 100644 --- a/src/Repository/EventRepository.php +++ b/src/Repository/EventRepository.php @@ -32,7 +32,7 @@ class EventRepository extends ServiceEntityRepository { $keys = array_values(array_unique(array_filter( $keys, - static fn (mixed $k): bool => \is_string($k) && $k !== '', + static fn (mixed $k): bool => $k !== '', ))); if ($keys === []) { return []; diff --git a/src/Service/ArticleBodyHighlightInjector.php b/src/Service/ArticleBodyHighlightInjector.php index 5c6ff40..ff4bccf 100644 --- a/src/Service/ArticleBodyHighlightInjector.php +++ b/src/Service/ArticleBodyHighlightInjector.php @@ -167,9 +167,6 @@ final class ArticleBodyHighlightInjector $stack[] = $this->dom->documentElement; while ($stack !== []) { $el = \array_pop($stack); - if (! $el instanceof DOMElement) { - continue; - } if ($el->getAttribute('id') === $id) { return $el; } @@ -260,9 +257,6 @@ final class ArticleBodyHighlightInjector continue; } $span = $this->dom->createElement('span'); - if (false === $span) { - continue; - } $span->setAttribute('id', 'highlight-'.$other); $span->setAttribute('class', 'user-highlight__fragment-target'); $span->setAttribute('aria-hidden', 'true'); @@ -320,8 +314,8 @@ final class ArticleBodyHighlightInjector \usort( $groups, static function (array $a, array $b): int { - $ta = $a[0] instanceof ArticleHighlight ? $a[0]->getEventCreatedAt() : 0; - $tb = $b[0] instanceof ArticleHighlight ? $b[0]->getEventCreatedAt() : 0; + $ta = $a[0]->getEventCreatedAt(); + $tb = $b[0]->getEventCreatedAt(); return $ta <=> $tb; } @@ -708,9 +702,6 @@ final class ArticleBodyHighlightInjector $parent->insertBefore($this->dom->createTextNode($before), $ref); } $mark = $this->dom->createElement('mark'); - if (! $mark) { - return false; - } $mark->setAttribute('class', 'user-highlight__marker'); if ($firstInReadingOrder) { $mark->setAttribute('id', 'highlight-'.$eventId); diff --git a/src/Service/ArticleCommentThreadLoader.php b/src/Service/ArticleCommentThreadLoader.php index df80243..866445a 100644 --- a/src/Service/ArticleCommentThreadLoader.php +++ b/src/Service/ArticleCommentThreadLoader.php @@ -111,8 +111,8 @@ final readonly class ArticleCommentThreadLoader $item->expiresAfter($partial ? self::PARTIAL_THREAD_CACHE_TTL_SEC : 86400); $this->logger->info('comments.loader.nostr_ok', [ 'nostr_elapsed_ms' => (int) round((microtime(true) - $tNostr) * 1000), - 'thread' => \count($out['thread'] ?? []), - 'quotes' => \count($out['quotes'] ?? []), + 'thread' => \count($out['thread']), + 'quotes' => \count($out['quotes']), 'partial' => $partial, ]); @@ -151,7 +151,7 @@ final readonly class ArticleCommentThreadLoader } /** - * @param array{thread: array, quotes: array, superchats?: list>} $discussion + * @param array{thread: array, quotes: array, superchats?: list>, partial?: bool} $discussion * * @return array{ * list: array, @@ -164,8 +164,8 @@ final readonly class ArticleCommentThreadLoader */ private function expandFromDiscussion(array $discussion, float $t0, ?string $articleEventHexId = null): array { - $list = $discussion['thread'] ?? []; - $quotes = $discussion['quotes'] ?? []; + $list = $discussion['thread']; + $quotes = $discussion['quotes']; $superchats = $discussion['superchats'] ?? []; $this->logger->info('comments.loader.cache_resolved', [ 'elapsed_since_start_ms' => (int) round((microtime(true) - $t0) * 1000), @@ -232,14 +232,10 @@ final readonly class ArticleCommentThreadLoader } }; foreach ($list as $ev) { - if (\is_object($ev)) { - $strip($ev); - } + $strip($ev); } foreach ($quotes as $ev) { - if (\is_object($ev)) { - $strip($ev); - } + $strip($ev); } } @@ -368,7 +364,7 @@ final readonly class ArticleCommentThreadLoader return ['blurb' => null, 'body' => $content]; } $parts = explode("\n\n", $content, 2); - $first = trim((string) ($parts[0] ?? '')); + $first = trim($parts[0]); $rest = (string) ($parts[1] ?? ''); if ($first === '' || !str_starts_with($first, '>')) { return ['blurb' => null, 'body' => $content]; diff --git a/src/Service/CacheService.php b/src/Service/CacheService.php index bafe667..16cf32c 100644 --- a/src/Service/CacheService.php +++ b/src/Service/CacheService.php @@ -76,7 +76,7 @@ final class CacheService implements HighlightAuthorMetadataProvider, ResetInterf public function prefetchMetadataForNpubs(array $npubs): void { foreach ($npubs as $npub) { - if (!\is_string($npub) || $npub === '') { + if ($npub === '') { continue; } $authorHex = $this->npubToAuthorHex64($npub); @@ -95,7 +95,7 @@ final class CacheService implements HighlightAuthorMetadataProvider, ResetInterf { $npubs = []; foreach ($pubkeyHex as $hex) { - if (!\is_string($hex) || 64 !== \strlen($hex) || !ctype_xdigit($hex)) { + if (64 !== \strlen($hex) || !ctype_xdigit($hex)) { continue; } try { @@ -114,9 +114,6 @@ final class CacheService implements HighlightAuthorMetadataProvider, ResetInterf ++$this->metadataBatchDepth; try { do { - if ($this->pendingHexToNpub === []) { - break; - } $this->flushPendingMetadataFetches(); } while ($this->pendingHexToNpub !== []); } finally { @@ -193,7 +190,7 @@ final class CacheService implements HighlightAuthorMetadataProvider, ResetInterf continue; } $h = strtolower($hex); - if (!isset($bundlesByLowerHex[$h]) || !\is_array($bundlesByLowerHex[$h])) { + if (!isset($bundlesByLowerHex[$h])) { continue; } $bundle = $bundlesByLowerHex[$h]; @@ -239,15 +236,11 @@ final class CacheService implements HighlightAuthorMetadataProvider, ResetInterf if ($seq === []) { continue; } - $r = array_values( - array_map( - static fn (mixed $v): string => (string) $v, - array_values($seq) - ) + $r = array_map( + static fn (mixed $v): string => (string) $v, + array_values($seq) ); - if ($r !== [] && (string) ($r[0] ?? '') !== '') { - $out[] = $r; - } + $out[] = $r; } return $out; @@ -352,7 +345,7 @@ final class CacheService implements HighlightAuthorMetadataProvider, ResetInterf private function bundleFromKind0EventRow(Event $row, string $npub): array { $content = $this->decodeKind0ContentString($row->getContent()); - if (!\is_object($content) || $this->isPlaceholderContent($content, $npub)) { + if ($this->isPlaceholderContent($content, $npub)) { $content = $this->namePlaceholderNpubObject($npub); } @@ -368,11 +361,6 @@ final class CacheService implements HighlightAuthorMetadataProvider, ResetInterf ]; } - private function decodeKind0ContentObject(object $ev): \stdClass - { - return $this->decodeKind0ContentString((string) ($ev->content ?? '')); - } - private function decodeKind0ContentString(string $raw): \stdClass { try { diff --git a/src/Service/CommentReplyService.php b/src/Service/CommentReplyService.php index bff9bea..5a893b5 100644 --- a/src/Service/CommentReplyService.php +++ b/src/Service/CommentReplyService.php @@ -91,7 +91,7 @@ final readonly class CommentReplyService : ''; $clientParentOk = 64 === \strlen($rawParentAuthor) && ctype_xdigit($rawParentAuthor); $coordBits = explode(':', $expectedCoordinate, 3); - $articleAuthor = \count($coordBits) >= 2 ? strtolower((string) $coordBits[1]) : ''; + $articleAuthor = strtolower((string) $coordBits[1]); $articleAuthorOk = 64 === \strlen($articleAuthor) && ctype_xdigit($articleAuthor); if (\in_array((int) $parentKind, [KindsEnum::COMMENTS->value, KindsEnum::TEXT_NOTE->value], true)) { diff --git a/src/Service/HighlightSyncService.php b/src/Service/HighlightSyncService.php index 1767778..3abe2d3 100644 --- a/src/Service/HighlightSyncService.php +++ b/src/Service/HighlightSyncService.php @@ -41,15 +41,12 @@ final class HighlightSyncService return 0; } - $kind = $article->getKind()?->value ?? 30023; + $kind = $article->getKind()->value; $coordinate = $kind.':'.$pubkey.':'.$slug; $events = $this->nostrClient->fetchHighlightEventsForArticle($coordinate); $n = 0; foreach ($events as $ev) { - if (!\is_object($ev)) { - continue; - } if ((int) ($ev->kind ?? 0) !== KindsEnum::HIGHLIGHTS->value) { continue; } diff --git a/src/Service/MagazineContentService.php b/src/Service/MagazineContentService.php index 32c7f51..828c929 100644 --- a/src/Service/MagazineContentService.php +++ b/src/Service/MagazineContentService.php @@ -91,7 +91,7 @@ final class MagazineContentService if (\count($parts) < 3) { continue; } - if ((int) ($parts[0] ?? 0) !== KindsEnum::PUBLICATION_INDEX->value) { + if ((int) $parts[0] !== KindsEnum::PUBLICATION_INDEX->value) { continue; } $cats[] = ['a', $coord]; @@ -111,8 +111,8 @@ final class MagazineContentService $queue = []; $enqueued = []; foreach ($this->getHomeCategoryAIndexTagsFromStoreOnly() as $row) { - $coord = $row[1] ?? ''; - if (!\is_string($coord) || $coord === '') { + $coord = $row[1]; + if ($coord === '') { continue; } $parts = explode(':', $coord, 3); @@ -130,7 +130,7 @@ final class MagazineContentService $out = []; while ($queue !== []) { $slug = array_shift($queue); - if (!\is_string($slug) || $slug === '') { + if ($slug === '') { continue; } $out[] = $slug; @@ -446,7 +446,7 @@ final class MagazineContentService continue; } - $kind = (int) ($parts[0] ?? 0); + $kind = (int) $parts[0]; if (!\in_array($kind, KindsEnum::longformKindValues(), true)) { $entries[] = ['coordinate' => $coordinate, 'status' => 'missing', 'reason' => 'unsupported_kind']; $missing++; @@ -521,15 +521,15 @@ final class MagazineContentService public function missingInDbCoordinatesFromCoverageReport(array $report): array { $out = []; - foreach ($report['categories'] ?? [] as $cat) { - foreach ($cat['entries'] ?? [] as $entry) { - if (($entry['status'] ?? '') !== 'missing') { + foreach ($report['categories'] as $cat) { + foreach ($cat['entries'] as $entry) { + if ($entry['status'] !== 'missing') { continue; } - if (($entry['reason'] ?? '') !== 'article_not_in_db') { + if ($entry['reason'] !== 'article_not_in_db') { continue; } - $coord = isset($entry['coordinate']) ? (string) $entry['coordinate'] : ''; + $coord = (string) $entry['coordinate']; if ($coord !== '') { $out[] = $coord; } @@ -562,7 +562,7 @@ final class MagazineContentService if (\count($parts) < 3 || trim((string) $parts[2]) === '') { continue; } - $kind = (int) ($parts[0] ?? 0); + $kind = (int) $parts[0]; if (!\in_array($kind, KindsEnum::longformKindValues(), true)) { continue; } @@ -698,8 +698,8 @@ final class MagazineContentService { $out = []; foreach ($categoryATags as $row) { - $coord = $row[1] ?? ''; - if (!\is_string($coord) || $coord === '') { + $coord = $row[1]; + if ($coord === '') { continue; } foreach ($this->buildFeaturedWallBlocksForCategoryTree($coord) as $b) { @@ -751,7 +751,7 @@ final class MagazineContentService if (\count($parts) < 3) { continue; } - $kind = (int) ($parts[0] ?? 0); + $kind = (int) $parts[0]; if (!\in_array($kind, KindsEnum::longformKindValues(), true)) { continue; } @@ -827,8 +827,8 @@ final class MagazineContentService { $blocks = []; foreach ($categoryATags as $row) { - $coord = $row[1] ?? ''; - if (!\is_string($coord) || $coord === '') { + $coord = $row[1]; + if ($coord === '') { continue; } foreach ($this->buildFeaturedWallBlocksForCategoryTree($coord) as $b) { @@ -987,7 +987,7 @@ final class MagazineContentService if (\count($segs) < 3) { continue; } - $kind = (int) ($segs[0] ?? 0); + $kind = (int) $segs[0]; $identifier = trim((string) $segs[2]); if ($identifier === '') { continue; @@ -1030,7 +1030,7 @@ final class MagazineContentService if (\count($segs) < 3) { continue; } - $kind = (int) ($segs[0] ?? 0); + $kind = (int) $segs[0]; $identifier = trim((string) $segs[2]); if ($identifier === '') { continue; @@ -1139,7 +1139,7 @@ final class MagazineContentService if (\count($segs) < 3) { continue; } - $kind = (int) ($segs[0] ?? 0); + $kind = (int) $segs[0]; if ($kind !== KindsEnum::PUBLICATION_INDEX->value) { continue; } diff --git a/src/Service/MagazineRefresher.php b/src/Service/MagazineRefresher.php index 8c4c06e..3704e42 100644 --- a/src/Service/MagazineRefresher.php +++ b/src/Service/MagazineRefresher.php @@ -203,7 +203,7 @@ final class MagazineRefresher if (\count($parts) < 3) { continue; } - if ((int) ($parts[0] ?? 0) !== KindsEnum::PUBLICATION_INDEX->value) { + if ((int) $parts[0] !== KindsEnum::PUBLICATION_INDEX->value) { continue; } $s = trim((string) $parts[2]); @@ -244,7 +244,7 @@ final class MagazineRefresher $relayLabel = (string) (parse_url($defaultRelay, \PHP_URL_HOST) ?: $defaultRelay); while ($queue !== [] && microtime(true) < $deadline) { $slug = array_shift($queue); - if (!\is_string($slug) || trim($slug) === '') { + if (trim($slug) === '') { continue; } try { diff --git a/src/Service/Nip05VerificationService.php b/src/Service/Nip05VerificationService.php index 4e71651..81d1195 100644 --- a/src/Service/Nip05VerificationService.php +++ b/src/Service/Nip05VerificationService.php @@ -47,7 +47,7 @@ final readonly class Nip05VerificationService $out = []; $coldDone = 0; foreach ($rows as $r) { - $label = (string) ($r['label'] ?? ''); + $label = (string) $r['label']; $n = $this->normalizeNip05($label); if ($n === null) { $out[] = [...$r, 'verified' => false]; diff --git a/src/Service/Nip09DeletionApplier.php b/src/Service/Nip09DeletionApplier.php index 4bdb5dd..ae9db03 100644 --- a/src/Service/Nip09DeletionApplier.php +++ b/src/Service/Nip09DeletionApplier.php @@ -53,9 +53,6 @@ final class Nip09DeletionApplier $seenArticleIds = []; foreach ($deletionEvents as $ev) { - if (!\is_object($ev)) { - continue; - } if ((int) ($ev->kind ?? 0) !== KindsEnum::DELETION_REQUEST->value) { continue; } diff --git a/src/Service/NostrClient.php b/src/Service/NostrClient.php index a5f7c4c..f3d879d 100644 --- a/src/Service/NostrClient.php +++ b/src/Service/NostrClient.php @@ -117,7 +117,7 @@ class NostrClient $out = $base; foreach ($pubkeys as $pk) { foreach ($this->authorRelayCache->getAuthorNip65RelaysList($pk) as $wss) { - if (!\is_string($wss) || $wss === '' || isset($seen[$wss])) { + if ($wss === '' || isset($seen[$wss])) { continue; } $seen[$wss] = true; @@ -166,7 +166,7 @@ class NostrClient { $authorPubkeyHex = \array_values(\array_unique(\array_filter( $authorPubkeyHex, - static fn (mixed $h): bool => \is_string($h) && 64 === \strlen($h), + static fn (string $h): bool => 64 === \strlen($h), ))); if ($authorPubkeyHex === []) { return []; @@ -265,7 +265,7 @@ class NostrClient ): array { $authorPubkeyHex = \array_values(\array_unique(\array_filter( $authorPubkeyHex, - static fn (mixed $h): bool => \is_string($h) && 64 === \strlen($h), + static fn (string $h): bool => 64 === \strlen($h), ))); if ($authorPubkeyHex === [] || $since >= $until) { return []; @@ -376,7 +376,7 @@ class NostrClient $relaySet->setMessage($eventMessage); $this->relayRequestFactory->applySocketTimeoutToRelaySet($relaySet); $sent = $relaySet->send(); - if (\is_array($sent) && \array_key_exists($relayWss, $sent)) { + if (\array_key_exists($relayWss, $sent)) { $results[$relayWss] = $sent[$relayWss]; } else { $results[$relayWss] = $sent; @@ -734,7 +734,7 @@ class NostrClient $merged = $this->wireMerge->mergeNip33ParameterizedWireEvents($response); $k10002 = (int) KindsEnum::RELAY_LIST->value; foreach ($merged as $e) { - if (\is_object($e) && (int) ($e->kind ?? 0) === $k10002) { + if ((int) ($e->kind ?? 0) === $k10002) { return $e; } } @@ -1073,7 +1073,7 @@ class NostrClient $seen = []; $out = []; foreach (array_merge($this->relayListFactory->getConfiguredArticleRelayUrlList(), $relayUrls) as $relayUrl) { - if (!\is_string($relayUrl) || $relayUrl === '' || isset($seen[$relayUrl])) { + if ($relayUrl === '' || isset($seen[$relayUrl])) { continue; } $seen[$relayUrl] = true; @@ -1703,7 +1703,7 @@ class NostrClient $this->logger->info('[longform_ingest] ingestLongform: start', [ 'address_count' => \count($addresses), 'relays' => $relaysForLog, - 'addresses_sample' => \array_values(\array_slice($addresses, 0, 15)), + 'addresses_sample' => \array_slice($addresses, 0, 15), ]); $groups = []; foreach ($addresses as $c) { @@ -1730,10 +1730,7 @@ class NostrClient 'group_count' => \count($groups), ]); foreach ($groups as $gkey => $g) { - $dTags = array_values(array_unique($g['dTags'] ?? [])); - if ($dTags === [] || !isset($g['pubkey'], $g['kind'])) { - continue; - } + $dTags = array_values(array_unique($g['dTags'])); $kindEnum = KindsEnum::tryFrom((int) $g['kind']); if ($kindEnum === null) { $this->logger->notice('[longform_ingest] skip group: unknown kind', ['kind' => $g['kind']]); @@ -1881,9 +1878,6 @@ class NostrClient $merged = $this->wireMerge->mergeNip33ParameterizedWireEvents($events); $mergedDetail = []; foreach ($merged as $ev) { - if (!\is_object($ev)) { - continue; - } $mergedDetail[] = $this->wireMerge->longformIngestEventWireSummary($ev); } $this->logger->info('[longform_ingest] ingestLongform: after mergeNip33ParameterizedWireEvents', [ @@ -1898,9 +1892,6 @@ class NostrClient } $seenAddresses = []; foreach ($merged as $event) { - if (!\is_object($event)) { - continue; - } $addr = $this->wireMerge->nip33ParameterizedReplaceableAddress($event); if ($addr !== null) { $seenAddresses[$addr] = true; @@ -1935,7 +1926,7 @@ class NostrClient sprintf('[longform_ingest] ingestLongform: exception in group %s: %s', (string) $gkey, $e->getMessage()), [ 'message' => $e->getMessage(), - 'pubkey' => $g['pubkey'] ?? null, + 'pubkey' => $g['pubkey'], 'trace' => $e->getTraceAsString(), 'relays' => $relaysForLog, ], diff --git a/src/Service/NostrShareMenuBuilder.php b/src/Service/NostrShareMenuBuilder.php index 14baf42..5537a2a 100644 --- a/src/Service/NostrShareMenuBuilder.php +++ b/src/Service/NostrShareMenuBuilder.php @@ -184,7 +184,7 @@ final class NostrShareMenuBuilder private function fromArticle(Article $article): NostrShareMenuContext { $npub = $this->nostrKeyHelper->convertPublicKeyToBech32((string) $article->getPubkey()); - $kind = (int) ($article->getKind()?->value ?? 30023); + $kind = $article->getKind()->value; $d = (string) ($article->getSlug() ?? ''); if ($d === '') { return new NostrShareMenuContext( diff --git a/src/Service/ProfileIdentityLinksBuilder.php b/src/Service/ProfileIdentityLinksBuilder.php index f893834..939fbe6 100644 --- a/src/Service/ProfileIdentityLinksBuilder.php +++ b/src/Service/ProfileIdentityLinksBuilder.php @@ -78,8 +78,8 @@ final class ProfileIdentityLinksBuilder } $seen[$id] = true; $parts = explode('@', $id, 2); - $local = $parts[0] ?? ''; - $domain = $parts[1] ?? ''; + $local = $parts[0]; + $domain = $parts[1]; if ($local === '' || $domain === '' || str_contains($domain, ' ')) { continue; } @@ -110,14 +110,14 @@ final class ProfileIdentityLinksBuilder } $seen = []; foreach ($rows as $r) { - $seen[strtolower((string) ($r['label'] ?? ''))] = true; + $seen[strtolower((string) $r['label'])] = true; } if (isset($seen[$siteNip05])) { return $rows; } $parts = explode('@', $siteNip05, 2); - $local = $parts[0] ?? ''; - $domain = $parts[1] ?? ''; + $local = $parts[0]; + $domain = $parts[1]; if ($local === '' || $domain === '' || str_contains($domain, ' ')) { return $rows; } diff --git a/src/Service/ProfilePaymentLinksBuilder.php b/src/Service/ProfilePaymentLinksBuilder.php index 9228fb9..759d6d4 100644 --- a/src/Service/ProfilePaymentLinksBuilder.php +++ b/src/Service/ProfilePaymentLinksBuilder.php @@ -48,16 +48,14 @@ final class ProfilePaymentLinksBuilder if ($resolved['lightning_address'] !== null) { $addr = $resolved['lightning_address']; $norm = 'la:'.strtolower($addr); - if (!isset($seen[$norm])) { - $seen[$norm] = true; - $rows[] = [ - 'type' => self::TYPE_LIGHTNING_ADDRESS, - 'type_label' => 'Lightning', - 'label' => $addr, - 'href' => 'lightning:'.$addr, - 'sort' => 0, - ]; - } + $seen[$norm] = true; + $rows[] = [ + 'type' => self::TYPE_LIGHTNING_ADDRESS, + 'type_label' => 'Lightning', + 'label' => $addr, + 'href' => 'lightning:'.$addr, + 'sort' => 0, + ]; } if ($resolved['lnurl_pay'] !== null) { @@ -207,7 +205,7 @@ final class ProfilePaymentLinksBuilder { $out = []; foreach ($kind10133Events as $ev) { - if (!\is_object($ev) || (int) ($ev->kind ?? 0) !== KindsEnum::PAYMENT_TARGETS->value) { + if ((int) ($ev->kind ?? 0) !== KindsEnum::PAYMENT_TARGETS->value) { continue; } $tags = self::normalizeTagsArray($ev->tags ?? null); @@ -296,12 +294,10 @@ final class ProfilePaymentLinksBuilder $r = array_values( array_map( static fn (mixed $v): string => (string) $v, - array_values($seq) + $seq ) ); - if ($r !== []) { - $out[] = $r; - } + $out[] = $r; } return $out; diff --git a/src/Twig/Components/IndexTabs.php b/src/Twig/Components/IndexTabs.php index fc8a980..3ed36ad 100644 --- a/src/Twig/Components/IndexTabs.php +++ b/src/Twig/Components/IndexTabs.php @@ -14,8 +14,6 @@ class IndexTabs { use DefaultActionTrait; - private $index; - #[LiveProp(writable: true)] public int $activeTab = 1; // Default active tab @@ -35,7 +33,6 @@ class IndexTabs public function mount(EventEntity $index): void { - $this->index = $index; foreach ($index->getTags() as $tag) { if (array_key_first($tag) === 'a') { $ref = $tag[1]; diff --git a/src/Twig/Components/Molecules/CategoryLink.php b/src/Twig/Components/Molecules/CategoryLink.php index f1a3c3b..b9f2322 100644 --- a/src/Twig/Components/Molecules/CategoryLink.php +++ b/src/Twig/Components/Molecules/CategoryLink.php @@ -36,7 +36,7 @@ final class CategoryLink $this->title = $this->slug; $this->magazineContent->warmCategoryIndexIfMissing($this->slug); $cat = $this->store->getCategory($this->slug); - if (!\is_object($cat) || !\method_exists($cat, 'getTags')) { + if (!\is_object($cat)) { return; } diff --git a/src/Twig/Components/Organisms/FeaturedList.php b/src/Twig/Components/Organisms/FeaturedList.php index e7c019b..ec08533 100644 --- a/src/Twig/Components/Organisms/FeaturedList.php +++ b/src/Twig/Components/Organisms/FeaturedList.php @@ -44,7 +44,7 @@ final class FeaturedList $this->magazineContent->warmCategoryIndexIfMissing($slug); $catIndex = $this->store->getCategory($slug); - if (!\is_object($catIndex) || !\method_exists($catIndex, 'getTags')) { + if (!\is_object($catIndex)) { return; } diff --git a/src/Util/NostrEventTags.php b/src/Util/NostrEventTags.php index 3a00bd3..13adc71 100644 --- a/src/Util/NostrEventTags.php +++ b/src/Util/NostrEventTags.php @@ -42,7 +42,7 @@ final class NostrEventTags return false; } - return strtolower($seq[0] ?? '') === strtolower($name); + return strtolower($seq[0]) === strtolower($name); } /** @@ -69,7 +69,7 @@ final class NostrEventTags if (\count($parts) < 3) { continue; } - if ((int) ($parts[0] ?? 0) !== KindsEnum::PUBLICATION_INDEX->value) { + if ((int) $parts[0] !== KindsEnum::PUBLICATION_INDEX->value) { continue; } $d = trim((string) $parts[2]); @@ -108,7 +108,7 @@ final class NostrEventTags if (\count($parts) < 3) { continue; } - if ((int) ($parts[0] ?? 0) !== KindsEnum::PUBLICATION_INDEX->value) { + if ((int) $parts[0] !== KindsEnum::PUBLICATION_INDEX->value) { continue; } $pk = strtolower(trim((string) $parts[1])); diff --git a/tests/Service/ArticleBodyHighlightInjectorTest.php b/tests/Service/ArticleBodyHighlightInjectorTest.php index d4d8d98..b50a69b 100644 --- a/tests/Service/ArticleBodyHighlightInjectorTest.php +++ b/tests/Service/ArticleBodyHighlightInjectorTest.php @@ -147,7 +147,7 @@ final class ArticleBodyHighlightInjectorTest extends TestCase } /** - * @param list $eventIdsLowerOrMixed 64-char hex event ids + * @param list $eventIds 64-char hex event ids */ private function assertHighlightFragmentsPresent(string $html, array $eventIds): void { diff --git a/tests/Service/ArticleHighlightCommonMarkPipelineTest.php b/tests/Service/ArticleHighlightCommonMarkPipelineTest.php index 9ab8804..533f936 100644 --- a/tests/Service/ArticleHighlightCommonMarkPipelineTest.php +++ b/tests/Service/ArticleHighlightCommonMarkPipelineTest.php @@ -26,9 +26,6 @@ final class ArticleHighlightCommonMarkPipelineTest extends KernelTestCase private function getConverter(): Converter { $container = static::getContainer(); - if (!$container->has(Converter::class)) { - self::fail('Converter service must be registered in the test kernel.'); - } /** @var Converter $c */ $c = $container->get(Converter::class); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bc0e6dd..91902e1 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,9 +4,7 @@ use Symfony\Component\Dotenv\Dotenv; require dirname(__DIR__).'/vendor/autoload.php'; -if (method_exists(Dotenv::class, 'bootEnv')) { - (new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); -} +(new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); if (!empty($_SERVER['APP_DEBUG'])) { umask(0000);