Completed
Push — latest ( 6c0640...3af091 )
by Colin
16s queued 11s
created

CommonMark/Parser/Block/HtmlBlockStartParser.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace League\CommonMark\Extension\CommonMark\Parser\Block;
15
16
use League\CommonMark\Node\Block\Paragraph;
17
use League\CommonMark\Parser\Block\BlockStart;
18
use League\CommonMark\Parser\Block\BlockStartParserInterface;
19
use League\CommonMark\Parser\Cursor;
20
use League\CommonMark\Parser\MarkdownParserStateInterface;
21
use League\CommonMark\Util\RegexHelper;
22
23
final class HtmlBlockStartParser implements BlockStartParserInterface
24
{
25 1953
    public function tryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): ?BlockStart
26
    {
27 1953
        if ($cursor->isIndented() || $cursor->getNextNonSpaceCharacter() !== '<') {
28 1707
            return BlockStart::none();
1 ignored issue
show
Are you sure the usage of League\CommonMark\Parser\Block\BlockStart::none() targeting League\CommonMark\Parser\Block\BlockStart::none() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
29
        }
30
31 303
        $tmpCursor = clone $cursor;
32 303
        $tmpCursor->advanceToNextNonSpaceOrTab();
33 303
        $line = $tmpCursor->getRemainder();
34
35 303
        for ($blockType = 1; $blockType <= 7; $blockType++) {
36 303
            $match = RegexHelper::matchAt(
37 303
                RegexHelper::getHtmlBlockOpenRegex($blockType),
38 202
                $line
39
            );
40
41 303
            if ($match !== null && ($blockType < 7 || ! ($parserState->getLastMatchedBlockParser()->getBlock() instanceof Paragraph))) {
42 171
                return BlockStart::of(new HtmlBlockParser($blockType))->at($cursor);
43
            }
44
        }
45
46 144
        return BlockStart::none();
1 ignored issue
show
Are you sure the usage of League\CommonMark\Parser\Block\BlockStart::none() targeting League\CommonMark\Parser\Block\BlockStart::none() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
47
    }
48
}
49