Issues (287)

src/web/twig/nodes/CommentsNode.php (20 issues)

1
<?php
2
/**
3
 * Template Comments plugin for Craft CMS
4
 *
5
 * Adds a HTML comment to demarcate each Twig template that is included or
6
 * extended.
7
 *
8
 * @link      https://nystudio107.com/
0 ignored issues
show
The tag in position 1 should be the @copyright tag
Loading history...
9
 * @copyright Copyright (c)  nystudio107
0 ignored issues
show
@copyright tag must contain a year and the name of the copyright holder
Loading history...
10
 */
0 ignored issues
show
PHP version not specified
Loading history...
Missing @category tag in file comment
Loading history...
Missing @package tag in file comment
Loading history...
Missing @author tag in file comment
Loading history...
Missing @license tag in file comment
Loading history...
11
12
namespace nystudio107\templatecomments\web\twig\nodes;
13
14
use Twig\Compiler;
15
use Twig\Node\Node;
16
17
/**
0 ignored issues
show
Missing short description in doc comment
Loading history...
18
 * @author    nystudio107
0 ignored issues
show
The tag in position 1 should be the @package tag
Loading history...
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
19
 * @package   TemplateComments
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
20
 * @since     1.0.0
0 ignored issues
show
The tag in position 3 should be the @author tag
Loading history...
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
21
 */
0 ignored issues
show
Missing @category tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
Missing @link tag in class comment
Loading history...
22
class CommentsNode extends Node
23
{
24
    // Public Methods
25
    // =========================================================================
26
27
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
Parameter $compiler should have a doc-comment as per coding-style.
Loading history...
28
     * @inheritdoc
29
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
30
    public function compile(Compiler $compiler): void
31
    {
32
        $compiler
33
            ->addDebugInfo($this)
34
            ->write('$_templateTimer = microtime(true)')
35
            ->raw(";\n")
36
            ->write('$_templateName = ')
37
            ->subcompile($this->getNode('templateName'))
38
            ->raw(";\n")
39
            ->write('echo PHP_EOL."<!-- >>> TEMPLATE BEGIN >>> ".$_templateName." -->".PHP_EOL')
40
            ->raw(";\n");
41
        // Make sure there is a body node
42
        if (!empty($this->nodes['body'])) {
43
            $compiler
44
                ->indent()
45
                ->subcompile($this->getNode('body'))
46
                ->outdent();
47
        }
48
        $compiler
49
            ->write('echo PHP_EOL."<!-- <<< TEMPLATE END <<< FROM ".$_templateName." TIME ".number_format((microtime(true)-$_templateTimer)*1000,2)."ms -->".PHP_EOL')
50
            ->raw(";\n")
51
            ->write("unset(\$_templateName);\n")
52
            ->write("unset(\$_templateTimer);\n");
53
    }
54
}
55