10000 chore(filesystem): improve docblock descriptions by jrmajor · Pull Request #345 · azjezz/psl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore(filesystem): improve docblock descriptions #345

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 3 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/component/filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- [canonicalize](./../../src/Psl/Filesystem/canonicalize.php#L15)
- [change_group](./../../src/Psl/Filesystem/change_group.php#L21)
- [change_owner](./../../src/Psl/Filesystem/change_owner.php#L21)
- [change_permissions](./../../src/Psl/Filesystem/change_permissions.php#L20)
- [change_permissions](./../../src/Psl/Filesystem/change_permissions.php#L21)
- [copy](./../../src/Psl/Filesystem/copy.php#L22)
- [create_directory](./../../src/Psl/Filesystem/create_directory.php#L19)
- [create_file](./../../src/Psl/Filesystem/create_file.php#L24)
Expand All @@ -28,25 +28,25 @@
- [create_temporary_file](./../../src/Psl/Filesystem/create_temporary_file.php#L26)
- [delete_directory](./../../src/Psl/Filesystem/delete_directory.php#L23)
- [delete_file](./../../src/Psl/Filesystem/delete_file.php#L21)
- [exists](./../../src/Psl/Filesystem/exists.php#L21)
- [exists](./../../src/Psl/Filesystem/exists.php#L16)
- [file_size](./../../src/Psl/Filesystem/file_size.php#L22)
- [get_access_time](./../../src/Psl/Filesystem/get_access_time.php#L20)
- [get_basename](./../../src/Psl/Filesystem/get_basename.php#L23)
- [get_change_time](./../../src/Psl/Filesystem/get_change_time.php#L21)
- [get_change_time](./../../src/Psl/Filesystem/get_change_time.php#L23)
- [get_directory](./../../src/Psl/Filesystem/get_directory.php#L24)
- [get_extension](./../../src/Psl/Filesystem/get_extension.php#L18)
- [get_filename](./../../src/Psl/Filesystem/get_filename.php#L20)
- [get_group](./../../src/Psl/Filesystem/get_group.php#L20)
- [get_inode](./../../src/Psl/Filesystem/get_inode.php#L20)
- [get_modification_time](./../../src/Psl/Filesystem/get_modification_time.php#L20)
- [get_modification_time](./../../src/Psl/Filesystem/get_modification_time.php#L22)
- [get_owner](./../../src/Psl/Filesystem/get_owner.php#L20)
- [get_permissions](./../../src/Psl/Filesystem/get_permissions.php#L20)
- [is_directory](./../../src/Psl/Filesystem/is_directory.php#L21)
- [is_executable](./../../src/Psl/Filesystem/is_executable.php#L19)
- [is_file](./../../src/Psl/Filesystem/is_file.php#L21)
- [is_readable](./../../src/Psl/Filesystem/is_readable.php#L19)
- [is_symbolic_link](./../../src/Psl/Filesystem/is_symbolic_link.php#L19)
- [is_writable](./../../src/Psl/Filesystem/is_writable.php#L19)
- [is_directory](./../../src/Psl/Filesystem/is_directory.php#L15)
- [is_executable](./../../src/Psl/Filesystem/is_executable.php#L15)
- [is_file](./../../src/Psl/Filesystem/is_file.php#L15)
- [is_readable](./../../src/Psl/Filesystem/is_readable.php#L14)
- [is_symbolic_link](./../../src/Psl/Filesystem/is_symbolic_link.php#L14)
- [is_writable](./../../src/Psl/Filesystem/is_writable.php#L14)
- [read_directory](./../../src/Psl/Filesystem/read_directory.php#L21)
- [read_symbolic_link](./../../src/Psl/Filesystem/read_symbolic_link.php#L23)

Expand Down
2 changes: 1 addition & 1 deletion src/Psl/File/WriteMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enum WriteMode: string
* the file.
*
* If the file exits, it is not truncated (as with `TRUNCATE`), and the call
* succeeds (unlike `EXCLUSIVE_CREATE`).
* succeeds (unlike `MUST_CREATE`).
*/
case OPEN_OR_CREATE = 'cb';

Expand Down
4 changes: 2 additions & 2 deletions src/Psl/Filesystem/canonicalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

/**
* Returns canonicalized absolute pathname.
* The resulting path will have no symbolic links, '/./' or '/../' components.
*
* @return non-empty-string|null The canonicalized absolute pathname on success.
* The resulting path will have no symbolic link, '/./' or '/../' components.
* @return non-empty-string|null
*/
function canonicalize(string $path): ?string
{
Expand Down
3 changes: 2 additions & 1 deletion src/Psl/Filesystem/change_permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
use function chmod;

/**
* Changes mode permission of $node.
* Change permission mode of $node.
*
* @param non-empty-string $node
* @param int $permissions Permissions as an octal number, e.g. `0755`.
*
* @throws Exception\RuntimeException If unable to change the mode for the given $node.
* @throws Exception\NotFoundException If $node does not exist.
Expand Down
4 changes: 2 additions & 2 deletions src/Psl/Filesystem/copy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
use Psl\Str;

/**
* Copy $source to $destination and preserve executable permission bits.
* Copy a file from $source to $destination and preserve executable permission bits.
*
* @param non-empty-string $source
* @param non-empty-string $destination
*
* @throws Exception\RuntimeException If unable to change the group ownership for $filename.
* @throws Exception\RuntimeException If unable to copy $source to $destination.
* @throws Exception\NotFoundException If $source is not found.
* @throws Exception\NotReadableException If $source is not readable.
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Psl/Filesystem/create_file.php
B422
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* Create the file specified by $filename.
*
* @param non-empty-string $filename
* @param int|null $time The touch time as a Unix timestamp,
* If not supplied the current system time is used.
* @param int|null $access_time The access time as a Unix timestamp,
* If not supplied the current system time is used.
* @param int|null $time The touch time as a Unix timestamp.
* Defaults to the current system time.
* @param int|null $access_time The access time as a Unix timestamp.
* Defaults to the current system time.
*
* @throws Exception\RuntimeException If unable to create the file.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/create_hard_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @param non-empty-string $source The file to create a hard link for.
* @param non-empty-string $destination
*
* @throws Exception\RuntimeException If unable to create a hard file.
* @throws Exception\RuntimeException If unable to create the hard link.
* @throws Exception\NotFoundException If $source does not exist.
* @throws Exception\NotFileException If $source is not a file.
* @throws Exception\NotReadableException If $destination is a non-empty directory, and is non-readable {@see delete_directory()}.
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/create_symbolic_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Create a symbolic link for $source.
*
* @param non-empty-string $source The file to create a hard link for.
* @param non-empty-string $source The file to create a symbolic link for.
* @param non-empty-string $destination
*
* @throws Exception\RuntimeException If unable to create the symbolic link.
Expand Down
4 changes: 2 additions & 2 deletions src/Psl/Filesystem/create_temporary_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
/**
* Create a temporary file.
*
* @param non-empty-string|null $directory The directory where the temporary filename will be created.
* If no specified, `Env\temp_dir()` will be used to retrieve
* @param non-empty-string|null $directory The directory where the temporary file will be created.
* If none specified, `Env\temp_dir()` will be used to retrieve
* the system default temporary directory.
* @param non-empty-string|null $prefix The prefix of the generated temporary filename.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/delete_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @throws Exception\RuntimeException If unable to delete the file.
* @throws Exception\NotFileException If $file is not a file.
* @throws Exception\NotFoundException If $file is not a found.
* @throws Exception\NotFoundException If $file is not found.
*/
function delete_file(string $file): void
{
Expand Down
7 changes: 1 addition & 6 deletions src/Psl/Filesystem/exists.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
/**
* Check whether $node exists.
*
* @param string $node Path to the file.
*
* If $node is a relative filename, it will be checked relative to
* the current working directory.
*
* @return bool true if $node exists, false otherwise.
* @param string $node Path, absolute or relative to the current working directory.
*
* @psalm-assert-if-true non-empty-string $node
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/file_size.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psl\Str;

/**
* Ge the size of $file.
* Get the size of $file.
*
* @param non-empty-string $file
*
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/get_access_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function fileatime;

/**
* Gets last access time of $node.
* Get last access time of $node.
*
* @param non-empty-string $node
*
Expand Down
10 changes: 5 additions & 5 deletions src/Psl/Filesystem/get_basename.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
use function basename as php_basename;

/**
* Returns trailing name component of path.
* Get the last component of $path.
*
* On Windows, both forward slash `/` and back slash `\` are used
* as directory separator character.
* On Windows, both forward slash `/` and backslash `\` are used
* as a directory separator character.
*
* In other environments, it is the forward slash `/`.
*
* @param non-empty-string|null $suffix If the filename ends in a suffix, this will also be cut off.
* @param non-empty-string|null $suffix If the filename ends in a suffix, it will also be cut off.
*
* @return non-empty-string the base name of the given path.
* @return non-empty-string
*
* @pure
*/
Expand Down
6 changes: 4 additions & 2 deletions src/Psl/Filesystem/get_change_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
use function filectime;

/**
* Get the last time the inode of $node
* was changed ( e.g: permission change, ownership change .. etc ).
* Get the last time the inode of $node was changed
* (e.g. permission change or ownership change).
*
* @param non-empty-string $node
*
* @throws Exception\NotFoundException If $node is not found.
* @throws Exception\RuntimeException In case of an error.
*
* @return int The last inode modification time as a Unix timestamp.
*/
function get_change_time(string $node): int
{
Expand Down
8 changes: 4 additions & 4 deletions src/Psl/Filesystem/get_directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
use function dirname;

/**
* Returns a parent directory's path.
* Get a parent directory path.
*
* On Windows, both forward slash `/` and back slash `\` are used
* as directory separator character.
* On Windows, both forward slash `/` and backslash `\` are used
* as a directory separator character.
*
* In other environments, it is the forward slash `/`.
*
* @param non-empty-string $node
* @param positive-int $levels The number of parent directories to go up.
*
* @return non-empty-string the base name of the given path.
* @return non-empty-string
*
* @pure
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Psl/Filesystem/get_extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
use function pathinfo;

/**
* Returns the $node extension.
* Get the $node extension.
*
* @param non-empty-string $node
*
* @return non-empty-string|null the $node extensions, or null if none.
* @return non-empty-string|null The $node extensions, or null if none.
*
* @pure
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Psl/Filesystem/get_filename.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
use const PATHINFO_FILENAME;

/**
* Returns trailing name component of path.
* Get the last component of $node, excluding extension.
*
* @param non-empty-string $node
*
* @return non-empty-string the base name of the given path.
* @return non-empty-string
*
* @pure
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/get_inode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function fileinode;

/**
* Get the last time the content of $node was modified.
* Get inode number of $node.
*
* @param non-empty-string $node
*
Expand Down
2 changes: 2 additions & 0 deletions src/Psl/Filesystem/get_modification_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
* @throws Exception\NotFoundException If $node is not found.
* @throws Exception\RuntimeException In case of an error.
*
* @return int The last content modification time as a Unix timestamp.
*/
function get_modification_time(string $node): int
{
Expand Down
12 changes: 3 additions & 9 deletions src/Psl/Filesystem/is_directory.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
use function is_dir;

/**
* Check whether $node is a directory.
* Check whether $node exists and is a directory.
*
* If $node is a relative filename, it will be checked relative to
* the current working directory.
*
* If $node is a symbolic or hard link then the link will be resolved and checked.
*
* @param non-empty-string $node
*
* @return bool true if $node exists and is a directory, false otherwise.
* @param non-empty-string $node Path, absolute or relative to the current working directory.
* If it is a link, it will be resolved and checked.
*/
function is_directory(string $node): bool
{
Expand Down
10 changes: 3 additions & 7 deletions src/Psl/Filesystem/is_executable.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
use function is_executable as php_is_executable;

/**
* Check whether $node is executable.
* Check whether $node exists and is an executable file
* or a directory with `execute` permission.
*
* If $node is a relative filename, it will be checked relative to
* the current working directory.
*
* @param non-empty-string $node
*
* @return bool true if the file or directory specified by $node exists and is executable, false otherwise.
* @param non-empty-string $node Path, absolute or relative to the current working directory.
*/
function is_executable(string $node): bool
{
Expand Down
12 changes: 3 additions & 9 deletions src/Psl/Filesystem/is_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
use function is_file as php_is_file;

/**
* Check whether $node is a regular file.
* Check whether $node exists and is a regular file or a link to one.
*
* If $node is a relative filename, it will be checked relative to
* the current working directory.
*
* If $node is a symbolic or hard link then the link will be resolved and checked.
*
* @param non-empty-string $node
*
* @return bool true if $node exists and is a regular file, false otherwise.
* @param non-empty-string $node Path, absolute or relative to the current working directory.
* If it is a link, it will be resolved and checked.
*/
function is_file(string $node): bool
{
Expand Down
9 changes: 2 additions & 7 deletions src/Psl/Filesystem/is_readable.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@
use function is_readable as php_is_readable;

/**
* Check whether $node is readable.
* Check whether $node exists and is readable.
*
* If $node is a relative filename, it will be checked relative to
* the current working directory.
*
* @param non-empty-string $node
*
* @return bool true if the file or directory specified by $node exists and is readable, false otherwise.
* @param non-empty-string $node Path, absolute or relative to the current working directory.
*/
function is_readable(string $node): bool
{
Expand Down
9 changes: 2 additions & 7 deletions src/Psl/Filesystem/is_symbolic_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@
use function is_link as php_is_link;

/**
* Check whether $symbolic_link is a symbolic link.
* Check whether $symbolic_link exists and is a symbolic link.
*
* If $node is a relative filename, it will be checked relative to
* the current working directory.
*
* @param non-empty-string $node
*
* @return bool true if the file or directory specified by $node exists and is a symbolic link, false otherwise.
* @param non-empty-string $node Path, absolute or relative to the current working directory.
*/
function is_symbolic_link(string $node): bool
{
Expand Down
9 changes: 2 additions & 7 deletions src/Psl/Filesystem/is_writable.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@
use function is_writable as php_is_writable;

/**
* Check whether $node is writable.
* Check whether $node exists and is writable.
*
* If $node is a relative filename, it will be checked relative to
* the current working directory.
*
* @param non-empty-string $node
*
* @return bool true if the file or directory specified by $node exists and is writable, false otherwise.
* @param non-empty-string $node Path, absolute or relative to the current working directory.
*/
function is_writable(string $node): bool
{
Expand Down
0