Dhii/i18n-helper-base

View on GitHub

Showing 9 of 9 total issues

Avoid using short method names like StringTranslatingTrait::__(). The configured minimum method name length is 3.
Open

    protected function __($string, $args = array(), $context = null)
    {
        $string = $this->_translate($string, $context);
        array_unshift($args, $string);
        $result = call_user_func_array('sprintf', $args);
Severity: Minor
Found in src/StringTranslatingTrait.php by phpmd

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

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

Avoid unused parameters such as '$context'.
Open

    protected function _translate($string, $context = null)
Severity: Minor
Found in src/StringTranslatingTrait.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid assigning values to variables in if clauses and the like (line '26', column '16').
Open

    protected function _translate($string, $context = null)
    {
        if (!(($translator = $this->_getTranslator()) instanceof StringTranslatorInterface)) {
            return $string;
        }

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

The method _getTranslator is not named in camelCase.
Open

    abstract protected function _getTranslator();

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 _translate is not named in camelCase.
Open

    protected function _translate($string, $context = null)
    {
        return $string;
    }
Severity: Minor
Found in src/StringTranslatingTrait.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 _setTranslator is not named in camelCase.
Open

    protected function _setTranslator($translator)
    {
        if (!(is_null($translator) || $translator instanceof StringTranslatorInterface)) {
            throw new InvalidArgumentException('Invalid translator');
        }
Severity: Minor
Found in src/StringTranslatorAwareTrait.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 __ is not named in camelCase.
Open

    protected function __($string, $args = array(), $context = null)
    {
        $string = $this->_translate($string, $context);
        array_unshift($args, $string);
        $result = call_user_func_array('sprintf', $args);
Severity: Minor
Found in src/StringTranslatingTrait.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 _getTranslator is not named in camelCase.
Open

    protected function _getTranslator()
    {
        return $this->translator;
    }
Severity: Minor
Found in src/StringTranslatorAwareTrait.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 _translate is not named in camelCase.
Open

    protected function _translate($string, $context = null)
    {
        if (!(($translator = $this->_getTranslator()) instanceof StringTranslatorInterface)) {
            return $string;
        }

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

Severity
Category
Status
Source
Language