1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 10:49:36 +02:00

Update comments

This commit is contained in:
Daniel Neto 2024-08-21 09:11:05 -03:00
parent 91ac7ba018
commit d7965a01b8
302 changed files with 56587 additions and 763 deletions

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ApacheException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ApcuException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ArrayException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class Bzip2Exception extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class CalendarException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ClassobjException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ComException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class CubridException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class DatetimeException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class DirException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class EioException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ErrorfuncException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ExecException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class FileinfoException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class FilesystemException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class FilterException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class FpmException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class FtpException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class FunchandException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class GettextException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class GmpException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class GnupgException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class HashException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class IbaseException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class IbmDb2Exception extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class IconvException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ImageException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ImapException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class InfoException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class InotifyException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class LdapException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class LibxmlException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class LzfException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class MailparseException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class MbstringException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class MiscException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class MysqlException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class NetworkException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class Oci8Exception extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class OpcacheException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class OutcontrolException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class PcntlException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class PgsqlException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class PosixException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class PsException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class PspellException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ReadlineException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class RpminfoException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class RrdException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SemException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SessionException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ShmopException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SocketsException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SodiumException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SolrException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SplException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SqlsrvException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SsdeepException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class Ssh2Exception extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class StreamException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class StringsException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class SwooleException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class UodbcException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class UopzException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class UrlException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class VarException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class XdiffException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class XmlException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class XmlrpcException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class YamlException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class YazException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ZipException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace Safe\Exceptions;
class ZlibException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View file

@ -0,0 +1,199 @@
<?php
namespace Safe;
use Safe\Exceptions\ApacheException;
/**
* Fetch the Apache version.
*
* @return string Returns the Apache version on success.
* @throws ApacheException
*
*/
function apache_get_version(): string
{
error_clear_last();
$safeResult = \apache_get_version();
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieve an Apache environment variable specified by
* variable.
*
* @param string $variable The Apache environment variable
* @param bool $walk_to_top Whether to get the top-level variable available to all Apache layers.
* @return string The value of the Apache environment variable on success
* @throws ApacheException
*
*/
function apache_getenv(string $variable, bool $walk_to_top = false): string
{
error_clear_last();
$safeResult = \apache_getenv($variable, $walk_to_top);
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* This performs a partial request for a URI. It goes just far
* enough to obtain all the important information about the given
* resource.
*
* @param string $filename The filename (URI) that's being requested.
* @return object An object of related URI information. The properties of
* this object are:
*
*
* status
* the_request
* status_line
* method
* content_type
* handler
* uri
* filename
* path_info
* args
* boundary
* no_cache
* no_local_copy
* allowed
* send_bodyct
* bytes_sent
* byterange
* clength
* unparsed_uri
* mtime
* request_time
*
*
* Returns FALSE on failure.
* @throws ApacheException
*
*/
function apache_lookup_uri(string $filename): object
{
error_clear_last();
$safeResult = \apache_lookup_uri($filename);
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* Fetches all HTTP request headers from the current request. Works in the
* Apache, FastCGI, CLI, and FPM webservers.
*
* @return array An associative array of all the HTTP headers in the current request.
* @throws ApacheException
*
*/
function apache_request_headers(): array
{
error_clear_last();
$safeResult = \apache_request_headers();
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* Fetch all HTTP response headers. Works in the
* Apache, FastCGI, CLI, and FPM webservers.
*
* @return array An array of all Apache response headers on success.
* @throws ApacheException
*
*/
function apache_response_headers(): array
{
error_clear_last();
$safeResult = \apache_response_headers();
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* apache_setenv sets the value of the Apache
* environment variable specified by
* variable.
*
* @param string $variable The environment variable that's being set.
* @param string $value The new variable value.
* @param bool $walk_to_top Whether to set the top-level variable available to all Apache layers.
* @throws ApacheException
*
*/
function apache_setenv(string $variable, string $value, bool $walk_to_top = false): void
{
error_clear_last();
$safeResult = \apache_setenv($variable, $value, $walk_to_top);
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
}
/**
* Fetches all HTTP headers from the current request.
*
* This function is an alias for apache_request_headers.
* Please read the apache_request_headers
* documentation for more information on how this function works.
*
* @return array An associative array of all the HTTP headers in the current request.
* @throws ApacheException
*
*/
function getallheaders(): array
{
error_clear_last();
$safeResult = \getallheaders();
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* virtual is an Apache-specific function which
* is similar to &lt;!--#include virtual...--&gt; in
* mod_include.
* It performs an Apache sub-request. It is useful for including
* CGI scripts or .shtml files, or anything else that you would
* parse through Apache. Note that for a CGI script, the script
* must generate valid CGI headers. At the minimum that means it
* must generate a Content-Type header.
*
* To run the sub-request, all buffers are terminated and flushed to the
* browser, pending headers are sent too.
*
* @param string $uri The file that the virtual command will be performed on.
* @throws ApacheException
*
*/
function virtual(string $uri): void
{
error_clear_last();
$safeResult = \virtual($uri);
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
}

View file

@ -0,0 +1,112 @@
<?php
namespace Safe;
use Safe\Exceptions\ApcuException;
/**
* Retrieves cached information and meta-data from APC's data store.
*
* @param bool $limited If limited is TRUE, the
* return value will exclude the individual list of cache entries. This
* is useful when trying to optimize calls for statistics gathering.
* @return array Array of cached data (and meta-data)
* @throws ApcuException
*
*/
function apcu_cache_info(bool $limited = false): array
{
error_clear_last();
$safeResult = \apcu_cache_info($limited);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
return $safeResult;
}
/**
* apcu_cas updates an already existing integer value if the
* old parameter matches the currently stored value
* with the value of the new parameter.
*
* @param string $key The key of the value being updated.
* @param int $old The old value (the value currently stored).
* @param int $new The new value to update to.
* @throws ApcuException
*
*/
function apcu_cas(string $key, int $old, int $new): void
{
error_clear_last();
$safeResult = \apcu_cas($key, $old, $new);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
}
/**
* Decreases a stored integer value.
*
* @param string $key The key of the value being decreased.
* @param int $step The step, or value to decrease.
* @param bool|null $success Optionally pass the success or fail boolean value to
* this referenced variable.
* @param int $ttl TTL to use if the operation inserts a new value (rather than decrementing an existing one).
* @return int Returns the current value of key's value on success
* @throws ApcuException
*
*/
function apcu_dec(string $key, int $step = 1, ?bool &$success = null, int $ttl = 0): int
{
error_clear_last();
$safeResult = \apcu_dec($key, $step, $success, $ttl);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
return $safeResult;
}
/**
* Increases a stored number.
*
* @param string $key The key of the value being increased.
* @param int $step The step, or value to increase.
* @param bool|null $success Optionally pass the success or fail boolean value to
* this referenced variable.
* @param int $ttl TTL to use if the operation inserts a new value (rather than incrementing an existing one).
* @return int Returns the current value of key's value on success
* @throws ApcuException
*
*/
function apcu_inc(string $key, int $step = 1, ?bool &$success = null, int $ttl = 0): int
{
error_clear_last();
$safeResult = \apcu_inc($key, $step, $success, $ttl);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves APCu Shared Memory Allocation information.
*
* @param bool $limited When set to FALSE (default) apcu_sma_info will
* return a detailed information about each segment.
* @return array Array of Shared Memory Allocation data; FALSE on failure.
* @throws ApcuException
*
*/
function apcu_sma_info(bool $limited = false): array
{
error_clear_last();
$safeResult = \apcu_sma_info($limited);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
return $safeResult;
}

View file

@ -0,0 +1,59 @@
<?php
namespace Safe;
use Safe\Exceptions\ArrayException;
/**
* Applies the user-defined callback function to each
* element of the array. This function will recurse
* into deeper arrays.
*
* @param array|object $array The input array.
* @param callable $callback Typically, callback takes on two parameters.
* The array parameter's value being the first, and
* the key/index second.
*
* If callback needs to be working with the
* actual values of the array, specify the first parameter of
* callback as a
* reference. Then,
* any changes made to those elements will be made in the
* original array itself.
* @param mixed $arg If the optional arg parameter is supplied,
* it will be passed as the third parameter to the
* callback.
* @throws ArrayException
*
*/
function array_walk_recursive(&$array, callable $callback, $arg = null): void
{
error_clear_last();
if ($arg !== null) {
$safeResult = \array_walk_recursive($array, $callback, $arg);
} else {
$safeResult = \array_walk_recursive($array, $callback);
}
if ($safeResult === false) {
throw ArrayException::createFromPhpError();
}
}
/**
* This function shuffles (randomizes the order of the elements in) an array.
* It uses a pseudo random number generator that is not suitable for
* cryptographic purposes.
*
* @param array $array The array.
* @throws ArrayException
*
*/
function shuffle(array &$array): void
{
error_clear_last();
$safeResult = \shuffle($array);
if ($safeResult === false) {
throw ArrayException::createFromPhpError();
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace Safe;
use Safe\Exceptions\Bzip2Exception;
/**
* Closes the given bzip2 file pointer.
*
* @param resource $bz The file pointer. It must be valid and must point to a file
* successfully opened by bzopen.
* @throws Bzip2Exception
*
*/
function bzclose($bz): void
{
error_clear_last();
$safeResult = \bzclose($bz);
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
}
/**
* This function is supposed to force a write of all buffered bzip2 data for the file pointer
* bz,
* but is implemented as null function in libbz2, and as such does nothing.
*
* @param resource $bz The file pointer. It must be valid and must point to a file
* successfully opened by bzopen.
* @throws Bzip2Exception
*
*/
function bzflush($bz): void
{
error_clear_last();
$safeResult = \bzflush($bz);
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
}
/**
* bzread reads from the given bzip2 file pointer.
*
* Reading stops when length (uncompressed) bytes have
* been read or EOF is reached, whichever comes first.
*
* @param resource $bz The file pointer. It must be valid and must point to a file
* successfully opened by bzopen.
* @param int $length If not specified, bzread will read 1024
* (uncompressed) bytes at a time. A maximum of 8192
* uncompressed bytes will be read at a time.
* @return string Returns the uncompressed data.
* @throws Bzip2Exception
*
*/
function bzread($bz, int $length = 1024): string
{
error_clear_last();
$safeResult = \bzread($bz, $length);
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* bzwrite writes a string into the given bzip2 file
* stream.
*
* @param resource $bz The file pointer. It must be valid and must point to a file
* successfully opened by bzopen.
* @param string $data The written data.
* @param int $length If supplied, writing will stop after length
* (uncompressed) bytes have been written or the end of
* data is reached, whichever comes first.
* @return int Returns the number of bytes written.
* @throws Bzip2Exception
*
*/
function bzwrite($bz, string $data, int $length = null): int
{
error_clear_last();
if ($length !== null) {
$safeResult = \bzwrite($bz, $data, $length);
} else {
$safeResult = \bzwrite($bz, $data);
}
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
return $safeResult;
}

View file

@ -0,0 +1,30 @@
<?php
namespace Safe;
use Safe\Exceptions\CalendarException;
/**
* Return the Julian Day for a Unix timestamp
* (seconds since 1.1.1970), or for the current day if no
* timestamp is given. Either way, the time is regarded
* as local time (not UTC).
*
* @param int $timestamp A unix timestamp to convert.
* @return int A julian day number as integer.
* @throws CalendarException
*
*/
function unixtojd(int $timestamp = null): int
{
error_clear_last();
if ($timestamp !== null) {
$safeResult = \unixtojd($timestamp);
} else {
$safeResult = \unixtojd();
}
if ($safeResult === false) {
throw CalendarException::createFromPhpError();
}
return $safeResult;
}

View file

@ -0,0 +1,25 @@
<?php
namespace Safe;
use Safe\Exceptions\ClassobjException;
/**
* Creates an alias named alias
* based on the user defined class class.
* The aliased class is exactly the same as the original class.
*
* @param string $class The original class.
* @param string $alias The alias name for the class.
* @param bool $autoload Whether to autoload if the original class is not found.
* @throws ClassobjException
*
*/
function class_alias(string $class, string $alias, bool $autoload = true): void
{
error_clear_last();
$safeResult = \class_alias($class, $alias, $autoload);
if ($safeResult === false) {
throw ClassobjException::createFromPhpError();
}
}

View file

@ -0,0 +1,196 @@
<?php
namespace Safe;
use Safe\Exceptions\ComException;
/**
* Generates a Globally Unique Identifier (GUID).
*
* A GUID is generated in the same way as DCE UUID's, except that the
* Microsoft convention is to enclose a GUID in curly braces.
*
* @return string Returns the GUID as a string.
* @throws ComException
*
*/
function com_create_guid(): string
{
error_clear_last();
$safeResult = \com_create_guid();
if ($safeResult === false) {
throw ComException::createFromPhpError();
}
return $safeResult;
}
/**
* Instructs COM to sink events generated by
* variant into the PHP object
* sink_object.
*
* Be careful how you use this feature; if you are doing something similar
* to the example below, then it doesn't really make sense to run it in a
* web server context.
*
* @param object $variant
* @param object $sink_object sink_object should be an instance of a class with
* methods named after those of the desired dispinterface; you may use
* com_print_typeinfo to help generate a template class
* for this purpose.
* @param mixed $sink_interface PHP will attempt to use the default dispinterface type specified by
* the typelibrary associated with variant, but
* you may override this choice by setting
* sink_interface to the name of the dispinterface
* that you want to use.
* @throws ComException
*
*/
function com_event_sink(object $variant, object $sink_object, $sink_interface = null): void
{
error_clear_last();
if ($sink_interface !== null) {
$safeResult = \com_event_sink($variant, $sink_object, $sink_interface);
} else {
$safeResult = \com_event_sink($variant, $sink_object);
}
if ($safeResult === false) {
throw ComException::createFromPhpError();
}
}
/**
* Loads a type-library and registers its constants in the engine, as though
* they were defined using define.
*
* Note that it is much more efficient to use the com.typelib-file php.ini setting to pre-load and
* register the constants, although not so flexible.
*
* If com.autoregister-typelib is turned on, then
* PHP will attempt to automatically register the constants associated with a
* COM object when you instantiate it. This depends on the interfaces
* provided by the COM object itself, and may not always be possible.
*
* @param string $typelib typelib can be one of the following:
*
*
*
* The filename of a .tlb file or the executable module
* that contains the type library.
*
*
*
*
* The type library GUID, followed by its version number, for example
* {00000200-0000-0010-8000-00AA006D2EA4},2,0.
*
*
*
*
* The type library name, e.g. Microsoft OLE DB ActiveX Data
* Objects 1.0 Library.
*
*
*
* PHP will attempt to resolve the type library in this order, as the
* process gets more and more expensive as you progress down the list;
* searching for the type library by name is handled by physically
* enumerating the registry until we find a match.
*
* The filename of a .tlb file or the executable module
* that contains the type library.
*
* The type library GUID, followed by its version number, for example
* {00000200-0000-0010-8000-00AA006D2EA4},2,0.
*
* The type library name, e.g. Microsoft OLE DB ActiveX Data
* Objects 1.0 Library.
* @param bool $case_insensitive The case_insensitive behaves inversely to
* the parameter $case_insensitive in the define
* function.
* @throws ComException
*
*/
function com_load_typelib(string $typelib, bool $case_insensitive = true): void
{
error_clear_last();
$safeResult = \com_load_typelib($typelib, $case_insensitive);
if ($safeResult === false) {
throw ComException::createFromPhpError();
}
}
/**
* The purpose of this function is to help generate a skeleton class for use
* as an event sink. You may also use it to generate a dump of any COM
* object, provided that it supports enough of the introspection interfaces,
* and that you know the name of the interface you want to display.
*
* @param object $variant variant should be either an instance of a COM
* object, or be the name of a typelibrary (which will be resolved according
* to the rules set out in com_load_typelib).
* @param string $dispatch_interface The name of an IDispatch descendant interface that you want to display.
* @param bool $display_sink If set to TRUE, the corresponding sink interface will be displayed
* instead.
* @throws ComException
*
*/
function com_print_typeinfo(object $variant, string $dispatch_interface = null, bool $display_sink = false): void
{
error_clear_last();
if ($display_sink !== false) {
$safeResult = \com_print_typeinfo($variant, $dispatch_interface, $display_sink);
} elseif ($dispatch_interface !== null) {
$safeResult = \com_print_typeinfo($variant, $dispatch_interface);
} else {
$safeResult = \com_print_typeinfo($variant);
}
if ($safeResult === false) {
throw ComException::createFromPhpError();
}
}
/**
* Converts variant from a VT_DATE
* (or similar) value into a Unix timestamp. This allows easier
* interopability between the Unix-ish parts of PHP and COM.
*
* @param object $variant The variant.
* @return int Returns a unix timestamp.
* @throws ComException
*
*/
function variant_date_to_timestamp(object $variant): int
{
error_clear_last();
$safeResult = \variant_date_to_timestamp($variant);
if ($safeResult === null) {
throw ComException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the value of value rounded to
* decimals decimal places.
*
* @param mixed $value The variant.
* @param int $decimals Number of decimal places.
* @return mixed Returns the rounded value.
* @throws ComException
*
*/
function variant_round($value, int $decimals)
{
error_clear_last();
$safeResult = \variant_round($value, $decimals);
if ($safeResult === null) {
throw ComException::createFromPhpError();
}
return $safeResult;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,134 @@
<?php
namespace Safe;
use Safe\Exceptions\DirException;
/**
* Changes PHP's current directory to
* directory.
*
* @param string $directory The new current directory
* @throws DirException
*
*/
function chdir(string $directory): void
{
error_clear_last();
$safeResult = \chdir($directory);
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
}
/**
* Changes the root directory of the current process to
* directory, and changes the current
* working directory to "/".
*
* This function is only available to GNU and BSD systems, and
* only when using the CLI, CGI or Embed SAPI. Also, this function
* requires root privileges.
*
* Calling this function does not change the values of the __DIR__
* and __FILE__ magic constants.
*
* @param string $directory The path to change the root directory to.
* @throws DirException
*
*/
function chroot(string $directory): void
{
error_clear_last();
$safeResult = \chroot($directory);
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
}
/**
* Gets the current working directory.
*
* @return string Returns the current working directory on success.
*
* On some Unix variants, getcwd will return
* FALSE if any one of the parent directories does not have the
* readable or search mode set, even if the current directory
* does. See chmod for more information on
* modes and permissions.
* @throws DirException
*
*/
function getcwd(): string
{
error_clear_last();
$safeResult = \getcwd();
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
return $safeResult;
}
/**
* Opens up a directory handle to be used in subsequent
* closedir, readdir, and
* rewinddir calls.
*
* @param string $directory The directory path that is to be opened
* @param resource $context For a description of the context parameter,
* refer to the streams section of
* the manual.
* @return resource Returns a directory handle resource on success
* @throws DirException
*
*/
function opendir(string $directory, $context = null)
{
error_clear_last();
if ($context !== null) {
$safeResult = \opendir($directory, $context);
} else {
$safeResult = \opendir($directory);
}
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns an array of files and directories from the
* directory.
*
* @param string $directory The directory that will be scanned.
* @param int $sorting_order By default, the sorted order is alphabetical in ascending order. If
* the optional sorting_order is set to
* SCANDIR_SORT_DESCENDING, then the sort order is
* alphabetical in descending order. If it is set to
* SCANDIR_SORT_NONE then the result is unsorted.
* @param resource $context For a description of the context parameter,
* refer to the streams section of
* the manual.
* @return array Returns an array of filenames on success. If directory is not a directory, then
* boolean FALSE is returned, and an error of level
* E_WARNING is generated.
* @throws DirException
*
*/
function scandir(string $directory, int $sorting_order = SCANDIR_SORT_ASCENDING, $context = null): array
{
error_clear_last();
if ($context !== null) {
$safeResult = \scandir($directory, $sorting_order, $context);
} else {
$safeResult = \scandir($directory, $sorting_order);
}
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
return $safeResult;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,82 @@
<?php
namespace Safe;
use Safe\Exceptions\ErrorfuncException;
/**
* Sends an error message to the web server's error log or to a file.
*
* @param string $message The error message that should be logged.
* @param int $message_type Says where the error should go. The possible message types are as
* follows:
*
*
* error_log log types
*
*
*
* 0
*
* message is sent to PHP's system logger, using
* the Operating System's system logging mechanism or a file, depending
* on what the error_log
* configuration directive is set to. This is the default option.
*
*
*
* 1
*
* message is sent by email to the address in
* the destination parameter. This is the only
* message type where the fourth parameter,
* additional_headers is used.
*
*
*
* 2
*
* No longer an option.
*
*
*
* 3
*
* message is appended to the file
* destination. A newline is not automatically
* added to the end of the message string.
*
*
*
* 4
*
* message is sent directly to the SAPI logging
* handler.
*
*
*
*
*
* @param string $destination The destination. Its meaning depends on the
* message_type parameter as described above.
* @param string $additional_headers The extra headers. It's used when the message_type
* parameter is set to 1.
* This message type uses the same internal function as
* mail does.
* @throws ErrorfuncException
*
*/
function error_log(string $message, int $message_type = 0, string $destination = null, string $additional_headers = null): void
{
error_clear_last();
if ($additional_headers !== null) {
$safeResult = \error_log($message, $message_type, $destination, $additional_headers);
} elseif ($destination !== null) {
$safeResult = \error_log($message, $message_type, $destination);
} else {
$safeResult = \error_log($message, $message_type);
}
if ($safeResult === false) {
throw ErrorfuncException::createFromPhpError();
}
}

View file

@ -0,0 +1,154 @@
<?php
namespace Safe;
use Safe\Exceptions\ExecException;
/**
* exec executes the given
* command.
*
* @param string $command The command that will be executed.
* @param array|null $output If the output argument is present, then the
* specified array will be filled with every line of output from the
* command. Trailing whitespace, such as \n, is not
* included in this array. Note that if the array already contains some
* elements, exec will append to the end of the array.
* If you do not want the function to append elements, call
* unset on the array before passing it to
* exec.
* @param int|null $result_code If the result_code argument is present
* along with the output argument, then the
* return status of the executed command will be written to this
* variable.
* @return string The last line from the result of the command. If you need to execute a
* command and have all the data from the command passed directly back without
* any interference, use the passthru function.
*
* Returns FALSE on failure.
*
* To get the output of the executed command, be sure to set and use the
* output parameter.
* @throws ExecException
*
*/
function exec(string $command, ?array &$output = null, ?int &$result_code = null): string
{
error_clear_last();
$safeResult = \exec($command, $output, $result_code);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
* The passthru function is similar to the
* exec function in that it executes a
* command. This function
* should be used in place of exec or
* system when the output from the Unix command
* is binary data which needs to be passed directly back to the
* browser. A common use for this is to execute something like the
* pbmplus utilities that can output an image stream directly. By
* setting the Content-type to image/gif and
* then calling a pbmplus program to output a gif, you can create
* PHP scripts that output images directly.
*
* @param string $command The command that will be executed.
* @param int|null $result_code If the result_code argument is present, the
* return status of the Unix command will be placed here.
* @throws ExecException
*
*/
function passthru(string $command, ?int &$result_code = null): void
{
error_clear_last();
$safeResult = \passthru($command, $result_code);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
}
/**
* proc_nice changes the priority of the current
* process by the amount specified in priority. A
* positive priority will lower the priority of the
* current process, whereas a negative priority
* will raise the priority.
*
* proc_nice is not related to
* proc_open and its associated functions in any way.
*
* @param int $priority The new priority value, the value of this may differ on platforms.
*
* On Unix, a low value, such as -20 means high priority
* whereas positive values have a lower priority.
*
* For Windows the priority parameter has the
* following meaning:
* @throws ExecException
*
*/
function proc_nice(int $priority): void
{
error_clear_last();
$safeResult = \proc_nice($priority);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
}
/**
* This function is identical to the backtick operator.
*
* @param string $command The command that will be executed.
* @return string A string containing the output from the executed command, FALSE if the pipe
* cannot be established or NULL if an error occurs or the command produces no output.
* @throws ExecException
*
*/
function shell_exec(string $command): string
{
error_clear_last();
$safeResult = \shell_exec($command);
if ($safeResult === null) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
* system is just like the C version of the
* function in that it executes the given
* command and outputs the result.
*
* The system call also tries to automatically
* flush the web server's output buffer after each line of output if
* PHP is running as a server module.
*
* If you need to execute a command and have all the data from the
* command passed directly back without any interference, use the
* passthru function.
*
* @param string $command The command that will be executed.
* @param int|null $result_code If the result_code argument is present, then the
* return status of the executed command will be written to this
* variable.
* @return string Returns the last line of the command output on success.
* @throws ExecException
*
*/
function system(string $command, ?int &$result_code = null): string
{
error_clear_last();
$safeResult = \system($command, $result_code);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}

View file

@ -0,0 +1,79 @@
<?php
namespace Safe;
use Safe\Exceptions\FileinfoException;
/**
* This function closes the instance opened by finfo_open.
*
* @param resource $finfo An finfo instance, returned by finfo_open.
* @throws FileinfoException
*
*/
function finfo_close($finfo): void
{
error_clear_last();
$safeResult = \finfo_close($finfo);
if ($safeResult === false) {
throw FileinfoException::createFromPhpError();
}
}
/**
* Procedural style
*
* Object-oriented style (constructor):
*
* This function opens a magic database and returns its instance.
*
* @param int $flags One or disjunction of more Fileinfo
* constants.
* @param string $magic_database Name of a magic database file, usually something like
* /path/to/magic.mime. If not specified, the
* MAGIC environment variable is used. If the
* environment variable isn't set, then PHP's bundled magic database will
* be used.
*
* Passing NULL or an empty string will be equivalent to the default
* value.
* @return resource (Procedural style only)
* Returns an finfo instance on success.
* @throws FileinfoException
*
*/
function finfo_open(int $flags = FILEINFO_NONE, string $magic_database = null)
{
error_clear_last();
if ($magic_database !== null) {
$safeResult = \finfo_open($flags, $magic_database);
} else {
$safeResult = \finfo_open($flags);
}
if ($safeResult === false) {
throw FileinfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the MIME content type for a file as determined by using
* information from the magic.mime file.
*
* @param string|resource $filename Path to the tested file.
* @return string Returns the content type in MIME format, like
* text/plain or application/octet-stream.
* @throws FileinfoException
*
*/
function mime_content_type($filename): string
{
error_clear_last();
$safeResult = \mime_content_type($filename);
if ($safeResult === false) {
throw FileinfoException::createFromPhpError();
}
return $safeResult;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,81 @@
<?php
namespace Safe;
use Safe\Exceptions\FilterException;
/**
* This function is useful for retrieving many values without
* repetitively calling filter_input.
*
* @param int $type One of INPUT_GET, INPUT_POST,
* INPUT_COOKIE, INPUT_SERVER, or
* INPUT_ENV.
* @param int|array $options An array defining the arguments. A valid key is a string
* containing a variable name and a valid value is either a filter type, or an array
* optionally specifying the filter, flags and options. If the value is an
* array, valid keys are filter which specifies the
* filter type,
* flags which specifies any flags that apply to the
* filter, and options which specifies any options that
* apply to the filter. See the example below for a better understanding.
*
* This parameter can be also an integer holding a filter constant. Then all values in the
* input array are filtered by this filter.
* @param bool $add_empty Add missing keys as NULL to the return value.
* @return array|null An array containing the values of the requested variables on success.
* If the input array designated by type is not populated,
* the function returns NULL if the FILTER_NULL_ON_FAILURE
* flag is not given, or FALSE otherwise. For other failures, FALSE is returned.
*
* An array value will be FALSE if the filter fails, or NULL if
* the variable is not set. Or if the flag FILTER_NULL_ON_FAILURE
* is used, it returns FALSE if the variable is not set and NULL if the filter
* fails. If the add_empty parameter is FALSE, no array
* element will be added for unset variables.
* @throws FilterException
*
*/
function filter_input_array(int $type, $options = FILTER_DEFAULT, bool $add_empty = true): ?array
{
error_clear_last();
$safeResult = \filter_input_array($type, $options, $add_empty);
if ($safeResult === false) {
throw FilterException::createFromPhpError();
}
return $safeResult;
}
/**
* This function is useful for retrieving many values without
* repetitively calling filter_var.
*
* @param array $array An array with string keys containing the data to filter.
* @param mixed $options An array defining the arguments. A valid key is a string
* containing a variable name and a valid value is either a
* filter type, or an
* array optionally specifying the filter, flags and options.
* If the value is an array, valid keys are filter
* which specifies the filter type,
* flags which specifies any flags that apply to the
* filter, and options which specifies any options that
* apply to the filter. See the example below for a better understanding.
*
* This parameter can be also an integer holding a filter constant. Then all values in the
* input array are filtered by this filter.
* @param bool $add_empty Add missing keys as NULL to the return value.
* @return array|null An array containing the values of the requested variables on success. An array value will be FALSE if the filter fails, or NULL if
* the variable is not set.
* @throws FilterException
*
*/
function filter_var_array(array $array, $options = FILTER_DEFAULT, bool $add_empty = true): ?array
{
error_clear_last();
$safeResult = \filter_var_array($array, $options, $add_empty);
if ($safeResult === false) {
throw FilterException::createFromPhpError();
}
return $safeResult;
}

View file

@ -0,0 +1,22 @@
<?php
namespace Safe;
use Safe\Exceptions\FpmException;
/**
* This function flushes all response data to the client and finishes the
* request. This allows for time consuming tasks to be performed without
* leaving the connection to the client open.
*
* @throws FpmException
*
*/
function fastcgi_finish_request(): void
{
error_clear_last();
$safeResult = \fastcgi_finish_request();
if ($safeResult === false) {
throw FpmException::createFromPhpError();
}
}

View file

@ -0,0 +1,547 @@
<?php
namespace Safe;
use Safe\Exceptions\FtpException;
/**
* Sends an ALLO command to the remote FTP server to
* allocate space for a file to be uploaded.
*
* @param resource $ftp An FTP\Connection instance.
* @param int $size The number of bytes to allocate.
* @param string|null $response A textual representation of the servers response will be returned by
* reference in response if a variable is provided.
* @throws FtpException
*
*/
function ftp_alloc($ftp, int $size, ?string &$response = null): void
{
error_clear_last();
$safeResult = \ftp_alloc($ftp, $size, $response);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
*
*
* @param resource $ftp An FTP\Connection instance.
* @param string $remote_filename
* @param string $local_filename
* @param int $mode
* @throws FtpException
*
*/
function ftp_append($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY): void
{
error_clear_last();
$safeResult = \ftp_append($ftp, $remote_filename, $local_filename, $mode);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Changes to the parent directory.
*
* @param resource $ftp An FTP\Connection instance.
* @throws FtpException
*
*/
function ftp_cdup($ftp): void
{
error_clear_last();
$safeResult = \ftp_cdup($ftp);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Changes the current directory to the specified one.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $directory The target directory.
* @throws FtpException
*
*/
function ftp_chdir($ftp, string $directory): void
{
error_clear_last();
$safeResult = \ftp_chdir($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Sets the permissions on the specified remote file to
* permissions.
*
* @param resource $ftp An FTP\Connection instance.
* @param int $permissions The new permissions, given as an octal value.
* @param string $filename The remote file.
* @return int Returns the new file permissions on success.
* @throws FtpException
*
*/
function ftp_chmod($ftp, int $permissions, string $filename): int
{
error_clear_last();
$safeResult = \ftp_chmod($ftp, $permissions, $filename);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_close closes the given link identifier
* and releases the resource.
*
* @param resource $ftp An FTP\Connection instance.
* @throws FtpException
*
*/
function ftp_close($ftp): void
{
error_clear_last();
$safeResult = \ftp_close($ftp);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_connect opens an FTP connection to the
* specified hostname.
*
* @param string $hostname The FTP server address. This parameter shouldn't have any trailing
* slashes and shouldn't be prefixed with ftp://.
* @param int $port This parameter specifies an alternate port to connect to. If it is
* omitted or set to zero, then the default FTP port, 21, will be used.
* @param int $timeout This parameter specifies the timeout in seconds for all subsequent network operations.
* If omitted, the default value is 90 seconds. The timeout can be changed and
* queried at any time with ftp_set_option and
* ftp_get_option.
* @return resource Returns an FTP\Connection instance on success.
* @throws FtpException
*
*/
function ftp_connect(string $hostname, int $port = 21, int $timeout = 90)
{
error_clear_last();
$safeResult = \ftp_connect($hostname, $port, $timeout);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_delete deletes the file specified by
* filename from the FTP server.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $filename The file to delete.
* @throws FtpException
*
*/
function ftp_delete($ftp, string $filename): void
{
error_clear_last();
$safeResult = \ftp_delete($ftp, $filename);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_fget retrieves remote_filename
* from the FTP server, and writes it to the given file pointer.
*
* @param resource $ftp An FTP\Connection instance.
* @param resource $stream An open file pointer in which we store the data.
* @param string $remote_filename The remote file path.
* @param int $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start downloading from.
* @throws FtpException
*
*/
function ftp_fget($ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void
{
error_clear_last();
$safeResult = \ftp_fget($ftp, $stream, $remote_filename, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_fput uploads the data from a file pointer
* to a remote file on the FTP server.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $remote_filename The remote file path.
* @param resource $stream An open file pointer on the local file. Reading stops at end of file.
* @param int $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start uploading to.
* @throws FtpException
*
*/
function ftp_fput($ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): void
{
error_clear_last();
$safeResult = \ftp_fput($ftp, $remote_filename, $stream, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_get retrieves a remote file from the FTP server,
* and saves it into a local file.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $local_filename The local file path (will be overwritten if the file already exists).
* @param string $remote_filename The remote file path.
* @param int $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start downloading from.
* @throws FtpException
*
*/
function ftp_get($ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void
{
error_clear_last();
$safeResult = \ftp_get($ftp, $local_filename, $remote_filename, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Logs in to the given FTP connection.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $username The username (USER).
* @param string $password The password (PASS).
* @throws FtpException
*
*/
function ftp_login($ftp, string $username, string $password): void
{
error_clear_last();
$safeResult = \ftp_login($ftp, $username, $password);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Creates the specified directory on the FTP server.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $directory The name of the directory that will be created.
* @return string Returns the newly created directory name on success.
* @throws FtpException
*
*/
function ftp_mkdir($ftp, string $directory): string
{
error_clear_last();
$safeResult = \ftp_mkdir($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param resource $ftp An FTP\Connection instance.
* @param string $directory The directory to be listed.
* @return array Returns an array of arrays with file infos from the specified directory on success.
* @throws FtpException
*
*/
function ftp_mlsd($ftp, string $directory): array
{
error_clear_last();
$safeResult = \ftp_mlsd($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_nb_put stores a local file on the FTP server.
*
* The difference between this function and the ftp_put
* is that this function uploads the file asynchronously, so your program can
* perform other operations while the file is being uploaded.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $remote_filename The remote file path.
* @param string $local_filename The local file path.
* @param int $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start uploading to.
* @return int Returns FTP_FAILED or FTP_FINISHED
* or FTP_MOREDATA to open the local file.
* @throws FtpException
*
*/
function ftp_nb_put($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): int
{
error_clear_last();
$safeResult = \ftp_nb_put($ftp, $remote_filename, $local_filename, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param resource $ftp An FTP\Connection instance.
* @param string $directory The directory to be listed. This parameter can also include arguments, eg.
* ftp_nlist($ftp, "-la /your/dir");.
* Note that this parameter isn't escaped so there may be some issues with
* filenames containing spaces and other characters.
* @return array Returns an array of filenames from the specified directory on success.
* @throws FtpException
*
*/
function ftp_nlist($ftp, string $directory): array
{
error_clear_last();
$safeResult = \ftp_nlist($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_pasv turns on or off passive mode. In
* passive mode, data connections are initiated by the client,
* rather than by the server.
* It may be needed if the client is behind firewall.
*
* Please note that ftp_pasv can only be called after a
* successful login or otherwise it will fail.
*
* @param resource $ftp An FTP\Connection instance.
* @param bool $enable If TRUE, the passive mode is turned on, else it's turned off.
* @throws FtpException
*
*/
function ftp_pasv($ftp, bool $enable): void
{
error_clear_last();
$safeResult = \ftp_pasv($ftp, $enable);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_put stores a local file on the FTP server.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $remote_filename The remote file path.
* @param string $local_filename The local file path.
* @param int $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start uploading to.
* @throws FtpException
*
*/
function ftp_put($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): void
{
error_clear_last();
$safeResult = \ftp_put($ftp, $remote_filename, $local_filename, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
*
*
* @param resource $ftp An FTP\Connection instance.
* @return string Returns the current directory name.
* @throws FtpException
*
*/
function ftp_pwd($ftp): string
{
error_clear_last();
$safeResult = \ftp_pwd($ftp);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* Sends an arbitrary command to the FTP server.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $command The command to execute.
* @return array Returns the server's response as an array of strings.
* No parsing is performed on the response string, nor does
* ftp_raw determine if the command succeeded.
* @throws FtpException
*
*/
function ftp_raw($ftp, string $command): array
{
error_clear_last();
$safeResult = \ftp_raw($ftp, $command);
if ($safeResult === null) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_rename renames a file or a directory on the FTP
* server.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $from The old file/directory name.
* @param string $to The new name.
* @throws FtpException
*
*/
function ftp_rename($ftp, string $from, string $to): void
{
error_clear_last();
$safeResult = \ftp_rename($ftp, $from, $to);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Removes the specified directory on the FTP server.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $directory The directory to delete. This must be either an absolute or relative
* path to an empty directory.
* @throws FtpException
*
*/
function ftp_rmdir($ftp, string $directory): void
{
error_clear_last();
$safeResult = \ftp_rmdir($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_site sends the given SITE
* command to the FTP server.
*
* SITE commands are not standardized, and vary from server
* to server. They are useful for handling such things as file permissions and
* group membership.
*
* @param resource $ftp An FTP\Connection instance.
* @param string $command The SITE command. Note that this parameter isn't escaped so there may
* be some issues with filenames containing spaces and other characters.
* @throws FtpException
*
*/
function ftp_site($ftp, string $command): void
{
error_clear_last();
$safeResult = \ftp_site($ftp, $command);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_ssl_connect opens an explicit SSL-FTP connection to the
* specified hostname. That implies that
* ftp_ssl_connect will succeed even if the server is not
* configured for SSL-FTP, or its certificate is invalid. Only when
* ftp_login is called, the client will send the
* appropriate AUTH FTP command, so ftp_login will fail in
* the mentioned cases.
*
* @param string $hostname The FTP server address. This parameter shouldn't have any trailing
* slashes and shouldn't be prefixed with ftp://.
* @param int $port This parameter specifies an alternate port to connect to. If it is
* omitted or set to zero, then the default FTP port, 21, will be used.
* @param int $timeout This parameter specifies the timeout for all subsequent network operations.
* If omitted, the default value is 90 seconds. The timeout can be changed and
* queried at any time with ftp_set_option and
* ftp_get_option.
* @return resource Returns an FTP\Connection instance on success.
* @throws FtpException
*
*/
function ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90)
{
error_clear_last();
$safeResult = \ftp_ssl_connect($hostname, $port, $timeout);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the system type identifier of the remote FTP server.
*
* @param resource $ftp An FTP\Connection instance.
* @return string Returns the remote system type.
* @throws FtpException
*
*/
function ftp_systype($ftp): string
{
error_clear_last();
$safeResult = \ftp_systype($ftp);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}

View file

@ -0,0 +1,49 @@
<?php
namespace Safe;
use Safe\Exceptions\FunchandException;
/**
* Creates a function dynamically from the parameters passed, and returns a unique name for it.
*
* @param string $args The function arguments, as a single comma-separated string.
* @param string $code The function code.
* @return string Returns a unique function name as a string.
* Note that the name contains a non-printable character ("\0"),
* so care should be taken when printing the name or incorporating it in any other
* string.
* @throws FunchandException
*
*/
function create_function(string $args, string $code): string
{
error_clear_last();
$safeResult = \create_function($args, $code);
if ($safeResult === false) {
throw FunchandException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param callable(): void $callback The function to register.
* @param mixed $args
* @throws FunchandException
*
*/
function register_tick_function(callable $callback, ...$args): void
{
error_clear_last();
if ($args !== []) {
$safeResult = \register_tick_function($callback, ...$args);
} else {
$safeResult = \register_tick_function($callback);
}
if ($safeResult === false) {
throw FunchandException::createFromPhpError();
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,27 @@
<?php
namespace Safe;
use Safe\Exceptions\GettextException;
/**
* The bindtextdomain function sets or gets the path
* for a domain.
*
* @param string $domain The domain.
* @param string $directory The directory path.
* An empty string means the current directory.
* If NULL, the currently set directory is returned.
* @return string The full pathname for the domain currently being set.
* @throws GettextException
*
*/
function bindtextdomain(string $domain, string $directory): string
{
error_clear_last();
$safeResult = \bindtextdomain($domain, $directory);
if ($safeResult === false) {
throw GettextException::createFromPhpError();
}
return $safeResult;
}

View file

@ -0,0 +1,25 @@
<?php
namespace Safe;
use Safe\Exceptions\GmpException;
/**
*
*
* @param \GMP|string|int $seed The seed to be set for the gmp_random,
* gmp_random_bits, and
* gmp_random_range functions.
*
* A GMP object, an integer or a numeric string.
* @throws GmpException
*
*/
function gmp_random_seed($seed): void
{
error_clear_last();
$safeResult = \gmp_random_seed($seed);
if ($safeResult === false) {
throw GmpException::createFromPhpError();
}
}

View file

@ -0,0 +1,188 @@
<?php
namespace Safe;
use Safe\Exceptions\GnupgException;
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param string $fingerprint The fingerprint key.
* @param string $passphrase The pass phrase.
* @throws GnupgException
*
*/
function gnupg_adddecryptkey($identifier, string $fingerprint, string $passphrase): void
{
error_clear_last();
$safeResult = \gnupg_adddecryptkey($identifier, $fingerprint, $passphrase);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param string $fingerprint The fingerprint key.
* @throws GnupgException
*
*/
function gnupg_addencryptkey($identifier, string $fingerprint): void
{
error_clear_last();
$safeResult = \gnupg_addencryptkey($identifier, $fingerprint);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param string $fingerprint The fingerprint key.
* @param string $passphrase The pass phrase.
* @throws GnupgException
*
*/
function gnupg_addsignkey($identifier, string $fingerprint, string $passphrase = null): void
{
error_clear_last();
if ($passphrase !== null) {
$safeResult = \gnupg_addsignkey($identifier, $fingerprint, $passphrase);
} else {
$safeResult = \gnupg_addsignkey($identifier, $fingerprint);
}
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @throws GnupgException
*
*/
function gnupg_cleardecryptkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_cleardecryptkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @throws GnupgException
*
*/
function gnupg_clearencryptkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_clearencryptkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @throws GnupgException
*
*/
function gnupg_clearsignkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_clearsignkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param string $key The key to delete.
* @param bool $allow_secret It specifies whether to delete secret keys as well.
* @throws GnupgException
*
*/
function gnupg_deletekey($identifier, string $key, bool $allow_secret): void
{
error_clear_last();
$safeResult = \gnupg_deletekey($identifier, $key, $allow_secret);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* Toggle the armored output.
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param int $armor Pass a non-zero integer-value to this function to enable armored-output
* (default).
* Pass 0 to disable armored output.
* @throws GnupgException
*
*/
function gnupg_setarmor($identifier, int $armor): void
{
error_clear_last();
$safeResult = \gnupg_setarmor($identifier, $armor);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* Sets the mode for signing.
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param int $signmode The mode for signing.
*
* signmode takes a constant indicating what type of
* signature should be produced. The possible values are
* GNUPG_SIG_MODE_NORMAL,
* GNUPG_SIG_MODE_DETACH and
* GNUPG_SIG_MODE_CLEAR.
* By default GNUPG_SIG_MODE_CLEAR is used.
* @throws GnupgException
*
*/
function gnupg_setsignmode($identifier, int $signmode): void
{
error_clear_last();
$safeResult = \gnupg_setsignmode($identifier, $signmode);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}

View file

@ -0,0 +1,65 @@
<?php
namespace Safe;
use Safe\Exceptions\HashException;
/**
*
*
* @param string $algo Name of selected hashing algorithm (i.e. "sha256", "sha512", "haval160,4", etc..)
* See hash_algos for a list of supported algorithms.
*
*
* Non-cryptographic hash functions are not allowed.
*
*
*
* Non-cryptographic hash functions are not allowed.
* @param string $key Input keying material (raw binary). Cannot be empty.
* @param int $length Desired output length in bytes.
* Cannot be greater than 255 times the chosen hash function size.
*
* If length is 0, the output length
* will default to the chosen hash function size.
* @param string $info Application/context-specific info string.
* @param string $salt Salt to use during derivation.
*
* While optional, adding random salt significantly improves the strength of HKDF.
* @return string Returns a string containing a raw binary representation of the derived key
* (also known as output keying material - OKM);.
* @throws HashException
*
*/
function hash_hkdf(string $algo, string $key, int $length = 0, string $info = "", string $salt = ""): string
{
error_clear_last();
$safeResult = \hash_hkdf($algo, $key, $length, $info, $salt);
if ($safeResult === false) {
throw HashException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param \HashContext $context Hashing context returned by hash_init.
* @param string $filename URL describing location of file to be hashed; Supports fopen wrappers.
* @param \HashContext|null $stream_context Stream context as returned by stream_context_create.
* @throws HashException
*
*/
function hash_update_file(\HashContext $context, string $filename, ?\HashContext $stream_context = null): void
{
error_clear_last();
if ($stream_context !== null) {
$safeResult = \hash_update_file($context, $filename, $stream_context);
} else {
$safeResult = \hash_update_file($context, $filename);
}
if ($safeResult === false) {
throw HashException::createFromPhpError();
}
}

View file

@ -0,0 +1,661 @@
<?php
namespace Safe;
use Safe\Exceptions\IbaseException;
/**
* This function will discard a BLOB if it has not yet been closed by
* fbird_blob_close.
*
* @param resource $blob_handle A BLOB handle opened with fbird_blob_create.
* @throws IbaseException
*
*/
function fbird_blob_cancel($blob_handle): void
{
error_clear_last();
$safeResult = \fbird_blob_cancel($blob_handle);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
*
*
* @param resource $service_handle The handle on the database server service.
* @param string $user_name The login name of the new database user.
* @param string $password The password of the new user.
* @param string $first_name The first name of the new database user.
* @param string $middle_name The middle name of the new database user.
* @param string $last_name The last name of the new database user.
* @throws IbaseException
*
*/
function ibase_add_user($service_handle, string $user_name, string $password, string $first_name = null, string $middle_name = null, string $last_name = null): void
{
error_clear_last();
if ($last_name !== null) {
$safeResult = \ibase_add_user($service_handle, $user_name, $password, $first_name, $middle_name, $last_name);
} elseif ($middle_name !== null) {
$safeResult = \ibase_add_user($service_handle, $user_name, $password, $first_name, $middle_name);
} elseif ($first_name !== null) {
$safeResult = \ibase_add_user($service_handle, $user_name, $password, $first_name);
} else {
$safeResult = \ibase_add_user($service_handle, $user_name, $password);
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* This function passes the arguments to the (remote) database server. There it starts a new backup process. Therefore you
* won't get any responses.
*
* @param resource $service_handle A previously opened connection to the database server.
* @param string $source_db The absolute file path to the database on the database server. You can also use a database alias.
* @param string $dest_file The path to the backup file on the database server.
* @param int $options Additional options to pass to the database server for backup.
* The options parameter can be a combination
* of the following constants:
* IBASE_BKP_IGNORE_CHECKSUMS,
* IBASE_BKP_IGNORE_LIMBO,
* IBASE_BKP_METADATA_ONLY,
* IBASE_BKP_NO_GARBAGE_COLLECT,
* IBASE_BKP_OLD_DESCRIPTIONS,
* IBASE_BKP_NON_TRANSPORTABLE or
* IBASE_BKP_CONVERT.
* Read the section about for further information.
* @param bool $verbose Since the backup process is done on the database server, you don't have any chance
* to get its output. This argument is useless.
* @return mixed Returns TRUE on success.
*
* Since the backup process is done on the (remote) server, this function just passes the arguments to it.
* While the arguments are legal, you won't get FALSE.
* @throws IbaseException
*
*/
function ibase_backup($service_handle, string $source_db, string $dest_file, int $options = 0, bool $verbose = false)
{
error_clear_last();
$safeResult = \ibase_backup($service_handle, $source_db, $dest_file, $options, $verbose);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* This function will discard a BLOB if it has not yet been closed by
* ibase_blob_close.
*
* @param resource $blob_handle A BLOB handle opened with ibase_blob_create.
* @throws IbaseException
*
*/
function ibase_blob_cancel($blob_handle): void
{
error_clear_last();
$safeResult = \ibase_blob_cancel($blob_handle);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* ibase_blob_create creates a new BLOB for filling with
* data.
*
* @param resource $link_identifier An InterBase link identifier. If omitted, the last opened link is
* assumed.
* @return resource Returns a BLOB handle for later use with
* ibase_blob_add.
* @throws IbaseException
*
*/
function ibase_blob_create($link_identifier = null)
{
error_clear_last();
if ($link_identifier !== null) {
$safeResult = \ibase_blob_create($link_identifier);
} else {
$safeResult = \ibase_blob_create();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* This function returns at most len bytes from a BLOB
* that has been opened for reading by ibase_blob_open.
*
* @param resource $blob_handle A BLOB handle opened with ibase_blob_open.
* @param int $len Size of returned data.
* @return string Returns at most len bytes from the BLOB.
* @throws IbaseException
*
*/
function ibase_blob_get($blob_handle, int $len): string
{
error_clear_last();
$safeResult = \ibase_blob_get($blob_handle, $len);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* Closes the link to an InterBase database that's associated with
* a connection id returned from ibase_connect.
* Default transaction on link is committed, other transactions are
* rolled back.
*
* @param resource $connection_id An InterBase link identifier returned from
* ibase_connect. If omitted, the last opened link
* is assumed.
* @throws IbaseException
*
*/
function ibase_close($connection_id = null): void
{
error_clear_last();
if ($connection_id !== null) {
$safeResult = \ibase_close($connection_id);
} else {
$safeResult = \ibase_close();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Commits a transaction without closing it.
*
* @param resource $link_or_trans_identifier If called without an argument, this function commits the default
* transaction of the default link. If the argument is a connection
* identifier, the default transaction of the corresponding connection
* will be committed. If the argument is a transaction identifier, the
* corresponding transaction will be committed. The transaction context
* will be retained, so statements executed from within this transaction
* will not be invalidated.
* @throws IbaseException
*
*/
function ibase_commit_ret($link_or_trans_identifier = null): void
{
error_clear_last();
if ($link_or_trans_identifier !== null) {
$safeResult = \ibase_commit_ret($link_or_trans_identifier);
} else {
$safeResult = \ibase_commit_ret();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Commits a transaction.
*
* @param resource $link_or_trans_identifier If called without an argument, this function commits the default
* transaction of the default link. If the argument is a connection
* identifier, the default transaction of the corresponding connection
* will be committed. If the argument is a transaction identifier, the
* corresponding transaction will be committed.
* @throws IbaseException
*
*/
function ibase_commit($link_or_trans_identifier = null): void
{
error_clear_last();
if ($link_or_trans_identifier !== null) {
$safeResult = \ibase_commit($link_or_trans_identifier);
} else {
$safeResult = \ibase_commit();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Establishes a connection to an Firebird/InterBase server.
*
* In case a second call is made to ibase_connect with
* the same arguments, no new link will be established, but instead, the link
* identifier of the already opened link will be returned. The link to the
* server will be closed as soon as the execution of the script ends, unless
* it's closed earlier by explicitly calling ibase_close.
*
* @param string $database The database argument has to be a valid path to
* database file on the server it resides on. If the server is not local,
* it must be prefixed with either 'hostname:' (TCP/IP), 'hostname/port:'
* (TCP/IP with interbase server on custom TCP port), '//hostname/'
* (NetBEUI), depending on the connection
* protocol used.
* @param string $username The user name. Can be set with the
* ibase.default_user php.ini directive.
* @param string $password The password for username. Can be set with the
* ibase.default_password php.ini directive.
* @param string $charset charset is the default character set for a
* database.
* @param int $buffers buffers is the number of database buffers to
* allocate for the server-side cache. If 0 or omitted, server chooses
* its own default.
* @param int $dialect dialect selects the default SQL dialect for any
* statement executed within a connection, and it defaults to the highest
* one supported by client libraries.
* @param string $role Functional only with InterBase 5 and up.
* @param int $sync
* @return resource Returns an Firebird/InterBase link identifier on success.
* @throws IbaseException
*
*/
function ibase_connect(string $database = null, string $username = null, string $password = null, string $charset = null, int $buffers = null, int $dialect = null, string $role = null, int $sync = null)
{
error_clear_last();
if ($sync !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset, $buffers, $dialect, $role, $sync);
} elseif ($role !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset, $buffers, $dialect, $role);
} elseif ($dialect !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset, $buffers, $dialect);
} elseif ($buffers !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset, $buffers);
} elseif ($charset !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset);
} elseif ($password !== null) {
$safeResult = \ibase_connect($database, $username, $password);
} elseif ($username !== null) {
$safeResult = \ibase_connect($database, $username);
} elseif ($database !== null) {
$safeResult = \ibase_connect($database);
} else {
$safeResult = \ibase_connect();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param resource $service_handle The handle on the database server service.
* @param string $user_name The login name of the user you want to delete from the database.
* @throws IbaseException
*
*/
function ibase_delete_user($service_handle, string $user_name): void
{
error_clear_last();
$safeResult = \ibase_delete_user($service_handle, $user_name);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* This functions drops a database that was opened by either ibase_connect
* or ibase_pconnect. The database is closed and deleted from the server.
*
* @param resource $connection An InterBase link identifier. If omitted, the last opened link is
* assumed.
* @throws IbaseException
*
*/
function ibase_drop_db($connection = null): void
{
error_clear_last();
if ($connection !== null) {
$safeResult = \ibase_drop_db($connection);
} else {
$safeResult = \ibase_drop_db();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* This function causes the registered event handler specified by
* event to be cancelled. The callback function will
* no longer be called for the events it was registered to handle.
*
* @param resource $event An event resource, created by
* ibase_set_event_handler.
* @throws IbaseException
*
*/
function ibase_free_event_handler($event): void
{
error_clear_last();
$safeResult = \ibase_free_event_handler($event);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Frees a prepared query.
*
* @param resource $query A query prepared with ibase_prepare.
* @throws IbaseException
*
*/
function ibase_free_query($query): void
{
error_clear_last();
$safeResult = \ibase_free_query($query);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Frees a result set.
*
* @param resource $result_identifier A result set created by ibase_query or
* ibase_execute.
* @throws IbaseException
*
*/
function ibase_free_result($result_identifier): void
{
error_clear_last();
$safeResult = \ibase_free_result($result_identifier);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
*
*
* @param resource $service_handle
* @param string $db
* @param int $action
* @param int $argument
* @throws IbaseException
*
*/
function ibase_maintain_db($service_handle, string $db, int $action, int $argument = 0): void
{
error_clear_last();
$safeResult = \ibase_maintain_db($service_handle, $db, $action, $argument);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
*
*
* @param resource $service_handle The handle on the database server service.
* @param string $user_name The login name of the database user to modify.
* @param string $password The user's new password.
* @param string $first_name The user's new first name.
* @param string $middle_name The user's new middle name.
* @param string $last_name The user's new last name.
* @throws IbaseException
*
*/
function ibase_modify_user($service_handle, string $user_name, string $password, string $first_name = null, string $middle_name = null, string $last_name = null): void
{
error_clear_last();
if ($last_name !== null) {
$safeResult = \ibase_modify_user($service_handle, $user_name, $password, $first_name, $middle_name, $last_name);
} elseif ($middle_name !== null) {
$safeResult = \ibase_modify_user($service_handle, $user_name, $password, $first_name, $middle_name);
} elseif ($first_name !== null) {
$safeResult = \ibase_modify_user($service_handle, $user_name, $password, $first_name);
} else {
$safeResult = \ibase_modify_user($service_handle, $user_name, $password);
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* This function assigns a name to a result set. This name can be used later in
* UPDATE|DELETE ... WHERE CURRENT OF name statements.
*
* @param resource $result An InterBase result set.
* @param string $name The name to be assigned.
* @throws IbaseException
*
*/
function ibase_name_result($result, string $name): void
{
error_clear_last();
$safeResult = \ibase_name_result($result, $name);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Opens a persistent connection to an InterBase database.
*
* ibase_pconnect acts very much like
* ibase_connect with two major differences.
*
* First, when connecting, the function will first try to find a (persistent)
* link that's already opened with the same parameters. If one is found, an
* identifier for it will be returned instead of opening a new connection.
*
* Second, the connection to the InterBase server will not be closed when the
* execution of the script ends. Instead, the link will remain open for
* future use (ibase_close will not close links
* established by ibase_pconnect). This type of link is
* therefore called 'persistent'.
*
* @param string $database The database argument has to be a valid path to
* database file on the server it resides on. If the server is not local,
* it must be prefixed with either 'hostname:' (TCP/IP), '//hostname/'
* (NetBEUI) or 'hostname@' (IPX/SPX), depending on the connection
* protocol used.
* @param string $username The user name. Can be set with the
* ibase.default_user php.ini directive.
* @param string $password The password for username. Can be set with the
* ibase.default_password php.ini directive.
* @param string $charset charset is the default character set for a
* database.
* @param int $buffers buffers is the number of database buffers to
* allocate for the server-side cache. If 0 or omitted, server chooses
* its own default.
* @param int $dialect dialect selects the default SQL dialect for any
* statement executed within a connection, and it defaults to the highest
* one supported by client libraries. Functional only with InterBase 6
* and up.
* @param string $role Functional only with InterBase 5 and up.
* @param int $sync
* @return resource Returns an InterBase link identifier on success.
* @throws IbaseException
*
*/
function ibase_pconnect(string $database = null, string $username = null, string $password = null, string $charset = null, int $buffers = null, int $dialect = null, string $role = null, int $sync = null)
{
error_clear_last();
if ($sync !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset, $buffers, $dialect, $role, $sync);
} elseif ($role !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset, $buffers, $dialect, $role);
} elseif ($dialect !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset, $buffers, $dialect);
} elseif ($buffers !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset, $buffers);
} elseif ($charset !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset);
} elseif ($password !== null) {
$safeResult = \ibase_pconnect($database, $username, $password);
} elseif ($username !== null) {
$safeResult = \ibase_pconnect($database, $username);
} elseif ($database !== null) {
$safeResult = \ibase_pconnect($database);
} else {
$safeResult = \ibase_pconnect();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* This function passes the arguments to the (remote) database server. There it starts a new restore process. Therefore you
* won't get any responses.
*
* @param resource $service_handle A previously opened connection to the database server.
* @param string $source_file The absolute path on the server where the backup file is located.
* @param string $dest_db The path to create the new database on the server. You can also use database alias.
* @param int $options Additional options to pass to the database server for restore.
* The options parameter can be a combination
* of the following constants:
* IBASE_RES_DEACTIVATE_IDX,
* IBASE_RES_NO_SHADOW,
* IBASE_RES_NO_VALIDITY,
* IBASE_RES_ONE_AT_A_TIME,
* IBASE_RES_REPLACE,
* IBASE_RES_CREATE,
* IBASE_RES_USE_ALL_SPACE,
* IBASE_PRP_PAGE_BUFFERS,
* IBASE_PRP_SWEEP_INTERVAL,
* IBASE_RES_CREATE.
* Read the section about for further information.
* @param bool $verbose Since the restore process is done on the database server, you don't have any chance
* to get its output. This argument is useless.
* @return mixed Returns TRUE on success.
*
* Since the restore process is done on the (remote) server, this function just passes the arguments to it.
* While the arguments are legal, you won't get FALSE.
* @throws IbaseException
*
*/
function ibase_restore($service_handle, string $source_file, string $dest_db, int $options = 0, bool $verbose = false)
{
error_clear_last();
$safeResult = \ibase_restore($service_handle, $source_file, $dest_db, $options, $verbose);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* Rolls back a transaction without closing it.
*
* @param resource $link_or_trans_identifier If called without an argument, this function rolls back the default
* transaction of the default link. If the argument is a connection
* identifier, the default transaction of the corresponding connection
* will be rolled back. If the argument is a transaction identifier, the
* corresponding transaction will be rolled back. The transaction context
* will be retained, so statements executed from within this transaction
* will not be invalidated.
* @throws IbaseException
*
*/
function ibase_rollback_ret($link_or_trans_identifier = null): void
{
error_clear_last();
if ($link_or_trans_identifier !== null) {
$safeResult = \ibase_rollback_ret($link_or_trans_identifier);
} else {
$safeResult = \ibase_rollback_ret();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Rolls back a transaction.
*
* @param resource $link_or_trans_identifier If called without an argument, this function rolls back the default
* transaction of the default link. If the argument is a connection
* identifier, the default transaction of the corresponding connection
* will be rolled back. If the argument is a transaction identifier, the
* corresponding transaction will be rolled back.
* @throws IbaseException
*
*/
function ibase_rollback($link_or_trans_identifier = null): void
{
error_clear_last();
if ($link_or_trans_identifier !== null) {
$safeResult = \ibase_rollback($link_or_trans_identifier);
} else {
$safeResult = \ibase_rollback();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
*
*
* @param string $host The name or ip address of the database host. You can define the port by adding
* '/' and port number. If no port is specified, port 3050 will be used.
* @param string $dba_username The name of any valid user.
* @param string $dba_password The user's password.
* @return resource Returns a Interbase / Firebird link identifier on success.
* @throws IbaseException
*
*/
function ibase_service_attach(string $host, string $dba_username, string $dba_password)
{
error_clear_last();
$safeResult = \ibase_service_attach($host, $dba_username, $dba_password);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param resource $service_handle A previously created connection to the database server.
* @throws IbaseException
*
*/
function ibase_service_detach($service_handle): void
{
error_clear_last();
$safeResult = \ibase_service_detach($service_handle);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}

Some files were not shown because too many files have changed in this diff Show more