public function seeRightPathConvert() { $data = ['phar:///test\\data\\.\\..\\..\\data/.////./Windows/\\..\\../.\\data1.phar' => 'phar:///data1.phar', 'phar://' => 'phar://' . getcwd(), 'phar://C:\\test\\./data\\.\\..\\..\\data/.////./Windows/\\../.\\data.phar' => 'phar://C:/data/data.phar', __DIR__ . '/../../.' => realpath(__DIR__ . '/../../.')]; foreach ($data as $path => $expected) { $this->assertEquals($expected, helpers\FileHelper::realPath($path)); } }
/** * @return string */ public function getRelativePath() { $path = substr(FileHelper::realPath($this->iterator->current()->getPathname()), strlen($this->initPath)); if ($path[0] === '/') { $path = substr($path, 1); } return $path; }