diff --git a/be/.phpcs.xml b/be/.phpcs.xml index 0df55239..9ebf05dd 100644 --- a/be/.phpcs.xml +++ b/be/.phpcs.xml @@ -4,6 +4,7 @@ + diff --git a/be/phpcs.xml.dist b/be/phpcs.xml.dist deleted file mode 100644 index 89195e2b..00000000 --- a/be/phpcs.xml.dist +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - bin/ - config/ - public/ - src/ - tests/ - - diff --git a/be/src/Controller/PostsController.php b/be/src/Controller/PostsController.php index 1c32f3b1..461da3a6 100644 --- a/be/src/Controller/PostsController.php +++ b/be/src/Controller/PostsController.php @@ -50,7 +50,8 @@ public function __construct( public function query(Request $request): array { $this->validator->validate($request->query->all(), new Assert\Collection([ - 'cursor' => new Assert\Optional(new Assert\Regex( // https://stackoverflow.com/questions/475074/regex-to-parse-or-validate-base64-data + 'cursor' => new Assert\Optional(new Assert\Regex( + // https://stackoverflow.com/questions/475074/regex-to-parse-or-validate-base64-data // (,|$)|,){5,6} means allow at most 5~6 parts of base64 segment or empty string to exist '/^(([A-Za-z0-9-_]{4})*([A-Za-z0-9-_]{2,3})(,|$)|,){5,6}$/', )), diff --git a/be/src/EventListener/SerializeToJson.php b/be/src/EventListener/SerializeToJson.php index 014615e8..5b600d86 100644 --- a/be/src/EventListener/SerializeToJson.php +++ b/be/src/EventListener/SerializeToJson.php @@ -7,7 +7,9 @@ use Symfony\Component\HttpKernel\Event\ViewEvent; use Symfony\Component\Serializer\SerializerInterface; -#[AsEventListener(priority: -129)] // https://github.com/symfony/twig-bridge/blob/d63fde6a6142ffbab5fe6ee252b668b9485bfc0d/EventListener/TemplateAttributeListener.php#L66 +// phpcs:disable Generic.Files.LineLength +// https://github.com/symfony/twig-bridge/blob/d63fde6a6142ffbab5fe6ee252b668b9485bfc0d/EventListener/TemplateAttributeListener.php#L66 +#[AsEventListener(priority: -129)] readonly class SerializeToJson { public function __construct(private SerializerInterface $serializer) {} diff --git a/be/src/PostsQuery/BaseQuery.php b/be/src/PostsQuery/BaseQuery.php index 2c7ecb19..94872988 100644 --- a/be/src/PostsQuery/BaseQuery.php +++ b/be/src/PostsQuery/BaseQuery.php @@ -210,13 +210,15 @@ static function (string $postIDName) use ($result): array { ->where('t.pid IN (:pids)')->setParameter('pids', $allRepliesId) ->getQuery()->getResult()) ->mapWithKeys(fn(ReplyContent $content) => [$content->getPid() => $content->getContent()]); - $replies->each(fn(Reply $reply) => $reply->setContent($replyContents->get($reply->getPid()))); + $replies->each(fn(Reply $reply) => + $reply->setContent($replyContents->get($reply->getPid()))); $subReplyContents = collect($this->postRepositoryFactory->newSubReplyContent($fid)->createQueryBuilder('t') ->where('t.spid IN (:spids)')->setParameter('spids', $spids) ->getQuery()->getResult()) ->mapWithKeys(fn(SubReplyContent $content) => [$content->getSpid() => $content->getContent()]); - $subReplies->each(fn(SubReply $subReply) => $subReply->setContent($subReplyContents->get($subReply->getSpid()))); + $subReplies->each(fn(SubReply $subReply) => + $subReply->setContent($subReplyContents->get($subReply->getSpid()))); $this->stopwatch->stop('parsePostContentProtoBufBytes'); return [ diff --git a/be/src/PostsQuery/SearchQuery.php b/be/src/PostsQuery/SearchQuery.php index b5734a0b..64fe7520 100644 --- a/be/src/PostsQuery/SearchQuery.php +++ b/be/src/PostsQuery/SearchQuery.php @@ -111,6 +111,7 @@ static function (QueryBuilder $newQueryWhenCacheMiss) use (&$outCachedUserQueryR 'tid', 'pid', 'spid', 'authorUid', 'authorExpGrade', 'latestReplierUid', 'threadViewCount', 'threadShareCount', 'threadReplyCount', 'replySubReplyCount' => + // phpcs:disable Generic.WhiteSpace.ScopeIndent match ($sub['range']) { 'IN' => $query->andWhere("t.$fieldNameOfNumericParams $not IN (:$sqlParamName)") ->setParameter($sqlParamName, explode(',', $value)), @@ -123,7 +124,13 @@ static function (QueryBuilder $newQueryWhenCacheMiss) use (&$outCachedUserQueryR }, // textMatch 'threadTitle', 'postContent' => - self::applyTextMatchParamOnQuery($query, $name === 'threadTitle' ? 'title' : 'content', $value, $sub, $sqlParamName), + self::applyTextMatchParamOnQuery( + $query, + $name === 'threadTitle' ? 'title' : 'content', + $value, + $sub, + $sqlParamName, + ), // dateTimeRange 'postedAt', 'latestReplyPostedAt' => $whereBetween($name), // array