Skip to content

PollingMonitorWatcher: redundant getFileInfo() call on SplFileInfo object #166

@s2x

Description

@s2x

Problem

In PollingMonitorWatcher, $file->getFileInfo()->getMTime() is called where $file is already an SplFileInfo instance (from Symfony Finder's iterator). Calling getFileInfo() on an SplFileInfo returns the same object, making it a redundant method call.

Location

  • src/Reboot/FileMonitorWatcher/PollingMonitorWatcher.php, line 45

Current Code

/** @var \SplFileInfo $file */
foreach ($this->finder as $file) {
    $filePath = $file->getRealPath();
    $currentMTime = $file->getFileInfo()->getMTime();  // redundant getFileInfo()
    // ...
}

Proposed Fix

foreach ($this->finder as $file) {
    $filePath = $file->getRealPath();
    $currentMTime = $file->getMTime();
    // ...
}

Priority

🟢 MINOR — redundant call; no functional impact but misleading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualityCode quality improvementsminorMinor priority - code quality

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions