Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented May 10, 2024

... with some utility functions for handling file paths.

The class initially contains the following utility methods:

  • getName(File $phpcsFile): string - Retrieve the normalized file name for the current file.
  • isStdin(File $phpcsFile): bool - Check whether the current file under scan comes from STDIN.
  • normalizeAbsolutePath(string $path): string - Normalize an absolute path to forward slashes and to include a trailing slash for directories.
  • normalizeDirectorySeparators(string $path): string - Normalize all directory separators to be a forward slash.
  • trailingSlashIt(string $path): string - Ensure that a directory path ends on a trailing slash.
  • startsWith(string $haystack, string $needle): bool - Check whether one file/directory path starts with another path.

Includes unit tests.

@jrfnl jrfnl added this to the 1.1.0 milestone May 10, 2024
@jrfnl jrfnl changed the title ✨ New FilePath class ✨ New FilePath utility class May 10, 2024
@jrfnl jrfnl force-pushed the testutils/new-configdouble-utility-class branch 4 times, most recently from a675d0d to c61fa32 Compare May 13, 2024 11:30
@jrfnl
Copy link
Member Author

jrfnl commented May 13, 2024

Rebased without changes. Setting to draft as this PR depends on #550, which has to be merged first.

@jrfnl jrfnl marked this pull request as draft May 13, 2024 11:35
@jrfnl jrfnl force-pushed the utils/new-filepath-utility-class branch from 0b69380 to da08c72 Compare May 13, 2024 11:35
@jrfnl jrfnl force-pushed the testutils/new-configdouble-utility-class branch from c61fa32 to 4f0f9a4 Compare May 20, 2024 14:05
Base automatically changed from testutils/new-configdouble-utility-class to develop May 20, 2024 17:55
@jrfnl
Copy link
Member Author

jrfnl commented May 20, 2024

Rebased without changes after the merge of PR #550.

@jrfnl jrfnl force-pushed the utils/new-filepath-utility-class branch from da08c72 to 44629fe Compare May 20, 2024 18:17
... with some utility functions for handling file paths.

The class initially contains the following utility methods:
* `getName(File $phpcsFile): string` - Retrieve the normalized file name for the current file.
* `isStdin(File $phpcsFile): bool` - Check whether the current file under scan comes from STDIN.
* `normalizeAbsolutePath(string $path): string` - Normalize an absolute path to forward slashes and to include a trailing slash for directories.
* `normalizeDirectorySeparators(string $path): string` - Normalize all directory separators to be a forward slash.
* `trailingSlashIt(string $path): string` - Ensure that a directory path ends on a trailing slash.
* `startsWith(string $haystack, string $needle): bool` - Check whether one file/directory path starts with another path.

Includes unit tests.
@jrfnl
Copy link
Member Author

jrfnl commented May 23, 2024

Rebased without changes.
Marking as ready as #550 has been merged now. Merging once the build passes.

Note: I've looked the sniff over to check if any of the new exceptions from PR #598 should be implemented and concluded that things should be fine as-is. In all methods, it is either handled gracefully already or a param will be passed to a PHP native function, which may throw a type error. I think that should be sufficient.

@jrfnl jrfnl force-pushed the utils/new-filepath-utility-class branch from 44629fe to f87bfb4 Compare May 23, 2024 20:11
@jrfnl jrfnl marked this pull request as ready for review May 23, 2024 20:11
@jrfnl jrfnl merged commit b5ee7dc into develop May 23, 2024
@jrfnl jrfnl deleted the utils/new-filepath-utility-class branch May 23, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant