bkdotcom/PHPDebugConsole

View on GitHub
src/Debug/Collector/MySqli.php

Summary

Maintainability
A
0 mins
Test Coverage
B
86%

Method real_connect has 7 arguments (exceeds 4 allowed). Consider refactoring.
Wontfix

    public function real_connect($host = null, $username = null, $passwd = null, $dbname = null, $port = null, $socket = null, $flags = null)
Severity: Major
Found in src/Debug/Collector/MySqli.php - About 50 mins to fix

    Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Wontfix

        public function __construct($host = null, $username = null, $passwd = null, $dbname = null, $port = null, $socket = null, $debug = null) // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
    Severity: Major
    Found in src/Debug/Collector/MySqli.php - About 50 mins to fix

      Rename "$debug" which has the same name as the field declared at line 45.
      Open

              $debug = $event->getSubject();
      Severity: Major
      Found in src/Debug/Collector/MySqli.php by sonar-php

      Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

      Noncompliant Code Example

      class Foo {
        public $myField;
      
        public function doSomething() {
          $myField = 0;
          ...
        }
      }
      

      See

      Remove this unused private "currentDatabase" method.
      Open

          private function currentDatabase()
      Severity: Major
      Found in src/Debug/Collector/MySqli.php by sonar-php

      private methods that are never executed are dead code: unnecessary, inoperative code that should be removed. Cleaning out dead code decreases the size of the maintained codebase, making it easier to understand the program and preventing bugs from being introduced.

      Noncompliant Code Example

      public class Foo
      {
        private function Foo() {}   // Compliant, private empty constructor intentionally used to prevent any direct instantiation of a class.
      
        public static function doSomething()
        {
          $foo = new Foo();
          ...
        }
      
        private function unusedPrivateFunction() {  // Noncompliant
        }
      }
      

      Compliant Solution

      public class Foo
      {
        private function Foo(){}   // Compliant, private empty constructor intentionally used to prevent any direct instantiation of a class.
      
        public static function doSomething()
        {
          $foo = new Foo();
        }
      }
      

      See

      Define and throw a dedicated exception instead of using a generic one.
      Open

                  throw new RuntimeException($errstr, $errno);
      Severity: Major
      Found in src/Debug/Collector/MySqli.php by sonar-php

      If you throw a general exception type, such as ErrorException, RuntimeException, or Exception in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle.

      Instead, either throw a subtype that already exists in the Standard PHP Library, or create your own type that derives from Exception.

      Noncompliant Code Example

      throw new Exception();  // Noncompliant
      

      Compliant Solution

      throw new InvalidArgumentException();
      // or
      throw new UnexpectedValueException();
      

      See

      There are no issues that match your filters.

      Category
      Status