Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Filesystem] Add the Path class #41954

Open
wants to merge 25 commits into
base: 5.4
Choose a base branch
from

Conversation

@theofidry
Copy link
Contributor

@theofidry theofidry commented Jul 2, 2021

Q A
Branch? 5.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #26523
License MIT
Doc PR TODO

Re-opening #30969 as requested by @fabpot.

This PR proposes a low-level, performant and pure API to manipulate file paths.

Two methods Path::isAbsolute() and Path::isRelative() are similar to Filesystem::isAbsolutePath() and Filesystem::makePathRelative(). They are however different as the methods from Path do not check the existence of the path which is very helpful in some scenarios (for example when manipulating virtual paths such as "regular" paths of a PHAR).

The original code comes from webmozart/path-util from which the path part was extracted. The library is very stable, well tested and documented. It has been heavily used in Puli, which although is no longer active has been a good performance test and is used in several other popular projects such as:

  • vimeo/psalm
  • drush/drush
  • infection/infection
  • humbug/box
  • humbug/php-scoper
  • phpbench/phpbench

It however suffers from lack of maintener from @webmozart which no longer has time to maintain it.

@theofidry theofidry force-pushed the theofidry:feature/path-component branch from 67755b1 to aaa6d2a Jul 2, 2021
* ".." segments at the beginning of relative paths are not removed.
*
* ```php
* echo Path::canonicalize("\webmozart\puli\..\css\style.css");

This comment has been minimized.

@OskarStark

OskarStark Jul 3, 2021
Contributor

While I would agree keeping this as credits, should we change "webmozart" to "symfony" in examples?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants