Issues (77)

src/twigextensions/EmptyCoalesceTwigExtension.php (24 issues)

1
<?php
2
/**
3
 * Empty Coalesce plugin for Craft CMS 3.x
4
 *
5
 * Empty Coalesce adds the ??? operator to Twig that will return the first thing
6
 * that is defined, not null, and not empty.
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) 2018 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\emptycoalesce\twigextensions;
13
14
use nystudio107\emptycoalesce\Node\Expression\EmptyCoalesceExpression;
15
16
use Twig\ExpressionParser;
17
use Twig\Extension\AbstractExtension;
18
19
/**
0 ignored issues
show
Missing short description in doc comment
Loading history...
20
 * @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...
21
 * @package   EmptyCoalesce
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
22
 * @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...
23
 */
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...
24
class EmptyCoalesceTwigExtension extends AbstractExtension
25
{
26
    // Public Methods
27
    // =========================================================================
28
29
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
30
     * @inheritdoc
31
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
32
    public function getName(): string
33
    {
34
        return 'EmptyCoalesce';
35
    }
36
37
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
38
     * @inheritdoc
39
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
40
    public function getFilters(): array
41
    {
42
        return [
43
        ];
44
    }
45
46
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
47
     * @inheritdoc
48
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
49
    public function getFunctions(): array
50
    {
51
        return [
52
        ];
53
    }
54
55
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
56
     * @return array<int, mixed[]>
57
     */
58
    public function getOperators(): array
59
    {
60
        return [
61
            // Unary operators
62
            [],
63
            // Binary operators
64
            [
65
                '???' => [
66
                    'precedence' => 300,
67
                    'class' => EmptyCoalesceExpression::class,
68
                    'associativity' => ExpressionParser::OPERATOR_RIGHT,
69
                ],
70
            ],
71
        ];
72
    }
73
}
74