upgrade idiorm to php8.1-patched version (aaronpk/idiorm)

This commit is contained in:
Andrew Dolgov
2022-07-12 22:26:21 +03:00
parent 4b61618920
commit 80d3db1dcf
189 changed files with 17077 additions and 12739 deletions

View File

@@ -28,12 +28,12 @@ function chgrp(string $filename, $group): void
/**
* Attempts to change the mode of the specified file to that given in
* mode.
* permissions.
*
* @param string $filename Path to the file.
* @param int $mode Note that mode is not automatically
* @param int $permissions Note that permissions is not automatically
* assumed to be an octal value, so to ensure the expected operation,
* you need to prefix mode with a zero (0).
* you need to prefix permissions with a zero (0).
* Strings such as "g+w" will not work properly.
*
*
@@ -43,7 +43,7 @@ function chgrp(string $filename, $group): void
*
*
*
* The mode parameter consists of three octal
* The permissions parameter consists of three octal
* number components specifying access restrictions for the owner,
* the user group in which the owner is in, and to everybody else in
* this order. One component can be computed by adding up the needed
@@ -58,10 +58,10 @@ function chgrp(string $filename, $group): void
*
*
*/
function chmod(string $filename, int $mode): void
function chmod(string $filename, int $permissions): void
{
error_clear_last();
$result = \chmod($filename, $mode);
$result = \chmod($filename, $permissions);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
@@ -89,13 +89,13 @@ function chown(string $filename, $user): void
/**
* Makes a copy of the file source to
* dest.
* Makes a copy of the file from to
* to.
*
* If you wish to move a file, use the rename function.
*
* @param string $source Path to the source file.
* @param string $dest The destination path. If dest is a URL, the
* @param string $from Path to the source file.
* @param string $to The destination path. If to is a URL, the
* copy operation may fail if the wrapper does not support overwriting of
* existing files.
*
@@ -105,13 +105,13 @@ function chown(string $filename, $user): void
* @throws FilesystemException
*
*/
function copy(string $source, string $dest, $context = null): void
function copy(string $from, string $to, $context = null): void
{
error_clear_last();
if ($context !== null) {
$result = \copy($source, $dest, $context);
$result = \copy($from, $to, $context);
} else {
$result = \copy($source, $dest);
$result = \copy($from, $to);
}
if ($result === false) {
throw FilesystemException::createFromPhpError();
@@ -165,17 +165,40 @@ function disk_total_space(string $directory): float
/**
* The file pointed to by handle is closed.
* The file pointed to by stream is closed.
*
* @param resource $handle The file pointer must be valid, and must point to a file successfully
* @param resource $stream The file pointer must be valid, and must point to a file successfully
* opened by fopen or fsockopen.
* @throws FilesystemException
*
*/
function fclose($handle): void
function fclose($stream): void
{
error_clear_last();
$result = \fclose($handle);
$result = \fclose($stream);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* This function synchronizes stream contents to storage media, just like fsync does,
* but it does not synchronize file meta-data.
* Note that this function is only effectively different in POSIX systems.
* In Windows, this function is aliased to fsync.
*
* @param resource $stream The file pointer must be valid, and must point to
* a file successfully opened by fopen or
* fsockopen (and not yet closed by
* fclose).
* @throws FilesystemException
*
*/
function fdatasync($stream): void
{
error_clear_last();
$result = \fdatasync($stream);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
@@ -184,30 +207,76 @@ function fclose($handle): void
/**
* This function forces a write of all buffered output to the resource
* pointed to by the file handle.
* pointed to by the file stream.
*
* @param resource $handle The file pointer must be valid, and must point to
* @param resource $stream The file pointer must be valid, and must point to
* a file successfully opened by fopen or
* fsockopen (and not yet closed by
* fclose).
* @throws FilesystemException
*
*/
function fflush($handle): void
function fflush($stream): void
{
error_clear_last();
$result = \fflush($handle);
$result = \fflush($stream);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* Similar to fgets except that
* fgetcsv parses the line it reads for fields in
* CSV format and returns an array containing the fields
* read.
*
* @param resource $stream A valid file pointer to a file successfully opened by
* fopen, popen, or
* fsockopen.
* @param int $length Must be greater than the longest line (in characters) to be found in
* the CSV file (allowing for trailing line-end characters). Otherwise the
* line is split in chunks of length characters,
* unless the split would occur inside an enclosure.
*
* Omitting this parameter (or setting it to 0,
* or NULL in PHP 8.0.0 or later) the maximum line length is not limited,
* which is slightly slower.
* @param string $separator The optional separator parameter sets the field separator (one single-byte character only).
* @param string $enclosure The optional enclosure parameter sets the field enclosure character (one single-byte character only).
* @param string $escape The optional escape parameter sets the escape character (at most one single-byte character).
* An empty string ("") disables the proprietary escape mechanism.
* @return array|null Returns an indexed array containing the fields read on success.
* @throws FilesystemException
*
*/
function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\"): ?array
{
error_clear_last();
if ($escape !== "\\") {
$result = \fgetcsv($stream, $length, $separator, $enclosure, $escape);
} elseif ($enclosure !== "\"") {
$result = \fgetcsv($stream, $length, $separator, $enclosure);
} elseif ($separator !== ",") {
$result = \fgetcsv($stream, $length, $separator);
} elseif ($length !== null) {
$result = \fgetcsv($stream, $length);
} else {
$result = \fgetcsv($stream);
}
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
return $result;
}
/**
* This function is similar to file, except that
* file_get_contents returns the file in a
* string, starting at the specified offset
* up to maxlen bytes. On failure,
* up to length bytes. On failure,
* file_get_contents will return FALSE.
*
* file_get_contents is the preferred way to read the
@@ -230,18 +299,18 @@ function fflush($handle): void
* Seeking (offset) is not supported with remote files.
* Attempting to seek on non-local files may work with small offsets, but this
* is unpredictable because it works on the buffered stream.
* @param int $maxlen Maximum length of data read. The default is to read until end
* @param int $length Maximum length of data read. The default is to read until end
* of file is reached. Note that this parameter is applied to the
* stream processed by the filters.
* @return string The function returns the read data.
* @throws FilesystemException
*
*/
function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, int $maxlen = null): string
function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, int $length = null): string
{
error_clear_last();
if ($maxlen !== null) {
$result = \file_get_contents($filename, $use_include_path, $context, $offset, $maxlen);
if ($length !== null) {
$result = \file_get_contents($filename, $use_include_path, $context, $offset, $length);
} elseif ($offset !== 0) {
$result = \file_get_contents($filename, $use_include_path, $context, $offset);
} elseif ($context !== null) {
@@ -324,7 +393,7 @@ function file_get_contents(string $filename, bool $use_include_path = false, $co
*
*
*
* @param resource $context A valid context resource created with
* @param resource|null $context A valid context resource created with
* stream_context_create.
* @return int This function returns the number of bytes that were written to the file.
* @throws FilesystemException
@@ -507,6 +576,39 @@ function fileowner(string $filename): int
}
/**
* Gets permissions for the given file.
*
* @param string $filename Path to the file.
* @return int Returns the file's permissions as a numeric mode. Lower bits of this mode
* are the same as the permissions expected by chmod,
* however on most platforms the return value will also include information on
* the type of file given as filename. The examples
* below demonstrate how to test the return value for specific permissions and
* file types on POSIX systems, including Linux and macOS.
*
* For local files, the specific return value is that of the
* st_mode member of the structure returned by the C
* library's stat function. Exactly which bits are set
* can vary from platform to platform, and looking up your specific platform's
* documentation is recommended if parsing the non-permission bits of the
* return value is required.
*
* Returns FALSE on failure.
* @throws FilesystemException
*
*/
function fileperms(string $filename): int
{
error_clear_last();
$result = \fileperms($filename);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
return $result;
}
/**
* Gets the size for the given file.
*
@@ -532,16 +634,15 @@ function filesize(string $filename): int
* model which can be used on virtually every platform (including most Unix
* derivatives and even Windows).
*
* On versions of PHP before 5.3.2, the lock is released also by
* fclose (which is also called automatically when script
* finished).
* The lock is released also by fclose,
* or when stream is garbage collected.
*
* PHP supports a portable way of locking complete files in an advisory way
* (which means all accessing programs have to use the same way of locking
* or it will not work). By default, this function will block until the
* requested lock is acquired; this may be controlled with the LOCK_NB option documented below.
*
* @param resource $handle A file system pointer resource
* @param resource $stream A file system pointer resource
* that is typically created using fopen.
* @param int $operation operation is one of the following:
*
@@ -565,15 +666,15 @@ function filesize(string $filename): int
* It is also possible to add LOCK_NB as a bitmask to one
* of the above operations, if flock should not
* block during the locking attempt.
* @param int|null $wouldblock The optional third argument is set to 1 if the lock would block
* @param int|null $would_block The optional third argument is set to 1 if the lock would block
* (EWOULDBLOCK errno condition).
* @throws FilesystemException
*
*/
function flock($handle, int $operation, ?int &$wouldblock = null): void
function flock($stream, int $operation, ?int &$would_block = null): void
{
error_clear_last();
$result = \flock($handle, $operation, $wouldblock);
$result = \flock($stream, $operation, $would_block);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
@@ -661,9 +762,8 @@ function flock($handle, int $operation, ?int &$wouldblock = null): void
*
* 'w+'
*
* Open for reading and writing; place the file pointer at
* the beginning of the file and truncate the file to zero
* length. If the file does not exist, attempt to create it.
* Open for reading and writing; otherwise it has the
* same behavior as 'w'.
*
*
*
@@ -774,7 +874,8 @@ function flock($handle, int $operation, ?int &$wouldblock = null): void
* @param bool $use_include_path The optional third use_include_path parameter
* can be set to '1' or TRUE if you want to search for the file in the
* include_path, too.
* @param resource $context
* @param resource|null $context A context stream
* resource.
* @return resource Returns a file pointer resource on success
* @throws FilesystemException
*
@@ -794,42 +895,10 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $
}
/**
* fputcsv formats a line (passed as a
* fields array) as CSV and writes it (terminated by a
* newline) to the specified file handle.
*
* @param resource $handle The file pointer must be valid, and must point to
* a file successfully opened by fopen or
* fsockopen (and not yet closed by
* fclose).
* @param array $fields An array of strings.
* @param string $delimiter The optional delimiter parameter sets the field
* delimiter (one character only).
* @param string $enclosure The optional enclosure parameter sets the field
* enclosure (one character only).
* @param string $escape_char The optional escape_char parameter sets the
* escape character (at most one character).
* An empty string ("") disables the proprietary escape mechanism.
* @return int Returns the length of the written string.
* @throws FilesystemException
*
*/
function fputcsv($handle, array $fields, string $delimiter = ",", string $enclosure = '"', string $escape_char = "\\"): int
{
error_clear_last();
$result = \fputcsv($handle, $fields, $delimiter, $enclosure, $escape_char);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
return $result;
}
/**
* fread reads up to
* length bytes from the file pointer
* referenced by handle. Reading stops as soon as one
* referenced by stream. Reading stops as soon as one
* of the following conditions is met:
*
*
@@ -858,17 +927,17 @@ function fputcsv($handle, array $fields, string $delimiter = ",", string $enclos
*
*
*
* @param resource $handle A file system pointer resource
* @param resource $stream A file system pointer resource
* that is typically created using fopen.
* @param int $length Up to length number of bytes read.
* @return string Returns the read string.
* @throws FilesystemException
*
*/
function fread($handle, int $length): string
function fread($stream, int $length): string
{
error_clear_last();
$result = \fread($handle, $length);
$result = \fread($stream, $length);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
@@ -877,12 +946,58 @@ function fread($handle, int $length): string
/**
* Takes the filepointer, handle, and truncates the file to
* Gathers the statistics of the file opened by the file
* pointer stream. This function is similar to the
* stat function except that it operates
* on an open file pointer instead of a filename.
*
* @param resource $stream A file system pointer resource
* that is typically created using fopen.
* @return array Returns an array with the statistics of the file; the format of the array
* is described in detail on the stat manual page.
* Returns FALSE on failure.
* @throws FilesystemException
*
*/
function fstat($stream): array
{
error_clear_last();
$result = \fstat($stream);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
return $result;
}
/**
* This function synchronizes changes to the file, including its meta-data. This is similar to fflush,
* but it also instructs the operating system to write to the storage media.
*
* @param resource $stream The file pointer must be valid, and must point to
* a file successfully opened by fopen or
* fsockopen (and not yet closed by
* fclose).
* @throws FilesystemException
*
*/
function fsync($stream): void
{
error_clear_last();
$result = \fsync($stream);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* Takes the filepointer, stream, and truncates the file to
* length, size.
*
* @param resource $handle The file pointer.
* @param resource $stream The file pointer.
*
* The handle must be open for writing.
* The stream must be open for writing.
* @param int $size The size to truncate to.
*
* If size is larger than the file then the file
@@ -893,10 +1008,10 @@ function fread($handle, int $length): string
* @throws FilesystemException
*
*/
function ftruncate($handle, int $size): void
function ftruncate($stream, int $size): void
{
error_clear_last();
$result = \ftruncate($handle, $size);
$result = \ftruncate($stream, $size);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
@@ -906,29 +1021,23 @@ function ftruncate($handle, int $size): void
/**
*
*
* @param resource $handle A file system pointer resource
* @param resource $stream A file system pointer resource
* that is typically created using fopen.
* @param string $string The string that is to be written.
* @param int $length If the length argument is given, writing will
* stop after length bytes have been written or
* the end of string is reached, whichever comes
* first.
*
* Note that if the length argument is given,
* then the magic_quotes_runtime
* configuration option will be ignored and no slashes will be
* stripped from string.
* @param string $data The string that is to be written.
* @param int $length If length is an integer, writing will stop
* after length bytes have been written or the
* end of data is reached, whichever comes first.
* @return int
* @throws FilesystemException
*
*/
function fwrite($handle, string $string, int $length = null): int
function fwrite($stream, string $data, int $length = null): int
{
error_clear_last();
if ($length !== null) {
$result = \fwrite($handle, $string, $length);
$result = \fwrite($stream, $data, $length);
} else {
$result = \fwrite($handle, $string);
$result = \fwrite($stream, $data);
}
if ($result === false) {
throw FilesystemException::createFromPhpError();
@@ -1016,6 +1125,12 @@ function fwrite($handle, string $string, int $length = null): int
*
*
*
*
*
* The GLOB_BRACE flag is not available on some non GNU
* systems, like Solaris or Alpine Linux.
*
*
* @return array Returns an array containing the matched files/directories, an empty array
* if no file matched.
* @throws FilesystemException
@@ -1095,32 +1210,60 @@ function link(string $target, string $link): void
/**
* Attempts to create the directory specified by pathname.
* Gathers the statistics of the file or symbolic link named by
* filename.
*
* @param string $pathname The directory path.
* @param int $mode The mode is 0777 by default, which means the widest possible
* access. For more information on modes, read the details
* on the chmod page.
* @param string $filename Path to a file or a symbolic link.
* @return array See the manual page for stat for information on
* the structure of the array that lstat returns.
* This function is identical to the stat function
* except that if the filename parameter is a symbolic
* link, the status of the symbolic link is returned, not the status of the
* file pointed to by the symbolic link.
*
* mode is ignored on Windows.
*
* Note that you probably want to specify the mode as an octal number,
* which means it should have a leading zero. The mode is also modified
* by the current umask, which you can change using
* umask.
* @param bool $recursive Allows the creation of nested directories specified in the
* pathname.
* @param resource $context
* On failure, FALSE is returned.
* @throws FilesystemException
*
*/
function mkdir(string $pathname, int $mode = 0777, bool $recursive = false, $context = null): void
function lstat(string $filename): array
{
error_clear_last();
$result = \lstat($filename);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
return $result;
}
/**
* Attempts to create the directory specified by directory.
*
* @param string $directory The directory path.
* @param int $permissions The permissions are 0777 by default, which means the widest possible
* access. For more information on permissions, read the details
* on the chmod page.
*
* permissions is ignored on Windows.
*
* Note that you probably want to specify the permissions as an octal number,
* which means it should have a leading zero. The permissions is also modified
* by the current umask, which you can change using
* umask.
* @param bool $recursive Allows the creation of nested directories specified in the
* directory.
* @param resource $context A context stream
* resource.
* @throws FilesystemException
*
*/
function mkdir(string $directory, int $permissions = 0777, bool $recursive = false, $context = null): void
{
error_clear_last();
if ($context !== null) {
$result = \mkdir($pathname, $mode, $recursive, $context);
$result = \mkdir($directory, $permissions, $recursive, $context);
} else {
$result = \mkdir($pathname, $mode, $recursive);
$result = \mkdir($directory, $permissions, $recursive);
}
if ($result === false) {
throw FilesystemException::createFromPhpError();
@@ -1170,11 +1313,11 @@ function parse_ini_file(string $filename, bool $process_sections = false, int $s
/**
* parse_ini_string returns the settings in string
* ini in an associative array.
* ini_string in an associative array.
*
* The structure of the ini string is the same as the php.ini's.
*
* @param string $ini The contents of the ini file being parsed.
* @param string $ini_string The contents of the ini file being parsed.
* @param bool $process_sections By setting the process_sections
* parameter to TRUE, you get a multidimensional array, with
* the section names and settings included. The default
@@ -1194,10 +1337,10 @@ function parse_ini_file(string $filename, bool $process_sections = false, int $s
* @throws FilesystemException
*
*/
function parse_ini_string(string $ini, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array
function parse_ini_string(string $ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array
{
error_clear_last();
$result = \parse_ini_string($ini, $process_sections, $scanner_mode);
$result = \parse_ini_string($ini_string, $process_sections, $scanner_mode);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
@@ -1211,7 +1354,8 @@ function parse_ini_string(string $ini, bool $process_sections = false, int $scan
* @param string $filename The filename being read.
* @param bool $use_include_path You can use the optional second parameter and set it to TRUE, if
* you want to search for the file in the include_path, too.
* @param resource $context A context stream resource.
* @param resource $context A context stream
* resource.
* @return int Returns the number of bytes read from the file on success
* @throws FilesystemException
*
@@ -1287,30 +1431,37 @@ function realpath(string $path): string
/**
* Attempts to rename oldname to
* newname, moving it between directories if necessary.
* If renaming a file and newname exists,
* Attempts to rename from to
* to, moving it between directories if necessary.
* If renaming a file and to exists,
* it will be overwritten. If renaming a directory and
* newname exists,
* to exists,
* this function will emit a warning.
*
* @param string $oldname The old name.
* @param string $from The old name.
*
* The wrapper used in oldname
* The wrapper used in from
* must match the wrapper used in
* newname.
* @param string $newname The new name.
* @param resource $context
* to.
* @param string $to The new name.
*
*
* On Windows, if to already exists, it must be writable.
* Otherwise rename fails and issues E_WARNING.
*
*
* @param resource $context A context stream
* resource.
* @throws FilesystemException
*
*/
function rename(string $oldname, string $newname, $context = null): void
function rename(string $from, string $to, $context = null): void
{
error_clear_last();
if ($context !== null) {
$result = \rename($oldname, $newname, $context);
$result = \rename($from, $to, $context);
} else {
$result = \rename($oldname, $newname);
$result = \rename($from, $to);
}
if ($result === false) {
throw FilesystemException::createFromPhpError();
@@ -1319,18 +1470,18 @@ function rename(string $oldname, string $newname, $context = null): void
/**
* Sets the file position indicator for handle
* Sets the file position indicator for stream
* to the beginning of the file stream.
*
* @param resource $handle The file pointer must be valid, and must point to a file
* @param resource $stream The file pointer must be valid, and must point to a file
* successfully opened by fopen.
* @throws FilesystemException
*
*/
function rewind($handle): void
function rewind($stream): void
{
error_clear_last();
$result = \rewind($handle);
$result = \rewind($stream);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
@@ -1338,22 +1489,23 @@ function rewind($handle): void
/**
* Attempts to remove the directory named by dirname.
* Attempts to remove the directory named by directory.
* The directory must be empty, and the relevant permissions must permit this.
* A E_WARNING level error will be generated on failure.
*
* @param string $dirname Path to the directory.
* @param resource $context
* @param string $directory Path to the directory.
* @param resource $context A context stream
* resource.
* @throws FilesystemException
*
*/
function rmdir(string $dirname, $context = null): void
function rmdir(string $directory, $context = null): void
{
error_clear_last();
if ($context !== null) {
$result = \rmdir($dirname, $context);
$result = \rmdir($directory, $context);
} else {
$result = \rmdir($dirname);
$result = \rmdir($directory);
}
if ($result === false) {
throw FilesystemException::createFromPhpError();
@@ -1387,16 +1539,16 @@ function symlink(string $target, string $link): void
* generate a file in the system's temporary directory, and return
* the full path to that file, including its name.
*
* @param string $dir The directory where the temporary filename will be created.
* @param string $directory The directory where the temporary filename will be created.
* @param string $prefix The prefix of the generated temporary filename.
* @return string Returns the new temporary filename (with path).
* @throws FilesystemException
*
*/
function tempnam(string $dir, string $prefix): string
function tempnam(string $directory, string $prefix): string
{
error_clear_last();
$result = \tempnam($dir, $prefix);
$result = \tempnam($directory, $prefix);
if ($result === false) {
throw FilesystemException::createFromPhpError();
}
@@ -1432,29 +1584,29 @@ function tmpfile()
/**
* Attempts to set the access and modification times of the file named in the
* filename parameter to the value given in
* time.
* mtime.
* Note that the access time is always modified, regardless of the number
* of parameters.
*
* If the file does not exist, it will be created.
*
* @param string $filename The name of the file being touched.
* @param int $time The touch time. If time is not supplied,
* @param int $mtime The touch time. If mtime is NULL,
* the current system time is used.
* @param int $atime If present, the access time of the given filename is set to
* @param int $atime If not NULL, the access time of the given filename is set to
* the value of atime. Otherwise, it is set to
* the value passed to the time parameter.
* If neither are present, the current system time is used.
* the value passed to the mtime parameter.
* If both are NULL, the current system time is used.
* @throws FilesystemException
*
*/
function touch(string $filename, int $time = null, int $atime = null): void
function touch(string $filename, int $mtime = null, int $atime = null): void
{
error_clear_last();
if ($atime !== null) {
$result = \touch($filename, $time, $atime);
} elseif ($time !== null) {
$result = \touch($filename, $time);
$result = \touch($filename, $mtime, $atime);
} elseif ($mtime !== null) {
$result = \touch($filename, $mtime);
} else {
$result = \touch($filename);
}
@@ -1470,7 +1622,11 @@ function touch(string $filename, int $time = null, int $atime = null): void
* failure.
*
* @param string $filename Path to the file.
* @param resource $context
*
* If the file is a symlink, the symlink will be deleted. On Windows, to delete
* a symlink to a directory, rmdir has to be used instead.
* @param resource $context A context stream
* resource.
* @throws FilesystemException
*
*/