skqr/hateoas

View on GitHub
JsonApi/DocumentSerializer.php

Summary

Maintainability
A
0 mins
Test Coverage

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

    private function addPrimaryResources(Document $document, array &$json)
    {
        $metadata = $document->resources->getMetadata();
        $fields = isset($document->sparseFields[$metadata->type])
            ? $document->sparseFields[$metadata->type]
Severity: Minor
Found in JsonApi/DocumentSerializer.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

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

    protected function addLinkedResources(Document $document, array &$json)
    {
        $name = 'linked';

        if (
Severity: Minor
Found in JsonApi/DocumentSerializer.php by phpmd

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

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

    protected function addTopLevelLinks(Document $document, array &$json)
    {
        $name = 'links';

        if (
Severity: Minor
Found in JsonApi/DocumentSerializer.php by phpmd

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

Avoid unused private fields such as '$document'.
Open

    private $document;
Severity: Minor
Found in JsonApi/DocumentSerializer.php by phpmd

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

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

    private $linkedResourcesSerializer;
Severity: Minor
Found in JsonApi/DocumentSerializer.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 excessively long variable names like $linkedResourcesSerializer. Keep variable name length under 20.
Open

        Serializer\LinkedResourcesSerializer $linkedResourcesSerializer,
Severity: Minor
Found in JsonApi/DocumentSerializer.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 excessively long variable names like $topLevelLinkSerializer. Keep variable name length under 20.
Open

    private $topLevelLinkSerializer;
Severity: Minor
Found in JsonApi/DocumentSerializer.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 excessively long variable names like $topLevelLinkSerializer. Keep variable name length under 20.
Open

        Serializer\TopLevelLinksSerializer $topLevelLinkSerializer,
Severity: Minor
Found in JsonApi/DocumentSerializer.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

Multi-line function declarations must define one parameter per line
Open

        DocumentResource $resource, array $fields = []

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {

Only one argument is allowed per line in a multi-line function call
Open

            $resource, $this->securityContext, $fields

Only one argument is allowed per line in a multi-line function call
Open

            $resource, $this->securityContext, $fields

Line exceeds 120 characters; contains 131 characters
Open

        // @todo El TopLevelLinksSerializer debería ir primero, pero depende de que el LinkedResourcesSerializer arme el Document.

Inline control structures are not allowed
Open

        if ($meta) $json['meta'] = $meta;

Expected 0 spaces after opening bracket; newline found
Open

        if (

Expected 0 spaces after opening bracket; newline found
Open

        if (

There are no issues that match your filters.

Category
Status