YetiForceCompany/YetiForceCRM

View on GitHub
app/RequestUtil.php

Summary

Maintainability
C
1 day
Test Coverage
C
75%

isHttps accesses the super-global variable $_SERVER.
Open

    public static function isHttps(): bool
    {
        if (!isset(self::$httpsCache)) {
            self::$httpsCache = (!empty($_SERVER['HTTPS']) && 'off' !== strtolower($_SERVER['HTTPS']))
                || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']));
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

requestId accesses the super-global variable $_SERVER.
Open

    public static function requestId(): string
    {
        if (empty(self::$requestId)) {
            self::$requestId = sprintf('%08x', abs(crc32($_SERVER['REMOTE_ADDR'] . $_SERVER['REQUEST_TIME_FLOAT'] . $_SERVER['REMOTE_PORT'])));
        }
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

isHttps accesses the super-global variable $_SERVER.
Open

    public static function isHttps(): bool
    {
        if (!isset(self::$httpsCache)) {
            self::$httpsCache = (!empty($_SERVER['HTTPS']) && 'off' !== strtolower($_SERVER['HTTPS']))
                || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']));
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getBrowserInfo accesses the super-global variable $_SERVER.
Open

    public static function getBrowserInfo(): object
    {
        if (empty(self::$browserCache)) {
            $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));

Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

isHttps accesses the super-global variable $_SERVER.
Open

    public static function isHttps(): bool
    {
        if (!isset(self::$httpsCache)) {
            self::$httpsCache = (!empty($_SERVER['HTTPS']) && 'off' !== strtolower($_SERVER['HTTPS']))
                || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']));
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

isHttps accesses the super-global variable $_SERVER.
Open

    public static function isHttps(): bool
    {
        if (!isset(self::$httpsCache)) {
            self::$httpsCache = (!empty($_SERVER['HTTPS']) && 'off' !== strtolower($_SERVER['HTTPS']))
                || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']));
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getRemoteIP accesses the super-global variable $_SERVER.
Open

    public static function getRemoteIP($onlyIP = false)
    {
        $address = Request::_getServer('REMOTE_ADDR');
        if ($onlyIP) {
            return empty($address) ? '' : $address;
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getBrowserInfo accesses the super-global variable $_SERVER.
Open

    public static function getBrowserInfo(): object
    {
        if (empty(self::$browserCache)) {
            $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));

Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

requestId accesses the super-global variable $_SERVER.
Open

    public static function requestId(): string
    {
        if (empty(self::$requestId)) {
            self::$requestId = sprintf('%08x', abs(crc32($_SERVER['REMOTE_ADDR'] . $_SERVER['REQUEST_TIME_FLOAT'] . $_SERVER['REMOTE_PORT'])));
        }
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

requestId accesses the super-global variable $_SERVER.
Open

    public static function requestId(): string
    {
        if (empty(self::$requestId)) {
            self::$requestId = sprintf('%08x', abs(crc32($_SERVER['REMOTE_ADDR'] . $_SERVER['REQUEST_TIME_FLOAT'] . $_SERVER['REMOTE_PORT'])));
        }
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getRemoteIP accesses the super-global variable $_SERVER.
Open

    public static function getRemoteIP($onlyIP = false)
    {
        $address = Request::_getServer('REMOTE_ADDR');
        if ($onlyIP) {
            return empty($address) ? '' : $address;
Severity: Minor
Found in app/RequestUtil.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Consider simplifying this complex logical expression.
Open

        if (empty(self::$browserCache)) {
            $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));

            $browser = new \stdClass();
            $browser->ver = 0;
Severity: Critical
Found in app/RequestUtil.php - About 4 hrs to fix

    Function getBrowserInfo has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getBrowserInfo(): object
        {
            if (empty(self::$browserCache)) {
                $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));
    
    
    Severity: Minor
    Found in app/RequestUtil.php - About 4 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    The class RequestUtil has an overall complexity of 55 which is very high. The configured complexity threshold is 50.
    Open

    class RequestUtil
    {
        /** @var stdClass Browser cache variable. */
        protected static $browserCache;
    
    
    Severity: Minor
    Found in app/RequestUtil.php by phpmd

    Method getBrowserInfo has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getBrowserInfo(): object
        {
            if (empty(self::$browserCache)) {
                $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));
    
    
    Severity: Major
    Found in app/RequestUtil.php - About 2 hrs to fix

      Function getRemoteIP has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getRemoteIP($onlyIP = false)
          {
              $address = Request::_getServer('REMOTE_ADDR');
              if ($onlyIP) {
                  return empty($address) ? '' : $address;
      Severity: Minor
      Found in app/RequestUtil.php - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      The method getBrowserInfo() has an NPath complexity of 1601. The configured NPath complexity threshold is 200.
      Open

          public static function getBrowserInfo(): object
          {
              if (empty(self::$browserCache)) {
                  $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));
      
      
      Severity: Minor
      Found in app/RequestUtil.php by phpmd

      NPathComplexity

      Since: 0.1

      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

      Example

      class Foo {
          function bar() {
              // lots of complicated code
          }
      }

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

      The method getBrowserInfo() has a Cyclomatic Complexity of 33. The configured cyclomatic complexity threshold is 10.
      Open

          public static function getBrowserInfo(): object
          {
              if (empty(self::$browserCache)) {
                  $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));
      
      
      Severity: Minor
      Found in app/RequestUtil.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

      Refactor this function to reduce its Cognitive Complexity from 37 to the 15 allowed.
      Open

          public static function getBrowserInfo(): object
      Severity: Critical
      Found in app/RequestUtil.php by sonar-php

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

      Avoid using undefined variables such as '$remoteIp' which will lead to PHP notices.
      Open

                  $remoteIp[] = 'X-Real-IP: ' . Request::_getServer('HTTP_X_REAL_IP');
      Severity: Minor
      Found in app/RequestUtil.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$remoteIp' which will lead to PHP notices.
      Open

              if (!empty($remoteIp)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$remoteIp' which will lead to PHP notices.
      Open

                  $address .= '(' . implode(',', $remoteIp) . ')';
      Severity: Minor
      Found in app/RequestUtil.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$remoteIp' which will lead to PHP notices.
      Open

                      $remoteIp[] = "$key: " . Request::_getServer($key);
      Severity: Minor
      Found in app/RequestUtil.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Missing class import via use statement (line '77', column '19').
      Open

                  $browser = new \stdClass();
      Severity: Minor
      Found in app/RequestUtil.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 getRemoteIP has a boolean flag argument $onlyIP, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public static function getRemoteIP($onlyIP = false)
      Severity: Minor
      Found in app/RequestUtil.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

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

                  } else {
                      $browser->lang = 'en';
                  }
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getRemoteIP'.
      Open

                      $remoteIp[] = "$key: " . Request::_getServer($key);
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getBrowserInfo'.
      Open

                  $dirPath = explode('/', Request::_getServer('SCRIPT_NAME'));
      Severity: Minor
      Found in app/RequestUtil.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 getBrowserInfo uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      $browser->name = 'unknow';
                  }
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getBrowserInfo'.
      Open

                  $host = Request::_getServer('HTTP_X_FORWARDED_HOST', Request::_getServer('HTTP_HOST', ''));
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getBrowserInfo'.
      Open

                  $browser->requestUri = ltrim(Request::_getServer('REQUEST_URI'), '/');
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getRemoteIP'.
      Open

              $address = Request::_getServer('REMOTE_ADDR');
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getRemoteIP'.
      Open

                  $remoteIp[] = 'X-Real-IP: ' . Request::_getServer('HTTP_X_REAL_IP');
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getBrowserInfo'.
      Open

                  $browser->url = $protocol . '://' . $host . Request::_getServer('REQUEST_URI');
      Severity: Minor
      Found in app/RequestUtil.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 '\App\Cache' in method 'getIpByName'.
      Open

                  return \App\Cache::get(__METHOD__, $name);
      Severity: Minor
      Found in app/RequestUtil.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 '\App\Cache' in method 'getIpByName'.
      Open

              if (\App\Cache::has(__METHOD__, $name)) {
      Severity: Minor
      Found in app/RequestUtil.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 '\App\Request' in method 'getBrowserInfo'.
      Open

                  $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getBrowserInfo'.
      Open

                  $host = $host ?? Request::_getServer('SERVER_NAME') . $port;
      Severity: Minor
      Found in app/RequestUtil.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 '\App\Cache' in method 'getIpByName'.
      Open

              return \App\Cache::save(__METHOD__, $name, $ip);
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getBrowserInfo'.
      Open

                  $sp = strtolower(Request::_getServer('SERVER_PROTOCOL'));
      Severity: Minor
      Found in app/RequestUtil.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 'App\Request' in method 'getBrowserInfo'.
      Open

                  $host = Request::_getServer('HTTP_X_FORWARDED_HOST', Request::_getServer('HTTP_HOST', ''));
      Severity: Minor
      Found in app/RequestUtil.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 '\App\Config' in method 'isNetConnection'.
      Open

              if (!\App\Config::performance('ACCESS_TO_INTERNET')) {
      Severity: Minor
      Found in app/RequestUtil.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

      Variable $remoteIp was undeclared, but array fields are being added to it.
      Open

                  $remoteIp[] = 'X-Real-IP: ' . Request::_getServer('HTTP_X_REAL_IP');
      Severity: Info
      Found in app/RequestUtil.php by phan

      Property \App\RequestUtil::$browserCache has undeclared type \App\stdClass (Did you mean class \stdClass)
      Open

          protected static $browserCache;
      Severity: Minor
      Found in app/RequestUtil.php by phan

      Assigning \stdClass to property but \App\RequestUtil::$browserCache is \App\stdClass
      Open

                  self::$browserCache = $browser;
      Severity: Minor
      Found in app/RequestUtil.php by phan

      Returning type bool but getIpByName() is declared to return string
      Open

              return \App\Cache::save(__METHOD__, $name, $ip);
      Severity: Minor
      Found in app/RequestUtil.php by phan

      Returning type false but getIpByName() is declared to return string
      Open

                  return false;
      Severity: Minor
      Found in app/RequestUtil.php by phan

      This branch's code block is the same as the block for the branch on line 91.
      Open

                  } elseif (false !== strpos($browserAgent, 'trident')) { //For Supporting IE 11
                      $browser->name = 'Internet explorer';
                  } elseif (false !== strpos($browserAgent, 'firefox')) {
      Severity: Major
      Found in app/RequestUtil.php by sonar-php

      Having two cases in a switch statement or two branches in an if chain with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if chain they should be combined, or for a switch, one should fall through to the other.

      Noncompliant Code Example

      switch ($i) {
        case 1:
          doSomething();
          break;
        case 2:
          doSomethingDifferent();
          break;
        case 3:  // Noncompliant; duplicates case 1's implementation
          doSomething();
          break;
        default:
          doTheRest();
      }
      
      if ($a >= 0 && $a < 10) {
        doTheThing();
      else if ($a >= 10 && $a < 20) {
        doTheOtherThing();
      }
      else if ($a >= 20 && $a < 50) {
        doTheThing();  // Noncompliant; duplicates first condition
      }
      else {
        doTheRest();
      }
      
      if ($b == 0) {
        doOneMoreThing();
      }
      else {
        doOneMoreThing(); // Noncompliant; duplicates then-branch
      }
      
      var b = a ? 12 > 4 : 4;  // Noncompliant; always results in the same value
      

      Compliant Solution

      switch ($i) {
        case 1:
        case 3:
          doSomething();
          break;
        case 2:
          doSomethingDifferent();
          break;
        default:
          doTheRest();
      }
      
      if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) {
        doTheThing();
      else if ($a >= 10 && $a < 20) {
        doTheOtherThing();
      }
      else {
        doTheRest();
      }
      
      doOneMoreThing();
      
      b = 4;
      

      or

      switch ($i) {
        case 1:
          doSomething();
          break;
        case 2:
          doSomethingDifferent();
          break;
        case 3:
          doThirdThing();
          break;
        default:
          doTheRest();
      }
      
      if ($a >= 0 && $a < 10) {
        doTheThing();
      else if ($a >= 10 && $a < 20) {
        doTheOtherThing();
      }
      else if ($a >= 20 && $a < 50) {
        doTheThirdThing();
      }
      else {
        doTheRest();
      }
      
      if ($b == 0) {
        doOneMoreThing();
      }
      else {
        doTheRest();
      }
      
      int b = a ? 12 > 4 : 8;
      

      Exceptions

      Blocks in an if chain that contain a single line of code are ignored, as are blocks in a switch statement that contain a single line of code with or without a following break.

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

              $ip = gethostbyname($name);
      Severity: Minor
      Found in app/RequestUtil.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 $sp. Configured minimum length is 3.
      Open

                  $sp = strtolower(Request::_getServer('SERVER_PROTOCOL'));
      Severity: Minor
      Found in app/RequestUtil.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

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @var string[]
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /** @var string Cache request id variable. */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /** @var bool Net connection cache. */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /** @var stdClass Browser cache variable. */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * IP fields names variable.
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /** @var bool Cache https check variable. */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          protected static $requestId;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          protected static $httpsCache;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          protected static $connectionCache;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          protected static $browserCache;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'HTTP_CF_CONNECTING_IP',
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->unix = false !== strpos($browserAgent, 'unix');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->name = 'Mozilla Firefox';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } elseif (preg_match('/(chrome|msie|version|khtml)(\s*|\/)([0-9.]+)/', $browserAgent, $regs)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->lang = $regs[1];
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->url = $protocol . '://' . $host . Request::_getServer('REQUEST_URI');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function isNetConnection(): bool
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @return bool
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function isHttps(): bool
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param string $name
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @return string
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $ip = gethostbyname($name);
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function getRemoteIP($onlyIP = false)
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              // append the NGINX X-Real-IP header, if set
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->chrome = !$browser->opera && false !== strpos($browserAgent, 'chrome');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $browserAgent, $regs)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $host = $host ?? Request::_getServer('SERVER_NAME') . $port;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->siteUrl = $protocol . '://' . $host . $dirPath . '/';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * Check net connection.
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (isset(self::$connectionCache)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->webkit = false !== strpos($browserAgent, 'applewebkit');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } elseif (false !== strpos($browserAgent, 'opera')) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->name = 'Safari';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  return false;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->name = 'Google Chrome';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($browser->opera) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->requestUri = ltrim(Request::_getServer('REQUEST_URI'), '/');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * Get the IP address corresponding to a given Internet host name.
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  return false;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  return empty($address) ? '' : $address;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * Get browser details.
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @return object
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } elseif (false !== strpos($browserAgent, 'firefox')) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $dirPath = implode('/', $dirPath);
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if ($ip === $name) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'HTTP_X_FORWARDED',
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'HTTP_FORWARDED_FOR',
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->linux = false !== strpos($browserAgent, 'linux');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->safari = !$browser->opera && !$browser->chrome && ($browser->webkit || false !== strpos($browserAgent, 'safari'));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  self::$browserCache = $browser;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Line exceeds 120 characters; contains 143 characters
      Open

                  self::$requestId = sprintf('%08x', abs(crc32($_SERVER['REMOTE_ADDR'] . $_SERVER['REQUEST_TIME_FLOAT'] . $_SERVER['REMOTE_PORT'])));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return empty($address) ? '' : $address;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->ns = false !== strpos($browserAgent, 'netscape');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Line exceeds 120 characters; contains 148 characters
      Open

                  $browser->ie = !$browser->opera && (false !== strpos($browserAgent, 'compatible; msie') || false !== strpos($browserAgent, 'trident/'));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->name = 'Internet explorer';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } else {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } else {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $port = isset($_SERVER['SERVER_PORT']) ? (int) $_SERVER['SERVER_PORT'] : 0;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return self::$browserCache;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @return bool
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function getIpByName(string $name): string
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if ($onlyIP) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              foreach (self::$ipFields as $key) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function getBrowserInfo(): object
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Line exceeds 120 characters; contains 136 characters
      Open

                  $browser->safari = !$browser->opera && !$browser->chrome && ($browser->webkit || false !== strpos($browserAgent, 'safari'));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } elseif (false !== strpos($browserAgent, 'safari')) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->ver = (float) $regs[3];
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (\App\Cache::has(__METHOD__, $name)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          ];
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (!empty($_SERVER['HTTP_X_REAL_IP'])) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (empty(self::$browserCache)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $remoteIp[] = 'X-Real-IP: ' . Request::_getServer('HTTP_X_REAL_IP');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  return \App\Cache::get(__METHOD__, $name);
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } elseif (false !== strpos($browserAgent, 'chrome')) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                          $browser->ver = (float) $regs[2];
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  return self::$connectionCache;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @return string
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Line exceeds 120 characters; contains 136 characters
      Open

                  $browser->opera = false !== strpos($browserAgent, 'opera') || ($browser->webkit && false !== strpos($browserAgent, 'opr/'));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->mz = !$browser->ie && !$browser->safari && !$browser->chrome && !$browser->ns && !$browser->opera && false !== strpos($browserAgent, 'mozilla');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->name = 'Internet explorer';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * Check that the connection is https.
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (!isset(self::$httpsCache)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return self::$httpsCache;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * Get request id.
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'HTTP_X_CLUSTER_CLIENT_IP',
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->win = false !== strpos($browserAgent, 'win');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->opera = false !== strpos($browserAgent, 'opera') || ($browser->webkit && false !== strpos($browserAgent, 'opr/'));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $protocol = substr($sp, 0, strpos($sp, '/')) . (($browser->https) ? 's' : '');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (!\App\Config::performance('ACCESS_TO_INTERNET')) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (!self::isNetConnection()) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'HTTP_X_FORWARDED_FOR',
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $address = Request::_getServer('REMOTE_ADDR');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (!empty($remoteIp)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $address .= '(' . implode(',', $remoteIp) . ')';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browserAgent = strtolower(\App\Request::_getServer('HTTP_USER_AGENT', ''));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->mac = false !== strpos($browserAgent, 'mac');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } elseif (false !== strpos($browserAgent, 'trident')) { //For Supporting IE 11
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      if (preg_match('/(opera|opr)\/([0-9.]+)/', $browserAgent, $regs)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->https = self::isHttps();
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $host = Request::_getServer('HTTP_X_FORWARDED_HOST', Request::_getServer('HTTP_HOST', ''));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $dirPath = explode('/', Request::_getServer('SCRIPT_NAME'));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'HTTP_CLIENT_IP',
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $remoteIp[] = "$key: " . Request::_getServer($key);
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->ver = 0;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Line exceeds 120 characters; contains 166 characters
      Open

                  $browser->mz = !$browser->ie && !$browser->safari && !$browser->chrome && !$browser->ns && !$browser->opera && false !== strpos($browserAgent, 'mozilla');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->name = 'Opera Mini';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->name = 'unknow';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  array_pop($dirPath);
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function requestId(): string
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          protected static $ipFields = [
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if (isset($_SERVER[$key])) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $sp = strtolower(Request::_getServer('SERVER_PROTOCOL'));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  self::$httpsCache = (!empty($_SERVER['HTTPS']) && 'off' !== strtolower($_SERVER['HTTPS']))
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Line exceeds 120 characters; contains 126 characters
      Open

                      || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'HTTP_FORWARDED',
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser = new \stdClass();
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $browser->ie = !$browser->opera && (false !== strpos($browserAgent, 'compatible; msie') || false !== strpos($browserAgent, 'trident/'));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if (false !== strpos($browserAgent, 'msie')) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } elseif (false !== strpos($browserAgent, 'opera mini')) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->name = 'Opera';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  } elseif (preg_match('/rv:([0-9.]+)/', $browserAgent, $regs)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->ver = (float) $regs[1];
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $browser->lang = 'en';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $port = ((!$browser->https && 80 === $port) || ($browser->https && 443 === $port)) ? '' : ':' . $port;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return self::$connectionCache = 'www.google.com' !== gethostbyname('www.google.com');
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $ip = '';
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return \App\Cache::save(__METHOD__, $name, $ip);
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (empty(self::$requestId)) {
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return self::$requestId;
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  self::$requestId = sprintf('%08x', abs(crc32($_SERVER['REMOTE_ADDR'] . $_SERVER['REQUEST_TIME_FLOAT'] . $_SERVER['REMOTE_PORT'])));
      Severity: Minor
      Found in app/RequestUtil.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status