PascalHonegger/M151

View on GitHub
Location/FileManager.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using undefined variables such as '$image' which will lead to PHP notices.
Open

                array_push($validImages, $image);
Severity: Minor
Found in Location/FileManager.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

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

        $this->model = new ImageModel();
Severity: Minor
Found in Location/FileManager.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 unused local variables such as '$image'.
Open

                array_push($validImages, $image);
Severity: Minor
Found in Location/FileManager.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Avoid using count() function in for loops.
Open

        for ($i = 0; $i < count($validImages); $i++) {
            $targetFile = "../images/" . $this->model->createImage($idLocation) . '.' . pathinfo($images['name'][$i], PATHINFO_EXTENSION);
            move_uploaded_file($images['tmp_name'][$i], $targetFile);
        }
Severity: Minor
Found in Location/FileManager.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

Avoid using count() function in for loops.
Open

        for ($i = 0; $i < count($images['error']); $i++) {
            if ($images['error'][$i] == 0) {
                array_push($validImages, $image);
            }
        }
Severity: Minor
Found in Location/FileManager.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

There are no issues that match your filters.

Category
Status