Passed
Push — latest ( fec122...d29a33 )
by Colin
03:43 queued 01:41
created

Attributes/Parser/AttributesBlockStartParser.php (2 issues)

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) 2015 Martin Hasoň <[email protected]>
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\Attributes\Parser;
16
17
use League\CommonMark\Extension\Attributes\Util\AttributesHelper;
18
use League\CommonMark\Parser\Block\BlockStart;
19
use League\CommonMark\Parser\Block\BlockStartParserInterface;
20
use League\CommonMark\Parser\Cursor;
21
use League\CommonMark\Parser\MarkdownParserStateInterface;
22
23
final class AttributesBlockStartParser implements BlockStartParserInterface
24
{
25 18
    public function tryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): ?BlockStart
26
    {
27 18
        $originalPosition = $cursor->getPosition();
28 18
        $attributes       = AttributesHelper::parseAttributes($cursor);
29
30 18
        if ($attributes === [] && $originalPosition === $cursor->getPosition()) {
31 9
            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...
32
        }
33
34 15
        if ($cursor->getNextNonSpaceCharacter() !== null) {
35 6
            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...
36
        }
37
38 15
        return BlockStart::of(new AttributesBlockContinueParser($attributes, $parserState->getActiveBlockParser()->getBlock()))->at($cursor);
39
    }
40
}
41