lib/Ajde/Exception/Handler.php

Summary

Maintainability
D
2 days
Test Coverage

The method Ajde_Exception_Handler::trace() calls the typical debug function var_dump() which is mostly only used during development.
Open

                        var_dump($item['args']);
Severity: Minor
Found in lib/Ajde/Exception/Handler.php by phpmd

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

The method Ajde_Exception_Handler::trace() calls the typical debug function var_dump() which is mostly only used during development.
Open

                                var_dump($dump[0]);
Severity: Minor
Found in lib/Ajde/Exception/Handler.php by phpmd

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

trace accesses the super-global variable $_SERVER.
Open

    public static function trace($exception, $output = self::EXCEPTION_TRACE_HTML)
    {
        $simpleJsonTrace = false;
        if ($simpleJsonTrace && Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
            $output = self::EXCEPTION_TRACE_LOG;
Severity: Minor
Found in lib/Ajde/Exception/Handler.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

Method trace has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function trace($exception, $output = self::EXCEPTION_TRACE_HTML)
    {
        $simpleJsonTrace = false;
        if ($simpleJsonTrace && Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
            $output = self::EXCEPTION_TRACE_LOG;
Severity: Major
Found in lib/Ajde/Exception/Handler.php - About 4 hrs to fix

    Function trace has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function trace($exception, $output = self::EXCEPTION_TRACE_HTML)
        {
            $simpleJsonTrace = false;
            if ($simpleJsonTrace && Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
                $output = self::EXCEPTION_TRACE_LOG;
    Severity: Minor
    Found in lib/Ajde/Exception/Handler.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 Ajde_Exception_Handler has an overall complexity of 78 which is very high. The configured complexity threshold is 50.
    Open

    class Ajde_Exception_Handler extends Ajde_Object_Static
    {
        const EXCEPTION_TRACE_HTML = 1;
        const EXCEPTION_TRACE_ONLY = 3;
        const EXCEPTION_TRACE_LOG = 2;
    Severity: Minor
    Found in lib/Ajde/Exception/Handler.php by phpmd

    File Handler.php has 280 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    class Ajde_Exception_Handler extends Ajde_Object_Static
    {
        const EXCEPTION_TRACE_HTML = 1;
    Severity: Minor
    Found in lib/Ajde/Exception/Handler.php - About 2 hrs to fix

      Method embedScript has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected static function embedScript($filename = null, $line = null, $arguments = null, $expand = false)
          {
              $lineOffset = 5;
              $file = '';
      
      
      Severity: Minor
      Found in lib/Ajde/Exception/Handler.php - About 1 hr to fix

        Function embedScript has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            protected static function embedScript($filename = null, $line = null, $arguments = null, $expand = false)
            {
                $lineOffset = 5;
                $file = '';
        
        
        Severity: Minor
        Found in lib/Ajde/Exception/Handler.php - About 1 hr 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

        Method getErrorType has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getErrorType($type)
            {
                switch ($type) {
                    case 1:
                        return 'E_ERROR';
        Severity: Minor
        Found in lib/Ajde/Exception/Handler.php - About 1 hr to fix

          Function handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function handler($exception)
              {
                  try {
                      if (config('app.debug') === true) {
                          if (!((get_class($exception) == 'Ajde_Exception' || is_subclass_of($exception, 'Ajde_Exception')) && !$exception->traceOnOutput())
          Severity: Minor
          Found in lib/Ajde/Exception/Handler.php - About 45 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

          Avoid too many return statements within this method.
          Open

                          return 'E_DEPRECATED';
          Severity: Major
          Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return 'E_CORE_ERROR';
            Severity: Major
            Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return 'E_USER_ERROR';
              Severity: Major
              Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return Ajde_Log::CHANNEL_EXCEPTION;
                Severity: Major
                Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return 'E_USER_DEPRECATED';
                  Severity: Major
                  Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return 'E_COMPILE_WARNING';
                    Severity: Major
                    Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return 'E_USER_WARNING';
                      Severity: Major
                      Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return 'E_USER_NOTICE';
                        Severity: Major
                        Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return 'E_COMPILE_ERROR';
                          Severity: Major
                          Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return 'E_STRICT';
                            Severity: Major
                            Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return 'E_CORE_WARNING';
                              Severity: Major
                              Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return 'E_RECOVERABLE_ERROR';
                                Severity: Major
                                Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return Ajde_Log::LEVEL_ERROR;
                                  Severity: Major
                                  Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return 'E_ALL';
                                    Severity: Major
                                    Found in lib/Ajde/Exception/Handler.php - About 30 mins to fix

                                      The method trace() has an NPath complexity of 16360. The configured NPath complexity threshold is 200.
                                      Open

                                          public static function trace($exception, $output = self::EXCEPTION_TRACE_HTML)
                                          {
                                              $simpleJsonTrace = false;
                                              if ($simpleJsonTrace && Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
                                                  $output = self::EXCEPTION_TRACE_LOG;
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 trace() has 124 lines of code. Current threshold is set to 100. Avoid really long methods.
                                      Open

                                          public static function trace($exception, $output = self::EXCEPTION_TRACE_HTML)
                                          {
                                              $simpleJsonTrace = false;
                                              if ($simpleJsonTrace && Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
                                                  $output = self::EXCEPTION_TRACE_LOG;
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by phpmd

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

                                          public static function getErrorType($type)
                                          {
                                              switch ($type) {
                                                  case 1:
                                                      return 'E_ERROR';
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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

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

                                          public static function trace($exception, $output = self::EXCEPTION_TRACE_HTML)
                                          {
                                              $simpleJsonTrace = false;
                                              if ($simpleJsonTrace && Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
                                                  $output = self::EXCEPTION_TRACE_LOG;
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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

                                      The method embedScript has a boolean flag argument $expand, which is a certain sign of a Single Responsibility Principle violation.
                                      Open

                                          protected static function embedScript($filename = null, $line = null, $arguments = null, $expand = false)
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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

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

                                                  throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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

                                      Avoid using static access to class 'Ajde_Exception_Log' in method 'handler'.
                                      Open

                                                          Ajde_Exception_Log::logException($exception);
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 handler uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                      Open

                                                  } else {
                                                      Ajde_Exception_Log::logException($exception);
                                                      Ajde_Http_Response::redirectServerError();
                                                  }
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 'Ajde_Http_Response' in method 'handler'.
                                      Open

                                                      Ajde_Http_Response::redirectServerError();
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 'Kint' in method 'trace'.
                                      Open

                                                                      Kint::dump($dump[0]);
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 getExceptionChannelMap uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                      Open

                                              } else {
                                                  return Ajde_Log::CHANNEL_EXCEPTION;
                                              }
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 embedScript uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                      Open

                                                      } else {
                                                          $file .= $lineNumber.' '.($lines[$i]);
                                                      }
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 assigning values to variables in if clauses and the like (line '130', column '25').
                                      Open

                                          public static function trace($exception, $output = self::EXCEPTION_TRACE_HTML)
                                          {
                                              $simpleJsonTrace = false;
                                              if ($simpleJsonTrace && Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
                                                  $output = self::EXCEPTION_TRACE_LOG;
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by phpmd

                                      IfStatementAssignment

                                      Since: 2.7.0

                                      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                                      Example

                                      class Foo
                                      {
                                          public function bar($flag)
                                          {
                                              if ($foo = 'bar') { // possible typo
                                                  // ...
                                              }
                                              if ($baz = 0) { // always false
                                                  // ...
                                              }
                                          }
                                      }

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

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

                                              } else {
                                                  $type = 'PHP exception '.$exception->getCode();
                                              }
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 'Ajde_Http_Response' in method 'handler'.
                                      Open

                                                          Ajde_Http_Response::redirectServerError();
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 'Ajde_Exception_Log' in method 'handler'.
                                      Open

                                                          Ajde_Exception_Log::logException($exception);
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 'Ajde_Core_Documentation' in method 'trace'.
                                      Open

                                                              Ajde_Core_Documentation::getUrl($exception->getCode()),
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 trace uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                      Open

                                                                  } else {
                                                                      echo '<pre>';
                                                                      var_dump($dump[0]);
                                                                      echo '</pre>';
                                                                  }
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 handler uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                      Open

                                                      } else {
                                                          Ajde_Exception_Log::logException($exception);
                                                          Ajde_Http_Response::redirectServerError();
                                                      }
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 'Ajde_Exception_Log' in method 'handler'.
                                      Open

                                                      Ajde_Exception_Log::logException($exception);
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 trace uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                      Open

                                                      } else {
                                                          $collapsed = '<div id="details">'.$exceptionDump.$exceptionMessage.$traceMessage.'</div>';
                                                          $header = '<header><h1><img src="'.config('app.rootUrl').MEDIA_DIR.'ajde-small.png">Something went wrong</h1><a href="javascript:history.go(-1);">Go back</a> <a href="#details">Show details</a></header>';
                                                      }
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 getExceptionLevelMap uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                      Open

                                              } else {
                                                  return Ajde_Log::LEVEL_ERROR;
                                              }
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 'Ajde_Dump' in method 'trace'.
                                      Open

                                                          if ($dumps = Ajde_Dump::getAll()) {
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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 handler() contains an exit expression.
                                      Open

                                                  die('An uncatched exception occured within the error handler, see the server error_log for details');
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by phpmd

                                      ExitExpression

                                      Since: 0.2

                                      An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                                      Example

                                      class Foo {
                                          public function bar($param)  {
                                              if ($param === 42) {
                                                  exit(23);
                                              }
                                          }
                                      }

                                      Source https://phpmd.org/rules/design.html#exitexpression

                                      Avoid using count() function in for loops.
                                      Open

                                                  for ($i = max(0, $line - $lineOffset - 1); $i < min($line + $lineOffset, count($lines)); $i++) {
                                                      $lineNumber = str_repeat(' ', 4 - strlen($i + 1)).($i + 1);
                                                      if ($i == $line - 1) {
                                                          $file .= '{{{}}}'.$lineNumber.' '.($lines[$i]).'{{{/}}}';
                                                      } else {
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by phpmd

                                      CountInLoopExpression

                                      Since: 2.7.0

                                      Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

                                      Example

                                      class Foo {
                                      
                                        public function bar()
                                        {
                                          $array = array();
                                      
                                          for ($i = 0; count($array); $i++) {
                                            // ...
                                          }
                                        }
                                      }

                                      Source https://phpmd.org/rules/design.html#countinloopexpression

                                      TODO found
                                      Open

                                                  // TODO: only possible in PHP >= 5.3 ?
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by fixme

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

                                                      $exceptionDocumentation = '';
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by phpmd

                                      LongVariable

                                      Since: 0.2

                                      Detects when a field, formal or local variable is declared with a long name.

                                      Example

                                      class Something {
                                          protected $reallyLongIntName = -3; // VIOLATION - Field
                                          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                              $otherReallyLongName = -5; // VIOLATION - Local
                                              for ($interestingIntIndex = 0; // VIOLATION - For
                                                   $interestingIntIndex < 10;
                                                   $interestingIntIndex++ ) {
                                              }
                                          }
                                      }

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

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

                                          public static $firstApplicationFileExpanded = false;
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by phpmd

                                      LongVariable

                                      Since: 0.2

                                      Detects when a field, formal or local variable is declared with a long name.

                                      Example

                                      class Something {
                                          protected $reallyLongIntName = -3; // VIOLATION - Field
                                          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                              $otherReallyLongName = -5; // VIOLATION - Local
                                              for ($interestingIntIndex = 0; // VIOLATION - For
                                                   $interestingIntIndex < 10;
                                                   $interestingIntIndex++ ) {
                                              }
                                          }
                                      }

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

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

                                              $id = md5(microtime().$filename.$line);
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.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

                                      The class Ajde_Exception_Handler is not named in CamelCase.
                                      Open

                                      class Ajde_Exception_Handler extends Ajde_Object_Static
                                      {
                                          const EXCEPTION_TRACE_HTML = 1;
                                          const EXCEPTION_TRACE_ONLY = 3;
                                          const EXCEPTION_TRACE_LOG = 2;
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by phpmd

                                      CamelCaseClassName

                                      Since: 0.2

                                      It is considered best practice to use the CamelCase notation to name classes.

                                      Example

                                      class class_name {
                                      }

                                      Source

                                      The method __bootstrap is not named in camelCase.
                                      Open

                                          public static function __bootstrap()
                                          {
                                              // making xdebug.overload_var_dump = 1 work
                                              if (config('app.debug')) {
                                                  ini_set('html_errors', 1);
                                      Severity: Minor
                                      Found in lib/Ajde/Exception/Handler.php by phpmd

                                      CamelCaseMethodName

                                      Since: 0.2

                                      It is considered best practice to use the camelCase notation to name methods.

                                      Example

                                      class ClassName {
                                          public function get_name() {
                                          }
                                      }

                                      Source

                                      There are no issues that match your filters.

                                      Category
                                      Status