Passed
Push — dependabot/composer/doctrine/d... ( bc1a80...bcc5a8 )
by
unknown
41:27 queued 36:06
created

src/Frontend/Core/Engine/FormEndTokenParser.php (3 issues)

1
<?php
2
3
namespace Frontend\Core\Engine;
4
5
/**
6
 * Twig token parser for form closing tag.
7
 */
8
class FormEndTokenParser extends \Twig_TokenParser
0 ignored issues
show
Deprecated Code introduced by
The class Twig_TokenParser has been deprecated: since Twig 2.7, use "Twig\TokenParser\AbstractTokenParser" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

8
class FormEndTokenParser extends /** @scrutinizer ignore-deprecated */ \Twig_TokenParser
Loading history...
9
{
10
    /**
11
     * @param \Twig_Token $token Token consumed by the lexer.
12
     *
13
     * @throws \Twig_Error_Syntax
14
     *
15
     * @return \Twig_Node
16
     */
17
    public function parse(\Twig_Token $token): \Twig_Node
18
    {
19
        $stream = $this->parser->getStream();
20
        if ($stream->getCurrent()->getType() !== \Twig_Token::BLOCK_END_TYPE) {
21
            $error = sprintf("'%s' does not require any arguments.", $this->getTag());
22
            throw new \Twig_Error_Syntax(
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Error_Syntax has been deprecated: since Twig 2.7, use "Twig\Error\SyntaxError" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

22
            throw /** @scrutinizer ignore-deprecated */ new \Twig_Error_Syntax(
Loading history...
23
                $error,
24
                $token->getLine(),
25
                $this->parser->getStream()->getSourceContext()->getPath()
26
            );
27
        }
28
        $stream->expect(\Twig_Token::BLOCK_END_TYPE);
29
30
        if (FormState::$current === null) {
31
            throw new \Twig_Error_Syntax(
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Error_Syntax has been deprecated: since Twig 2.7, use "Twig\Error\SyntaxError" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

31
            throw /** @scrutinizer ignore-deprecated */ new \Twig_Error_Syntax(
Loading history...
32
                'Trying to close a form tag, while none opened',
33
                $token->getLine(),
34
                $this->parser->getStream()->getSourceContext()->getPath()
35
            );
36
        }
37
38
        FormState::$current = null;
39
40
        return new FormEndNode($token->getLine(), $this->getTag());
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getTag(): string
47
    {
48
        return 'endform';
49
    }
50
}
51