Replace the code block:
with the following one:
$isWin = 'WIN' === strtoupper(substr(PHP_OS, 0, 3)); /** @var bool $isWin */
$realPath = $this->fileDriver->getRealPath($path); /** @var string $realPath */
foreach ($directories as $directory) {
if (0 === strpos($realPath, !$isWin ? $directory : str_replace('/', DIRECTORY_SEPARATOR, $directory))) {
For other Magento versions:
- For Magento ≥ 2.4.5
- For 2.3 ≤ Magento < 2.4.5