boehm-s/fun-php

View on GitHub
src/fun.php

Summary

Maintainability
A
0 mins
Test Coverage

The class F has 27 non-getter- and setter-methods. Consider refactoring F to keep number of methods under 25.
Open

class F {


    /**
     * @brief `F::_` is a special placeholder value used to specify "gaps" within curried functions,
Severity: Minor
Found in src/fun.php by phpmd

TooManyMethods

Since: 0.1

A class with too many 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'.

The default was changed from 10 to 25 in PHPMD 2.3.

Example

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

The class F has 27 public methods. Consider refactoring F to keep number of public methods under 10.
Open

class F {


    /**
     * @brief `F::_` is a special placeholder value used to specify "gaps" within curried functions,
Severity: Minor
Found in src/fun.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

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

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 25 and the first side effect is on line 12.
Open

<?php
Severity: Minor
Found in src/fun.php by phpcodesniffer

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry3(function($fn, $prop, $obj) {
Severity: Minor
Found in src/fun.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

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

            return _reduce(function($acc, $fn) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $params) {
Severity: Minor
Found in src/fun.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

Avoid classes with short names like F. Configured minimum length is 3.
Open

class F {


    /**
     * @brief `F::_` is a special placeholder value used to specify "gaps" within curried functions,
Severity: Minor
Found in src/fun.php by phpmd

ShortClassName

Since: 2.9

Detects when classes or interfaces have a very short name.

Example

class Fo {

}

interface Fo {

}

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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry3(function($fn, $default, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.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

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

        return _curry1(function($a) {
Severity: Minor
Found in src/fun.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

Opening brace of a class must be on the line after the definition
Open

class F {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry3(function($fn, $default, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($value, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($prop, $arr) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

            ? function(...$objs) use ($obj) { return array_merge($obj, ...$objs); }
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

            return _reduce(function($acc, $fn) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

        })(...$args);
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

The closing brace for the class must go on the next line after the body
Open

}
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry3(function($prop, $value, $obj) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

            return function(...$rest_params) use ($fn, $params) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry1(function($array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry1(function($arr) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($idx, $list) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry3(function($fn, $prop, $obj) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry3(function($prop, $default, $obj) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($props, $arr) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($props, $obj) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $params) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry2(function($fn, $array) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        return _curry1(function($a) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

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

Opening brace should be on a new line
Open

    public static function each(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function findIndex(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function propEq(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function propSatisfies(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function find(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function compose(...$fns) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function not(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function partition(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function reduce(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function every(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function prop(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function splitAt(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function merge($obj, ...$objs) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function flatMap(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function sort(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function map(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace must be the last content on the line
Open

    public static function includes(...$args) { // TODO: make it work with strings
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function reverse(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function some(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function props(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function propOr(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace must be the last content on the line
Open

            ? function(...$objs) use ($obj) { return array_merge($obj, ...$objs); }
Severity: Minor
Found in src/fun.php by phpcodesniffer

Closing brace must be on a line by itself
Open

            ? function(...$objs) use ($obj) { return array_merge($obj, ...$objs); }
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function pipe(...$fns) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function includes(...$args) { // TODO: make it work with strings
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function pick(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function uniqBy(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function uniq(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function partial(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function filter(...$args) {
Severity: Minor
Found in src/fun.php by phpcodesniffer

The variable $rest_params is not named in camelCase.
Open

    public static function partial(...$args) {
        return _curry2(function($fn, $params) {
            return function(...$rest_params) use ($fn, $params) {
                return call_user_func_array($fn, array_merge($params, $rest_params));
            };
Severity: Minor
Found in src/fun.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

There are no issues that match your filters.

Category
Status