$path]; $dirname = dirname($path); if ('' !== $dirname) { $pathInfo['dirname'] = $dirname === '.' ? '' : $dirname; } $pathInfo += pathinfo($this->basename($path)); $pathInfo['basename'] = $pathInfo['filename']; // phpcs:enable Magento2.Functions.DiscouragedFunction return $pathInfo + ['dirname' => '']; } /** * Get basename for path. * * @param string $path * @return string */ private function basename($path) { $separators = DIRECTORY_SEPARATOR === '/' ? '/' : '\/'; $path = rtrim($path, $separators); return preg_replace('#.*?([^' . preg_quote($separators, '#') . ']+$)#', '$1', $path); } }