detain/iptools

View on GitHub

Showing 352 of 352 total issues

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

    public static function parse($ip)
Severity: Minor
Found in src/IP.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 $ip. Configured minimum length is 3.
Open

    public function setIP(IP $ip)
Severity: Minor
Found in src/Network.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

Incorrect spacing between argument "$to" and equals sign; expected 1 but found 0
Open

    public function prev($to=1)
Severity: Minor
Found in src/IP.php by phpcodesniffer

Incorrect spacing between argument "$version" and equals sign; expected 1 but found 0
Open

    public static function parseLong($longIP, $version=self::IP_V4)
Severity: Minor
Found in src/IP.php by phpcodesniffer

Incorrect spacing between argument "$to" and equals sign; expected 1 but found 0
Open

    public function next($to=1)
Severity: Minor
Found in src/IP.php by phpcodesniffer

Incorrect spacing between default value and equals sign for argument "$version"; expected 1 but found 0
Open

    public static function parseLong($longIP, $version=self::IP_V4)
Severity: Minor
Found in src/IP.php by phpcodesniffer

Incorrect spacing between default value and equals sign for argument "$to"; expected 1 but found 0
Open

    public function next($to=1)
Severity: Minor
Found in src/IP.php by phpcodesniffer

Incorrect spacing between default value and equals sign for argument "$to"; expected 1 but found 0
Open

    public function prev($to=1)
Severity: Minor
Found in src/IP.php by phpcodesniffer

Blank line found at end of control structure
Open


Severity: Minor
Found in src/Range.php by phpcodesniffer

Avoid using static access to class 'IPTools\IP' in method 'parse'.
Open

            $netmask = IP::parse($netmask);
Severity: Minor
Found in src/Network.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 parseLong uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $binary = array();
            for ($i = 0; $i < self::IP_V6_OCTETS; $i++) {
                $binary[] = bcmod($longIP, 256);
                $longIP = bcdiv($longIP, 256, 0);
Severity: Minor
Found in src/IP.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 'IPTools\IP' in method 'getSpanNetwork'.
Open

        $ip = IP::parseBin(str_pad(substr($this->getFirstIP()->toBin(), 0, $prefixLength), $xorIP->getMaxPrefixLength(), '0'));
Severity: Minor
Found in src/Range.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 'IPTools\IP' in method 'parse'.
Open

            $ip      = IP::parse($ip);
Severity: Minor
Found in src/Network.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 'IPTools\IP' in method 'getSpanNetwork'.
Open

        $xorIP = IP::parseInAddr($this->getFirstIP()->inAddr() ^ $this->getLastIP()->inAddr());
Severity: Minor
Found in src/Range.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 contains uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            throw new RangeException('Invalid type');
        }
Severity: Minor
Found in src/Range.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 parse uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $ip      = IP::parse($data);
            $netmask = self::prefix2netmask($ip->getMaxPrefixLength(), $ip->getVersion());
        }
Severity: Minor
Found in src/Network.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 unused local variables such as '$chars'.
Open

            foreach ($chars = unpack('C*', $this->in_addr) as $char) {
Severity: Minor
Found in src/IP.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Avoid using static access to class 'IPTools\IP' in method 'parse'.
Open

            $firstIP = IP::parse($first);
Severity: Minor
Found in src/Range.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 'IPTools\IP' in method 'parse'.
Open

            $lastIP  = IP::parse($last);
Severity: Minor
Found in src/Range.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 toLong uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $octet = self::IP_V6_OCTETS - 1;
            foreach ($chars = unpack('C*', $this->in_addr) as $char) {
                $long = bcadd($long, bcmul($char, bcpow(256, $octet--)));
            }
Severity: Minor
Found in src/IP.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

Severity
Category
Status
Source
Language