src/HtmlTemplate.php

Summary

Maintainability
A
35 mins
Test Coverage

The class HtmlTemplate has an overall complexity of 82 which is very high. The configured complexity threshold is 50.
Open

class HtmlTemplate
{
    use WarnDynamicPropertyTrait;

    public const TOP_TAG = '_top';
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

The class HtmlTemplate has 17 public methods. Consider refactoring HtmlTemplate to keep number of public methods under 10.
Open

class HtmlTemplate
{
    use WarnDynamicPropertyTrait;

    public const TOP_TAG = '_top';
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Method _setOrAppend has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
Severity: Minor
Found in src/HtmlTemplate.php - About 35 mins to fix

The method _setOrAppend() has an NPath complexity of 960. The configured NPath complexity threshold is 200.
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
    {
        // $tag passed as associative array [tag => value]
        if (is_array($tag) && $value === null) { // @phpstan-ignore identical.alwaysFalse, booleanAnd.alwaysFalse
            if ($throwIfNotFound) {
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method _setOrAppend() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
    {
        // $tag passed as associative array [tag => value]
        if (is_array($tag) && $value === null) { // @phpstan-ignore identical.alwaysFalse, booleanAnd.alwaysFalse
            if ($throwIfNotFound) {
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

The method parseTemplateTree() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    protected function parseTemplateTree(array &$inputReversed, ?string $openedTag = null): TagTree
    {
        $tagTree = new TagTree($this, $openedTag ?? self::TOP_TAG);

        $chunk = array_pop($inputReversed);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

The method _setOrAppend has a boolean flag argument $throwIfNotFound, which is a certain sign of a Single Responsibility Principle violation.
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Remove error control operator '@' on line 408.
Open

    public function tryLoadFromFile(string $filename)
    {
        // realpath() is slow on Windows, so cache it and dedup only directories
        $filenameBase = basename($filename);
        $filename = dirname($filename);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

The method loadFromString has a boolean flag argument $allowParseCache, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function loadFromString(string $str, bool $allowParseCache = false): self
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method _setOrAppend has a boolean flag argument $append, which is a certain sign of a Single Responsibility Principle violation.
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method _setOrAppend has a boolean flag argument $encodeHtml, which is a certain sign of a Single Responsibility Principle violation.
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method _unsetFromTagTree uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                unset($tagTree->children[$k]);
            }
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The method _setOrAppend uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $htmlValue->dangerouslySetHtml($value);
        }
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The method emptyTagTree uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $this->_unsetFromTagTree($tagTree, $k);
            }
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\Closure' in method '_unsetFromTagTree'.
Open

        \Closure::bind(static function () use ($tagTree, $k) {
            if ($k === array_key_last($tagTree->children)) {
                array_pop($tagTree->children);
            } else {
                unset($tagTree->children[$k]);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method renderTagTreeToHtml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                throw (new Exception('Unexpected value class'))
                    ->addMoreInfo('value_class', get_class($v));
            }
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\Closure' in method 'cloneRegion'.
Open

        \Closure::bind(static function () use ($topTagTree, $topTag) {
            $topTagTree->tag = $topTag;
        }, null, TagTree::class)();
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Closure' in method 'del'.
Open

        \Closure::bind(static function () use ($tagTree) {
            $tagTree->children = [];
        }, null, TagTree::class)();
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method toLoadableString uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                throw (new Exception('Value class has no save support'))
                    ->addMoreInfo('value_class', get_class($v));
            }
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\Closure' in method 'parseTemplate'.
Open

            \Closure::bind(static function () use ($tagTrees, $parentTemplate) {
                foreach ($tagTrees as $tagTree) {
                    $tagTree->parentTemplate = $parentTemplate;
                }
            }, null, TagTree::class)();
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid excessively long variable names like $_parseCacheParentTemplate. Keep variable name length under 20.
Open

    private static ?self $_parseCacheParentTemplate = null;
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid variables with short names like $k. Configured minimum length is 3.
Open

    protected function _unsetFromTagTree(TagTree $tagTree, int $k): void
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

The property $_realpathCache is not named in camelCase.
Open

class HtmlTemplate
{
    use WarnDynamicPropertyTrait;

    public const TOP_TAG = '_top';
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $_filesCache is not named in camelCase.
Open

class HtmlTemplate
{
    use WarnDynamicPropertyTrait;

    public const TOP_TAG = '_top';
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $_parseCache is not named in camelCase.
Open

class HtmlTemplate
{
    use WarnDynamicPropertyTrait;

    public const TOP_TAG = '_top';
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $_parseCacheParentTemplate is not named in camelCase.
Open

class HtmlTemplate
{
    use WarnDynamicPropertyTrait;

    public const TOP_TAG = '_top';
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

Method name "_unsetFromTagTree" should not be prefixed with an underscore to indicate visibility
Open

    protected function _unsetFromTagTree(TagTree $tagTree, int $k): void
Severity: Minor
Found in src/HtmlTemplate.php by phpcodesniffer

Property name "$_filesCache" should not be prefixed with an underscore to indicate visibility
Open

    private static array $_filesCache = [];
Severity: Minor
Found in src/HtmlTemplate.php by phpcodesniffer

Method name "_hasTag" should not be prefixed with an underscore to indicate visibility
Open

    protected function _hasTag(string $tag): bool
Severity: Minor
Found in src/HtmlTemplate.php by phpcodesniffer

Property name "$_parseCacheParentTemplate" should not be prefixed with an underscore to indicate visibility
Open

    private static ?self $_parseCacheParentTemplate = null;
Severity: Minor
Found in src/HtmlTemplate.php by phpcodesniffer

Property name "$_realpathCache" should not be prefixed with an underscore to indicate visibility
Open

    private static array $_realpathCache = [];
Severity: Minor
Found in src/HtmlTemplate.php by phpcodesniffer

Property name "$_parseCache" should not be prefixed with an underscore to indicate visibility
Open

    private static array $_parseCache = [];
Severity: Minor
Found in src/HtmlTemplate.php by phpcodesniffer

Method name "_setOrAppend" should not be prefixed with an underscore to indicate visibility
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
Severity: Minor
Found in src/HtmlTemplate.php by phpcodesniffer

Line exceeds 120 characters; contains 147 characters
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
Severity: Minor
Found in src/HtmlTemplate.php by phpcodesniffer

The variable $_parseCache is not named in camelCase.
Open

    protected function parseTemplate(string $str, bool $allowParseCache): void
    {
        $cKey = static::class . "\0" . $str;
        if (!isset(self::$_parseCache[$cKey])) {
            // expand self-closing tags {$tag} -> {tag}{/tag}
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_parseCache is not named in camelCase.
Open

    protected function parseTemplate(string $str, bool $allowParseCache): void
    {
        $cKey = static::class . "\0" . $str;
        if (!isset(self::$_parseCache[$cKey])) {
            // expand self-closing tags {$tag} -> {tag}{/tag}
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_filesCache is not named in camelCase.
Open

    public function tryLoadFromFile(string $filename)
    {
        // realpath() is slow on Windows, so cache it and dedup only directories
        $filenameBase = basename($filename);
        $filename = dirname($filename);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_realpathCache is not named in camelCase.
Open

    public function tryLoadFromFile(string $filename)
    {
        // realpath() is slow on Windows, so cache it and dedup only directories
        $filenameBase = basename($filename);
        $filename = dirname($filename);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_parseCache is not named in camelCase.
Open

    protected function parseTemplate(string $str, bool $allowParseCache): void
    {
        $cKey = static::class . "\0" . $str;
        if (!isset(self::$_parseCache[$cKey])) {
            // expand self-closing tags {$tag} -> {tag}{/tag}
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_parseCache is not named in camelCase.
Open

    protected function parseTemplate(string $str, bool $allowParseCache): void
    {
        $cKey = static::class . "\0" . $str;
        if (!isset(self::$_parseCache[$cKey])) {
            // expand self-closing tags {$tag} -> {tag}{/tag}
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_realpathCache is not named in camelCase.
Open

    public function tryLoadFromFile(string $filename)
    {
        // realpath() is slow on Windows, so cache it and dedup only directories
        $filenameBase = basename($filename);
        $filename = dirname($filename);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_filesCache is not named in camelCase.
Open

    public function tryLoadFromFile(string $filename)
    {
        // realpath() is slow on Windows, so cache it and dedup only directories
        $filenameBase = basename($filename);
        $filename = dirname($filename);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_realpathCache is not named in camelCase.
Open

    public function tryLoadFromFile(string $filename)
    {
        // realpath() is slow on Windows, so cache it and dedup only directories
        $filenameBase = basename($filename);
        $filename = dirname($filename);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_filesCache is not named in camelCase.
Open

    public function tryLoadFromFile(string $filename)
    {
        // realpath() is slow on Windows, so cache it and dedup only directories
        $filenameBase = basename($filename);
        $filename = dirname($filename);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_parseCache is not named in camelCase.
Open

    protected function parseTemplate(string $str, bool $allowParseCache): void
    {
        $cKey = static::class . "\0" . $str;
        if (!isset(self::$_parseCache[$cKey])) {
            // expand self-closing tags {$tag} -> {tag}{/tag}
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method _setOrAppend is not named in camelCase.
Open

    protected function _setOrAppend($tag, ?string $value = null, bool $encodeHtml = true, bool $append = false, bool $throwIfNotFound = true): void
    {
        // $tag passed as associative array [tag => value]
        if (is_array($tag) && $value === null) { // @phpstan-ignore identical.alwaysFalse, booleanAnd.alwaysFalse
            if ($throwIfNotFound) {
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _hasTag is not named in camelCase.
Open

    protected function _hasTag(string $tag): bool
    {
        return isset($this->tagTrees[$tag]);
    }
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _unsetFromTagTree is not named in camelCase.
Open

    protected function _unsetFromTagTree(TagTree $tagTree, int $k): void
    {
        \Closure::bind(static function () use ($tagTree, $k) {
            if ($k === array_key_last($tagTree->children)) {
                array_pop($tagTree->children);
Severity: Minor
Found in src/HtmlTemplate.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status