Passed
Push — latest ( ba39d8...ca9086 )
by Colin
08:23
created

src/Extension/Footnote/Parser/FootnoteParser.php (1 issue)

Labels
Severity
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 * (c) Rezo Zero / Ambroise Maupate
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace League\CommonMark\Extension\Footnote\Parser;
16
17
use League\CommonMark\Extension\Footnote\Node\Footnote;
18
use League\CommonMark\Node\Block\AbstractBlock;
19
use League\CommonMark\Parser\Block\AbstractBlockContinueParser;
20
use League\CommonMark\Parser\Block\BlockContinue;
21
use League\CommonMark\Parser\Block\BlockContinueParserInterface;
22
use League\CommonMark\Parser\Cursor;
23
use League\CommonMark\Reference\ReferenceInterface;
24
25
final class FootnoteParser extends AbstractBlockContinueParser
26
{
27
    /**
28
     * @var Footnote
29
     *
30
     * @psalm-readonly
31
     */
32
    private $block;
33
34
    /**
35
     * @var int|null
36
     *
37
     * @psalm-readonly-allow-private-mutation
38
     */
39
    private $indentation;
40
41 66
    public function __construct(ReferenceInterface $reference)
42
    {
43 66
        $this->block = new Footnote($reference);
44 66
    }
45
46 66
    public function getBlock(): AbstractBlock
47
    {
48 66
        return $this->block;
49
    }
50
51 36
    public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
52
    {
53 36
        if ($cursor->isBlank()) {
54 15
            return BlockContinue::at($cursor);
55
        }
56
57 36
        if ($cursor->isIndented()) {
58 3
            $this->indentation = $this->indentation ?? $cursor->getIndent();
59 3
            $cursor->advanceBy($this->indentation);
60
61 3
            return BlockContinue::at($cursor);
62
        }
63
64 36
        return BlockContinue::none();
1 ignored issue
show
Are you sure the usage of League\CommonMark\Parser...k\BlockContinue::none() targeting League\CommonMark\Parser...k\BlockContinue::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...
65
    }
66
67 66
    public function isContainer(): bool
68
    {
69 66
        return true;
70
    }
71
72 60
    public function canContain(AbstractBlock $childBlock): bool
73
    {
74 60
        return true;
75
    }
76
}
77