Skip to content

[Filesystem] Add documentation for the Path class #15759

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

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

theofidry
Copy link
Contributor

@theofidry theofidry commented Aug 29, 2021

Closes #15621

@theofidry
Copy link
Contributor Author

This is a first iteration of the documentation. I'm not very familiar with the documentation workflow/process neither with its conventions regarding the doc organisation or choice of vocabulary so I have no doubt that a few changes will be needed there

@theofidry
Copy link
Contributor Author

/cc @chalasr

The component contains two classes:

- The :class:`Symfony\\Component\\Filesystem\\Filesystem` which provides utilities
for filesystem write operations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only write, right?

@OskarStark OskarStark added this to the 5.4 milestone Aug 29, 2021
Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Théo, thanks for this contribution! I left some minor comments, but your work is really nice and it will be mergeable very soon. Thanks!

@@ -236,6 +247,11 @@ Its behavior is the following::
* if ``$path`` does not exist, it returns null.
* if ``$path`` exists, it returns its absolute fully resolved final version.

.. note::

If you wish to canonicalize the path without checking its existence, you can
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading this might be confusing if you don't know what "canonicalize the path" exactly means.


- "." segments are removed;
- ".." segments are resolved;
- backslashes ("\") are converted into forward slashes ("/");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this "backslash to forward-slash" transform applied unconditionally? Even on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC yes, the idea being you should compare normalized paths (there is a Path::normalize()) method as otherwise you are always susceptible to surprises (e.g. to expect a certain hard-coded unix style path but you are on Windows hence the path you are comparing to is invalid)

@javiereguiluz javiereguiluz merged commit 44fd61e into symfony:5.4 Nov 18, 2021
@javiereguiluz
Copy link
Member

Thanks Théo for contributing not only this feature but its docs as well 🙏

@theofidry theofidry deleted the feature/path branch November 18, 2021 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Filesystem] Add the Path class
4 participants