mambax7/publisher

View on GitHub
class/PermissionHandler.php

Summary

Maintainability
A
2 hrs
Test Coverage

getGrantedItems accesses the super-global variable $GLOBALS.
Open

    public function getGrantedItems($gpermName)
    {
        static $items;
        if (isset($items[$gpermName])) {
            return $items[$gpermName];
Severity: Minor
Found in class/PermissionHandler.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

getGrantedItems accesses the super-global variable $GLOBALS.
Open

    public function getGrantedItems($gpermName)
    {
        static $items;
        if (isset($items[$gpermName])) {
            return $items[$gpermName];
Severity: Minor
Found in class/PermissionHandler.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 getGrantedGroupsById has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getGrantedGroupsById($gpermName, $id)
    {
        static $items;
        if (isset($items[$gpermName][$id])) {
            return $items[$gpermName][$id];
Severity: Minor
Found in class/PermissionHandler.php - About 1 hr to fix

    Method getGrantedItems has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getGrantedItems($gpermName)
        {
            static $items;
            if (isset($items[$gpermName])) {
                return $items[$gpermName];
    Severity: Minor
    Found in class/PermissionHandler.php - About 1 hr to fix

      Missing class import via use statement (line '61', column '17').
      Open

                  new \Criteria(
      Severity: Minor
      Found in class/PermissionHandler.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

      Missing class import via use statement (line '106', column '17').
      Open

                  new \Criteria(
      Severity: Minor
      Found in class/PermissionHandler.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

      Missing class import via use statement (line '116', column '33').
      Open

                  $criteria2->add(new \Criteria('gperm_groupid', $gid), 'OR');
      Severity: Minor
      Found in class/PermissionHandler.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

      Missing class import via use statement (line '59', column '25').
      Open

              $criteria = new \CriteriaCompo();
      Severity: Minor
      Found in class/PermissionHandler.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

      Missing class import via use statement (line '67', column '28').
      Open

              $criteria->add(new \Criteria('gperm_itemid', $id));
      Severity: Minor
      Found in class/PermissionHandler.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

      Missing class import via use statement (line '104', column '25').
      Open

              $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $gpermName));
      Severity: Minor
      Found in class/PermissionHandler.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

      Missing class import via use statement (line '114', column '26').
      Open

              $criteria2 = new \CriteriaCompo();
      Severity: Minor
      Found in class/PermissionHandler.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

      Missing class import via use statement (line '104', column '44').
      Open

              $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $gpermName));
      Severity: Minor
      Found in class/PermissionHandler.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

      Missing class import via use statement (line '66', column '28').
      Open

              $criteria->add(new \Criteria('gperm_name', $gpermName));
      Severity: Minor
      Found in class/PermissionHandler.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 '\XoopsDatabaseFactory' in method 'getGrantedItems'.
      Open

              $db     = \XoopsDatabaseFactory::getDatabaseConnection();
      Severity: Minor
      Found in class/PermissionHandler.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 '\XoopsDatabaseFactory' in method 'getGrantedGroupsById'.
      Open

              $db    = \XoopsDatabaseFactory::getDatabaseConnection();
      Severity: Minor
      Found in class/PermissionHandler.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 'XoopsModules\Publisher\Helper' in method '__construct'.
      Open

              $this->helper = $helper ?? Helper::getInstance();
      Severity: Minor
      Found in class/PermissionHandler.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 unused parameters such as '$db'.
      Open

          public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
      Severity: Minor
      Found in class/PermissionHandler.php by phpmd

      UnusedFormalParameter

      Since: 0.2

      Avoid passing parameters to methods or constructors and then not using those parameters.

      Example

      class Foo
      {
          private function bar($howdy)
          {
              // $howdy is not used
          }
      }

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

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

              $db    = \XoopsDatabaseFactory::getDatabaseConnection();
      Severity: Minor
      Found in class/PermissionHandler.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

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

              $db     = \XoopsDatabaseFactory::getDatabaseConnection();
      Severity: Minor
      Found in class/PermissionHandler.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

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

          public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
      Severity: Minor
      Found in class/PermissionHandler.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

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

          public function getGrantedGroupsById($gpermName, $id)
      Severity: Minor
      Found in class/PermissionHandler.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

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

          public function isGranted($gpermName, $id)
      Severity: Minor
      Found in class/PermissionHandler.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

      Only one argument is allowed per line in a multi-line function call
      Open

                      'gperm_modid', $this->helper->getModule()
      Severity: Minor
      Found in class/PermissionHandler.php by phpcodesniffer

      Only one argument is allowed per line in a multi-line function call
      Open

                      'gperm_modid', $this->helper->getModule()
      Severity: Minor
      Found in class/PermissionHandler.php by phpcodesniffer

      Only one argument is allowed per line in a multi-line function call
      Open

                               ->getVar('mid'), $gpermName, $itemId
      Severity: Minor
      Found in class/PermissionHandler.php by phpcodesniffer

      Only one argument is allowed per line in a multi-line function call
      Open

                               ->getVar('mid'), $gpermName, $itemId
      Severity: Minor
      Found in class/PermissionHandler.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status