boehm-s/fun-php

View on GitHub

Showing 283 of 290 total issues

Expected 1 space after FUNCTION keyword; 0 found
Open

    return function($a = null, $b = null, $c = null) use ($fn) {
Severity: Minor
Found in src/internals/_curry3.php by phpcodesniffer

Each PHP statement must be on a line by itself
Open

            return function(...$args) use ($fn) { return _curry3($fn)(...$args); };
Severity: Minor
Found in src/internals/_curry3.php by phpcodesniffer

Each PHP statement must be on a line by itself
Open

        return _curry1(function ($_c) use($fn, $a, $b) { return $fn($a, $b, $_c); });
Severity: Minor
Found in src/internals/_curry3.php by phpcodesniffer

Terminating statement must be indented to the same level as the CASE body
Open

            return _curry3_2_args($fn, $a, $b);
Severity: Minor
Found in src/internals/_curry3.php by phpcodesniffer

PHP keywords must be lowercase; expected "callable" but found "Callable"
Open

function _map(Callable $fn, iterable $array) {
Severity: Minor
Found in src/internals/_map.php by phpcodesniffer

Terminating statement must be indented to the same level as the CASE body
Open

            return _curry3_3_args($fn, $a, $b, $c);
Severity: Minor
Found in src/internals/_curry3.php by phpcodesniffer

Terminating statement must be indented to the same level as the CASE body
Open

            return function(...$args) use ($fn) { return _curry3($fn)(...$args); };
Severity: Minor
Found in src/internals/_curry3.php by phpcodesniffer

Missing class import via use statement (line '9', column '32').
Open

        $reflectionClass = new ReflectionClass($class);
Severity: Minor
Found in src/internals/_arity.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '13', column '27').
Open

        $reflection = new ReflectionFunction($fn);
Severity: Minor
Found in src/internals/_arity.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

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

    } else {
        return _curry1(function ($_c) use ($fn, $a, $b) { return $fn($a, $b, $_c); });
    }
Severity: Minor
Found in src/internals/_curry3.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 _curry3_3_args uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

    } else {
        return $fn($a, $b, $c);
    }
Severity: Minor
Found in src/internals/_curry3.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 splitAt uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $snd[] = $list[$i];
                }
Severity: Minor
Found in src/fun.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 _partition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $ko[] = $value;
        }
Severity: Minor
Found in src/internals/_filter.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 _arity uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

    } else {
        $reflection = new ReflectionFunction($fn);
        $arguments = $reflection->getParameters();
    }
Severity: Minor
Found in src/internals/_arity.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 _curry1 uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return call_user_func_array($fn, $args);
        }
Severity: Minor
Found in src/internals/_curry1.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 function _curry3_3_args() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
Open

function _curry3_3_args($fn, $a, $b, $c) {
    $a__ = _isPlaceholder($a);
    $b__ = _isPlaceholder($b);
    $c__ = _isPlaceholder($c);

Severity: Minor
Found in src/internals/_curry3.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

Line exceeds 120 characters; contains 145 characters
Open

     * Takes a value and returns the it's `!` (NOT Logical operator). Returns true when passed a falsy value, and false when passed a truthy one.
Severity: Minor
Found in src/fun.php by phpcodesniffer

Line exceeds 120 characters; contains 122 characters
Open

     * Performs right-to-left function composition. Like the unix pipe (|), but reversed ! All the function must be unary.
Severity: Minor
Found in src/fun.php by phpcodesniffer

Inline control structures are not allowed
Open

            } else
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Closing brace must be on a line by itself
Open

        return _curry2(function ($_a, $_c) use ($fn, $b) { return $fn($_a, $b, $_c); });
Severity: Minor
Found in src/internals/_curry3.php by phpcodesniffer
Severity
Category
Status
Source
Language