yiisoft/yii2

View on GitHub
framework/web/UploadedFile.php

Summary

Maintainability
A
1 hr
Test Coverage

loadFiles accesses the super-global variable $_FILES.
Open

    private static function loadFiles()
    {
        if (self::$_files === null) {
            self::$_files = [];
            if (isset($_FILES) && is_array($_FILES)) {
Severity: Minor
Found in framework/web/UploadedFile.php by phpmd

Since: PHPMD 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: http://phpmd.org/rules/controversial.txt

loadFiles accesses the super-global variable $_FILES.
Open

    private static function loadFiles()
    {
        if (self::$_files === null) {
            self::$_files = [];
            if (isset($_FILES) && is_array($_FILES)) {
Severity: Minor
Found in framework/web/UploadedFile.php by phpmd

Since: PHPMD 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: http://phpmd.org/rules/controversial.txt

loadFiles accesses the super-global variable $_FILES.
Open

    private static function loadFiles()
    {
        if (self::$_files === null) {
            self::$_files = [];
            if (isset($_FILES) && is_array($_FILES)) {
Severity: Minor
Found in framework/web/UploadedFile.php by phpmd

Since: PHPMD 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: http://phpmd.org/rules/controversial.txt

Method loadFilesRecursive has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private static function loadFilesRecursive($key, $names, $tempNames, $types, $sizes, $errors)
Severity: Minor
Found in framework/web/UploadedFile.php - About 45 mins to fix

    Function loadFiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function loadFiles()
        {
            if (self::$_files === null) {
                self::$_files = [];
                if (isset($_FILES) && is_array($_FILES)) {
    Severity: Minor
    Found in framework/web/UploadedFile.php - About 35 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

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

        public function saveAs($file, $deleteTempFile = true)
    Severity: Minor
    Found in framework/web/UploadedFile.php by phpmd

    Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

    The variable $_files is not named in camelCase.
    Open

        private static function loadFilesRecursive($key, $names, $tempNames, $types, $sizes, $errors)
        {
            if (is_array($names)) {
                foreach ($names as $i => $name) {
                    self::loadFilesRecursive($key . '[' . $i . ']', $name, $tempNames[$i], $types[$i], $sizes[$i], $errors[$i]);
    Severity: Minor
    Found in framework/web/UploadedFile.php by phpmd

    Since: PHPMD 0.2

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

    Example:

    class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

    Source: http://phpmd.org/rules/controversial.txt

    There are no issues that match your filters.

    Category
    Status