qcubed/framework

View on GitHub
includes/base_controls/QTreeNav.class.php

Summary

Maintainability
D
2 days
Test Coverage

ParsePostData accesses the super-global variable $_POST.
Open

        public function ParsePostData() {
            if (array_key_exists('Qform__FormControl', $_POST) && ($_POST['Qform__FormControl'] == $this->strControlId)) {
                if ($_POST['Qform__FormEvent'] == 'QChangeEvent') {
                    $strParameter = $_POST['Qform__FormParameter'];
                    $objItem = $this->GetItem($strParameter);

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

ParsePostData accesses the super-global variable $_POST.
Open

        public function ParsePostData() {
            if (array_key_exists('Qform__FormControl', $_POST) && ($_POST['Qform__FormControl'] == $this->strControlId)) {
                if ($_POST['Qform__FormEvent'] == 'QChangeEvent') {
                    $strParameter = $_POST['Qform__FormParameter'];
                    $objItem = $this->GetItem($strParameter);

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

ParsePostData accesses the super-global variable $_POST.
Open

        public function ParsePostData() {
            if (array_key_exists('Qform__FormControl', $_POST) && ($_POST['Qform__FormControl'] == $this->strControlId)) {
                if ($_POST['Qform__FormEvent'] == 'QChangeEvent') {
                    $strParameter = $_POST['Qform__FormParameter'];
                    $objItem = $this->GetItem($strParameter);

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

ParsePostData accesses the super-global variable $_POST.
Open

        public function ParsePostData() {
            if (array_key_exists('Qform__FormControl', $_POST) && ($_POST['Qform__FormControl'] == $this->strControlId)) {
                if ($_POST['Qform__FormEvent'] == 'QChangeEvent') {
                    $strParameter = $_POST['Qform__FormParameter'];
                    $objItem = $this->GetItem($strParameter);

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

ParsePostData accesses the super-global variable $_POST.
Open

        public function ParsePostData() {
            if (array_key_exists('Qform__FormControl', $_POST) && ($_POST['Qform__FormControl'] == $this->strControlId)) {
                if ($_POST['Qform__FormEvent'] == 'QChangeEvent') {
                    $strParameter = $_POST['Qform__FormParameter'];
                    $objItem = $this->GetItem($strParameter);

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

ParsePostData accesses the super-global variable $_POST.
Open

        public function ParsePostData() {
            if (array_key_exists('Qform__FormControl', $_POST) && ($_POST['Qform__FormControl'] == $this->strControlId)) {
                if ($_POST['Qform__FormEvent'] == 'QChangeEvent') {
                    $strParameter = $_POST['Qform__FormParameter'];
                    $objItem = $this->GetItem($strParameter);

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 __set has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function __set($strName, $mixValue) {
            switch ($strName) {
                case "ItemCssStyle":
                    try {
                        $this->strItemCssStyle = QType::Cast($mixValue, QType::String);
Severity: Major
Found in includes/base_controls/QTreeNav.class.php - About 3 hrs to fix

    Function __set has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

            public function __set($strName, $mixValue) {
                switch ($strName) {
                    case "ItemCssStyle":
                        try {
                            $this->strItemCssStyle = QType::Cast($mixValue, QType::String);
    Severity: Minor
    Found in includes/base_controls/QTreeNav.class.php - About 3 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

    File QTreeNav.class.php has 306 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
        /**
         * This file contains the QTreeNav class.
         *
         * @package Controls
    Severity: Minor
    Found in includes/base_controls/QTreeNav.class.php - About 3 hrs to fix

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

          class QTreeNav extends QControl {
              protected $strJavaScripts = 'treenav.js';
      
              protected $strItemCssStyle = 'treenav_item';
              protected $strItemSelectedCssStyle = 'treenav_item treenav_item_selected';

      Method GetItemHtml has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              protected function GetItemHtml($objItem) {
                  $strItemId = $this->strControlId . '_' . $objItem->ItemId;
      
                  $objChildren = $objItem->ChildItemArray;
                  $intChildCount = count($objChildren);
      Severity: Major
      Found in includes/base_controls/QTreeNav.class.php - About 2 hrs to fix

        Function GetItemHtml has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

                protected function GetItemHtml($objItem) {
                    $strItemId = $this->strControlId . '_' . $objItem->ItemId;
        
                    $objChildren = $objItem->ChildItemArray;
                    $intChildCount = count($objChildren);
        Severity: Minor
        Found in includes/base_controls/QTreeNav.class.php - About 2 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 QTreeNav has 19 fields. Consider redesigning QTreeNav to keep the number of fields under 15.
        Open

            class QTreeNav extends QControl {
                protected $strJavaScripts = 'treenav.js';
        
                protected $strItemCssStyle = 'treenav_item';
                protected $strItemSelectedCssStyle = 'treenav_item treenav_item_selected';

        TooManyFields

        Since: 0.1

        Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

        Example

        class Person {
           protected $one;
           private $two;
           private $three;
           [... many more fields ...]
        }

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

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

                public function ParsePostData() {
                    if (array_key_exists('Qform__FormControl', $_POST) && ($_POST['Qform__FormControl'] == $this->strControlId)) {
                        if ($_POST['Qform__FormEvent'] == 'QChangeEvent') {
                            $strParameter = $_POST['Qform__FormParameter'];
                            $objItem = $this->GetItem($strParameter);
        Severity: Minor
        Found in includes/base_controls/QTreeNav.class.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

                        case "ItemHeight": return $this->intItemHeight;
        Severity: Major
        Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          case "ItemHoverCssStyle": return $this->strItemHoverCssStyle;
          Severity: Major
          Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            case "IndentWidth": return $this->intIndentWidth;
            Severity: Major
            Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              case "ItemWidth": return $this->intItemWidth;
              Severity: Major
              Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                case "ItemSelectedCssStyle": return $this->strItemSelectedCssStyle;
                Severity: Major
                Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  case "ItemArray": return (array) $this->objItemArray;
                  Severity: Major
                  Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    case "ItemCssStyle": return $this->strItemCssStyle;
                    Severity: Major
                    Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      case "ExpandOnSelect": return $this->blnExpandOnSelect;
                      Severity: Major
                      Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                                return parent::__get($strName);
                        Severity: Major
                        Found in includes/base_controls/QTreeNav.class.php - About 30 mins to fix

                          The method GetItemHtml() has an NPath complexity of 220. The configured NPath complexity threshold is 200.
                          Open

                                  protected function GetItemHtml($objItem) {
                                      $strItemId = $this->strControlId . '_' . $objItem->ItemId;
                          
                                      $objChildren = $objItem->ChildItemArray;
                                      $intChildCount = count($objChildren);

                          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 __set() has 114 lines of code. Current threshold is set to 100. Avoid really long methods.
                          Open

                                  public function __set($strName, $mixValue) {
                                      switch ($strName) {
                                          case "ItemCssStyle":
                                              try {
                                                  $this->strItemCssStyle = QType::Cast($mixValue, QType::String);

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

                                  public function __get($strName) {
                                      switch ($strName) {
                                          case "SelectedItem": return $this->objSelectedTreeNavItem;
                                          case "SelectedValue":
                                              if ($this->objSelectedTreeNavItem)

                          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 GetItemHtml() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                          Open

                                  protected function GetItemHtml($objItem) {
                                      $strItemId = $this->strControlId . '_' . $objItem->ItemId;
                          
                                      $objChildren = $objItem->ChildItemArray;
                                      $intChildCount = count($objChildren);

                          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 __set() has a Cyclomatic Complexity of 26. The configured cyclomatic complexity threshold is 10.
                          Open

                                  public function __set($strName, $mixValue) {
                                      switch ($strName) {
                                          case "ItemCssStyle":
                                              try {
                                                  $this->strItemCssStyle = QType::Cast($mixValue, QType::String);

                          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

                          Missing class import via use statement (line '161', column '15').
                          Open

                                          throw new QCallerException('Item Id already exists in QTreeNav ' . $this->strControlId . ': ' . $objItem->ItemId, 2);

                          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 GetItemHtml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                      } else {
                                          // No Children -- we are displaying an End Node
                                          $strImageHtml = '<span style="margin-right: 2px;"><img src="' . __VIRTUAL_DIRECTORY__ . __IMAGE_ASSETS__ .
                                              '/treenav_child.png" width="11" height="11" alt="" style="position: relative; top: 2px;"/></span>';
                                      }

                          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 'QType' in method '__set'.
                          Open

                                                  $this->intItemHeight = QType::Cast($mixValue, QType::Integer);

                          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 'QApplication' in method 'ParsePostData'.
                          Open

                                              QApplication::ExecuteJavaScript('treenavRedrawElement("' . $strParameter . '", "' . $strItemHtml . '")');

                          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 'QType' in method '__set'.
                          Open

                                                  $this->strItemCssStyle = QType::Cast($mixValue, QType::String);

                          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 'QApplication' in method '__set'.
                          Open

                                                  QApplication::ExecuteJavaScript(sprintf("treenavItemUnselect('%s_%s_label', '%s')", $this->strControlId, $this->objSelectedTreeNavItem->ItemId, $this->strItemCssStyle));

                          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 'QType' in method '__set'.
                          Open

                                                  $objItem = QType::Cast($mixValue, "QTreeNavItem");

                          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 'QApplication' in method '__construct'.
                          Open

                                      $this->strLabelForRequired = QApplication::Translate('%s is required');

                          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 'QType' in method '__set'.
                          Open

                                                  $this->blnExpandOnSelect = QType::Cast($mixValue, QType::Boolean);

                          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 'QApplication' in method '__construct'.
                          Open

                                      $this->strLabelForRequiredUnnamed = QApplication::Translate('Required');

                          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 'QType' in method '__set'.
                          Open

                                                  $this->strItemHoverCssStyle = QType::Cast($mixValue, QType::String);

                          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 'QType' in method '__set'.
                          Open

                                                  $this->intItemWidth = QType::Cast($mixValue, QType::Integer);

                          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 'QApplication' in method 'ParsePostData'.
                          Open

                                              QApplication::ExecuteJavaScript('treenavRedrawElement("' . $strParameter . '", "' . $strItemHtml . '")');

                          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 GetItemHtml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                          } else {
                                              $strSubNodeHtml = sprintf('<div id="%s_sub" style="margin-left: %spx; display: none;"><span class="%s" style="cursor: auto;">%s...</span></div>',
                                                  $strItemId,
                                                  $this->intIndentWidth,
                                                  $this->strItemCssStyle,

                          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 '368', column '10').
                          Open

                                  public function __set($strName, $mixValue) {
                                      switch ($strName) {
                                          case "ItemCssStyle":
                                              try {
                                                  $this->strItemCssStyle = QType::Cast($mixValue, QType::String);

                          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

                          Avoid using static access to class 'QType' in method '__set'.
                          Open

                                                  $this->intIndentWidth = QType::Cast($mixValue, QType::Integer);

                          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 'QApplication' in method 'GetItemHtml'.
                          Open

                                                  QApplication::Translate('Loading')

                          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 'QType' in method '__set'.
                          Open

                                                  $this->strItemSelectedCssStyle = QType::Cast($mixValue, QType::String);

                          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 excessively long variable names like $objSelectedTreeNavItem. Keep variable name length under 20.
                          Open

                                  protected $objSelectedTreeNavItem = null;

                          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 $strItemSelectedCssStyle. Keep variable name length under 20.
                          Open

                                  protected $strItemSelectedCssStyle = 'treenav_item treenav_item_selected';

                          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 $strLabelForRequiredUnnamed. Keep variable name length under 20.
                          Open

                                  protected $strLabelForRequiredUnnamed;

                          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 $strItemSelectedHoverCssStyle. Keep variable name length under 20.
                          Open

                                  protected $strItemSelectedHoverCssStyle = 'treenav_item treenav_item_hover treenav_item_selected';

                          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

                          The method Validate is not named in camelCase.
                          Open

                                  public function Validate() {
                                      // Check for Required
                                      if ($this->blnRequired && $this->SelectedItem === null)
                                      {
                                          if ($this->strName)

                          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

                          The method GetControlHtml is not named in camelCase.
                          Open

                                  public function GetControlHtml() {
                                      $strAttributes = $this->GetAttributes();
                                      $strStyles = $this->GetStyleAttributes();
                          
                                      if ($strStyles)

                          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

                          The method GetItem is not named in camelCase.
                          Open

                                  public function GetItem($strItemId) {
                                      if (strpos($strItemId, '_') !== false) {
                                          $intIndexArray = explode('_', $strItemId);
                                          $strItemId = $intIndexArray[1];
                                      }

                          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

                          The method GenerateItemId is not named in camelCase.
                          Open

                                  public function GenerateItemId() {
                                      $strToReturn = 'i' . $this->intNextItemId;
                                      $this->intNextItemId++;
                                      return $strToReturn;
                                  }

                          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

                          The method GetItemHtml is not named in camelCase.
                          Open

                                  protected function GetItemHtml($objItem) {
                                      $strItemId = $this->strControlId . '_' . $objItem->ItemId;
                          
                                      $objChildren = $objItem->ChildItemArray;
                                      $intChildCount = count($objChildren);

                          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

                          The method AddItem is not named in camelCase.
                          Open

                                  public function AddItem(QTreeNavItem $objItem) {
                                      if (array_key_exists($objItem->ItemId, $this->objItemArray))
                                          throw new QCallerException('Item Id already exists in QTreeNav ' . $this->strControlId . ': ' . $objItem->ItemId, 2);
                                      $this->objItemArray[$objItem->ItemId] = $objItem;
                                  }

                          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

                          The method ParsePostData is not named in camelCase.
                          Open

                                  public function ParsePostData() {
                                      if (array_key_exists('Qform__FormControl', $_POST) && ($_POST['Qform__FormControl'] == $this->strControlId)) {
                                          if ($_POST['Qform__FormEvent'] == 'QChangeEvent') {
                                              $strParameter = $_POST['Qform__FormParameter'];
                                              $objItem = $this->GetItem($strParameter);

                          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

                          The method SetLoader is not named in camelCase.
                          Open

                                  public function SetLoader($strFuncName, $objParent)
                                  {
                                      $this->strLoader = $strFuncName;
                                      $this->objLoaderParent = $objParent;
                                  }

                          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

                          The method Clear is not named in camelCase.
                          Open

                                  public function Clear()
                                  {
                                      $this->objChildItemArray = array();
                                      $this->objItemArray = array();
                                      $this->intNextItemId = 1;

                          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

                          The method AddChildItem is not named in camelCase.
                          Open

                                  public function AddChildItem(QTreeNavItem $objItem) {
                                      array_push($this->objChildItemArray, $objItem);
                                  }

                          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