Completed
Push — master ( 83739a...a13ee4 )
by Colin
14s queued 11s
created

src/Extension/InlinesOnly/ChildRenderer.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\CommonMark\Extension\InlinesOnly;
13
14
use League\CommonMark\Block\Element\AbstractBlock;
15
use League\CommonMark\Block\Element\Document;
16
use League\CommonMark\Block\Element\InlineContainerInterface;
17
use League\CommonMark\Block\Renderer\BlockRendererInterface;
18
use League\CommonMark\ElementRendererInterface;
19
use League\CommonMark\Inline\Element\AbstractInline;
20
21
/**
22
 * Simply renders child elements as-is, adding newlines as needed.
23
 */
24
final class ChildRenderer implements BlockRendererInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29 3
    public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
30
    {
31 3
        $out = '';
32
33 3
        if ($block instanceof InlineContainerInterface) {
34
            /** @var iterable<AbstractInline> $children */
0 ignored issues
show
The doc-type iterable<AbstractInline> could not be parsed: Expected "|" or "end of type", but got "<" at position 8. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
35 3
            $children = $block->children();
36 3
            $out .= $htmlRenderer->renderInlines($children);
37
        } else {
38
            /** @var iterable<AbstractBlock> $children */
0 ignored issues
show
The doc-type iterable<AbstractBlock> could not be parsed: Expected "|" or "end of type", but got "<" at position 8. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
39 3
            $children = $block->children();
40 3
            $out .= $htmlRenderer->renderBlocks($children);
41
        }
42
43 3
        if (!($block instanceof Document)) {
44 3
            $out .= "\n";
45
        }
46
47 3
        return $out;
48
    }
49
}
50