gielfeldt/iterators

View on GitHub

Showing 65 of 69 total issues

Missing class import via use statement (line '16', column '32').
Open

        $this->iterators = new \InfiniteIterator($this->realIterators);
Severity: Minor
Found in src/InterleaveIterator.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 '71', column '30').
Open

        $outerIterator = new \ArrayIterator([$limitedInnerIterator]);
Severity: Minor
Found in src/ChunkIterator.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 '34', column '31').
Open

        $sortedIterator = new \ArrayIterator();
Severity: Minor
Found in src/SortIterator.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 '89', column '23').
Open

            throw new \RuntimeException("File: " . $realPath . " already opened!");
Severity: Minor
Found in src/AtomicTempFileObjects.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 '12', column '38').
Open

        $iterator = $iterator ?? new \EmptyIterator();
Severity: Minor
Found in src/ReplaceableIterator.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

Remove error control operator '@' on line 80.
Open

    private function doPersist()
    {
        if (!@rename($this->getRealPath(), $this->destinationRealPath)) {
            // @codeCoverageIgnoreStart
            $lastError = error_get_last();
Severity: Minor
Found in src/AtomicTempFileObject.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Remove error control operator '@' on line 24.
Open

    public function __construct(string $filename, $mode = 0755)
    {
        $tempDir = dirname($filename);
        if (!file_exists($tempDir)) {
            if (!@mkdir($tempDir, $mode, true)) {
Severity: Minor
Found in src/AtomicTempFileObject.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Missing class import via use statement (line '103', column '23').
Open

            throw new \RuntimeException(
Severity: Minor
Found in src/AtomicTempFileObject.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 '43', column '23').
Open

            throw new \RuntimeException("File: $fileName not opened!");
Severity: Minor
Found in src/AtomicTempFileObjects.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 '35', column '25').
Open

        $iterator = new \IteratorIterator($iterator);
Severity: Minor
Found in src/Iterator.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 '13', column '23').
Open

            throw new \InvalidArgumentException('An instance of RecursiveIterator or IteratorAggregate creating it is required');
Severity: Minor
Found in src/RecursiveSortIterator.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 '11', column '23').
Open

            throw new \InvalidArgumentException('An instance of RecursiveIterator or IteratorAggregate creating it is required');
Severity: Minor
Found in src/RecursiveCloningIterator.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 '18', column '76').
Open

        $this->iterator = $iterator instanceof \Iterator ? $iterator : new \IteratorIterator($iterator);
Severity: Minor
Found in src/ReplaceableIterator.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 '14', column '23').
Open

            throw new \InvalidArgumentException('Count cannot be less than 0.');
Severity: Minor
Found in src/RepeatIterator.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 '19', column '33').
Open

        $shuffledIterator = new \ArrayIterator();
Severity: Minor
Found in src/ShuffleIterator.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 '11', column '23').
Open

            throw new \InvalidArgumentException('An instance of RecursiveIterator or IteratorAggregate creating it is required');
Severity: Minor
Found in src/RecursiveMapIterator.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

Function accept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function accept()
    {
        foreach ($this->iterators as $iterator) {
            foreach ($iterator as $key => $value) {
                if (($this->callback)($this->getInnerIterator(), $key, $value)) {
Severity: Minor
Found in src/DiffIterator.php - About 25 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

Function compare has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function compare(AtomicTempFileObject $tempFile): bool
    {
        $filename = $tempFile->getDestinationRealPath();
        if (!file_exists($filename)) {
            return false;
Severity: Minor
Found in src/AtomicTempFileObject.php - About 25 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

Function __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct(string $globPattern, int $flags = self::GLOB_NOSORT | \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO)
    {
        $this->flags = $flags;
        list($path, $maxDepth) = self::extractPathAndMaxDepth($globPattern);
        $regexPattern = self::globToRegex($globPattern);
Severity: Minor
Found in src/GlobIterator.php - About 25 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 unused parameters such as '$iterator'.
Open

    protected function generateElement($key, $value, $iterator)
Severity: Minor
Found in src/SortIterator.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

Severity
Category
Status
Source
Language