Expand description
Exact ports of Composer\Util\Filesystem: normalizePath,
findShortestPath, findShortestPathCode (Composer 2.10.3). They decide
the paths written into installed.json/installed.php, the autoload files
and the bin proxies; checked by tests/oracle_installers.rs.
Unix paths only (no C:/file:// prefix).
Functions§
- canonicalize
std::fs::canonicalizewithout the Windows verbatim prefix (\\?\). PHPrealpath()(and therefore Composer) returns classic Win32 paths (C:\x), andnormalize_pathwould turn\\?\C:\xinto//?/C:/x— a form neither the Win32 APIs nor the paths generated into the autoload files understand. Elsewhere:std::fs::canonicalizeas-is.- find_
shortest_ path Filesystem::findShortestPath($from, $to, $directories, $preferRelative = false). Both paths must be absolute.- find_
shortest_ path_ code Filesystem::findShortestPathCode($from, $to, $directories, $staticCode, $preferRelative = false): a PHP expression relative to__DIR__.- is_
absolute_ path Filesystem::isAbsolutePath:/…,\…,C:/…/C:\…, or a stream wrapper (phar://…). On Unix only/exists in practice; thestarts_with('/')form of the test missed Windows drive-letter paths.- normalize_
path Filesystem::normalizePath: single slashes,./..resolution, no trailing slash (except for the root).- php_str
var_export()of a string: single quotes,\and'escaped.