GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TwigJsTokenParser::parse()   B
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 41
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 41
rs 8.8571
cc 3
eloc 26
nc 3
nop 1
1
<?php
2
3
namespace TwigJs\Twig;
4
5
class TwigJsTokenParser extends \Twig_TokenParser
6
{
7
    public function parse(\Twig_Token $token)
8
    {
9
        $node = new TwigJsNode(
10
            array(),
11
            array(),
12
            $token->getLine(),
13
            $this->getTag()
14
        );
15
16
        $stream = $this->parser->getStream();
17
        while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
18
            if ($stream->test(\Twig_Token::NAME_TYPE, 'name')) {
19
                $stream->next();
20
                $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
21
                $node->setAttribute(
22
                    'name',
23
                    $stream->expect(\Twig_Token::STRING_TYPE)->getValue()
24
                );
25
26
                continue;
27
            }
28
29
            $token = $stream->getCurrent();
30
31
            throw new \Twig_Error_Syntax(
32
                sprintf(
33
                    'Unexpected token "%s" of value "%s"',
34
                    \Twig_Token::typeToEnglish(
35
                        $token->getType(),
36
                        $token->getLine()
0 ignored issues
show
Unused Code introduced by
The call to Twig_Token::typeToEnglish() has too many arguments starting with $token->getLine().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
37
                    ),
38
                    $token->getValue()
39
                ),
40
                $token->getLine()
41
            );
42
        }
43
44
        $stream->expect(\Twig_Token::BLOCK_END_TYPE);
45
46
        return $node;
47
    }
48
49
    public function getTag()
50
    {
51
        return 'twig_js';
52
    }
53
}
54