Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate separete wrappers for multiple PHP versions #503

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"generated/ftp.php",
"generated/funchand.php",
"generated/gettext.php",
"generated/gmp.php",
"generated/gnupg.php",
"generated/hash.php",
"generated/ibase.php",
Expand All @@ -60,6 +61,7 @@
"generated/mbstring.php",
"generated/misc.php",
"generated/mysql.php",
"generated/mysqli.php",
"generated/network.php",
"generated/oci8.php",
"generated/opcache.php",
Expand All @@ -72,7 +74,6 @@
"generated/ps.php",
"generated/pspell.php",
"generated/readline.php",
"generated/rnp.php",
"generated/rpminfo.php",
"generated/rrd.php",
"generated/sem.php",
Expand All @@ -98,7 +99,8 @@
"generated/yaml.php",
"generated/yaz.php",
"generated/zip.php",
"generated/zlib.php"
"generated/zlib.php",
"generated/rnp.php"
]
},
"require": {
Expand Down
199 changes: 199 additions & 0 deletions generated/8.1/apache.php
Original file line number Diff line number Diff line change
@@ -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();
}
}
112 changes: 112 additions & 0 deletions generated/8.1/apcu.php
Original file line number Diff line number Diff line change
@@ -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;
}
Loading
Loading