Skip to content

Commit c35e365

Browse files
committed
Generate files for multiple versions
tl;dr: replace ```php $function_list = read_docs(); generate_files($function_list, "../generated/"); ``` with ```php foreach(["8.1", "8.2", "8.3", "8.4"] as $version) { exec("cd docs && git checkout $version"); $function_list = read_docs(); generate_files($function_list, "../generated/$version/"); } ``` generate a bunch of stubs like generated/misc.php: ```php <?php if(PHP_VERSION == "8.1") require_once __DIR__ . "/8.1/misc.php"; if(PHP_VERSION == "8.2") require_once __DIR__ . "/8.2/misc.php"; if(PHP_VERSION == "8.3") require_once __DIR__ . "/8.3/misc.php"; if(PHP_VERSION == "8.4") require_once __DIR__ . "/8.4/misc.php"; ``` This also automates generation of "deprecated" `safe` functions (ie, instead of hard-coding `deprecated/apache.php`, any functions which needed safe wrappers in 8.1 but no longer need safe wrappers in 8.2 will have no-op stubs generated instead) Currently the `Exceptions` are shared between all versions, which I _think_ is a good idea? (Thoughts, anybody?) -
1 parent 86ab3b7 commit c35e365

File tree

483 files changed

+216098
-39765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

483 files changed

+216098
-39765
lines changed

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"generated/ftp.php",
3333
"generated/funchand.php",
3434
"generated/gettext.php",
35+
"generated/gmp.php",
3536
"generated/gnupg.php",
3637
"generated/hash.php",
3738
"generated/ibase.php",
@@ -49,6 +50,7 @@
4950
"generated/mbstring.php",
5051
"generated/misc.php",
5152
"generated/mysql.php",
53+
"generated/mysqli.php",
5254
"generated/network.php",
5355
"generated/oci8.php",
5456
"generated/opcache.php",

generated/8.1/apache.php

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
<?php
2+
3+
namespace Safe;
4+
5+
use Safe\Exceptions\ApacheException;
6+
7+
/**
8+
* Fetch the Apache version.
9+
*
10+
* @return string Returns the Apache version on success.
11+
* @throws ApacheException
12+
*
13+
*/
14+
function apache_get_version(): string
15+
{
16+
error_clear_last();
17+
$safeResult = \apache_get_version();
18+
if ($safeResult === false) {
19+
throw ApacheException::createFromPhpError();
20+
}
21+
return $safeResult;
22+
}
23+
24+
25+
/**
26+
* Retrieve an Apache environment variable specified by
27+
* variable.
28+
*
29+
* @param string $variable The Apache environment variable
30+
* @param bool $walk_to_top Whether to get the top-level variable available to all Apache layers.
31+
* @return string The value of the Apache environment variable on success
32+
* @throws ApacheException
33+
*
34+
*/
35+
function apache_getenv(string $variable, bool $walk_to_top = false): string
36+
{
37+
error_clear_last();
38+
$safeResult = \apache_getenv($variable, $walk_to_top);
39+
if ($safeResult === false) {
40+
throw ApacheException::createFromPhpError();
41+
}
42+
return $safeResult;
43+
}
44+
45+
46+
/**
47+
* This performs a partial request for a URI. It goes just far
48+
* enough to obtain all the important information about the given
49+
* resource.
50+
*
51+
* @param string $filename The filename (URI) that's being requested.
52+
* @return object An object of related URI information. The properties of
53+
* this object are:
54+
*
55+
*
56+
* status
57+
* the_request
58+
* status_line
59+
* method
60+
* content_type
61+
* handler
62+
* uri
63+
* filename
64+
* path_info
65+
* args
66+
* boundary
67+
* no_cache
68+
* no_local_copy
69+
* allowed
70+
* send_bodyct
71+
* bytes_sent
72+
* byterange
73+
* clength
74+
* unparsed_uri
75+
* mtime
76+
* request_time
77+
*
78+
*
79+
* Returns FALSE on failure.
80+
* @throws ApacheException
81+
*
82+
*/
83+
function apache_lookup_uri(string $filename): object
84+
{
85+
error_clear_last();
86+
$safeResult = \apache_lookup_uri($filename);
87+
if ($safeResult === false) {
88+
throw ApacheException::createFromPhpError();
89+
}
90+
return $safeResult;
91+
}
92+
93+
94+
/**
95+
* Fetches all HTTP request headers from the current request. Works in the
96+
* Apache, FastCGI, CLI, and FPM webservers.
97+
*
98+
* @return array An associative array of all the HTTP headers in the current request.
99+
* @throws ApacheException
100+
*
101+
*/
102+
function apache_request_headers(): array
103+
{
104+
error_clear_last();
105+
$safeResult = \apache_request_headers();
106+
if ($safeResult === false) {
107+
throw ApacheException::createFromPhpError();
108+
}
109+
return $safeResult;
110+
}
111+
112+
113+
/**
114+
* Fetch all HTTP response headers. Works in the
115+
* Apache, FastCGI, CLI, and FPM webservers.
116+
*
117+
* @return array An array of all Apache response headers on success.
118+
* @throws ApacheException
119+
*
120+
*/
121+
function apache_response_headers(): array
122+
{
123+
error_clear_last();
124+
$safeResult = \apache_response_headers();
125+
if ($safeResult === false) {
126+
throw ApacheException::createFromPhpError();
127+
}
128+
return $safeResult;
129+
}
130+
131+
132+
/**
133+
* apache_setenv sets the value of the Apache
134+
* environment variable specified by
135+
* variable.
136+
*
137+
* @param string $variable The environment variable that's being set.
138+
* @param string $value The new variable value.
139+
* @param bool $walk_to_top Whether to set the top-level variable available to all Apache layers.
140+
* @throws ApacheException
141+
*
142+
*/
143+
function apache_setenv(string $variable, string $value, bool $walk_to_top = false): void
144+
{
145+
error_clear_last();
146+
$safeResult = \apache_setenv($variable, $value, $walk_to_top);
147+
if ($safeResult === false) {
148+
throw ApacheException::createFromPhpError();
149+
}
150+
}
151+
152+
153+
/**
154+
* Fetches all HTTP headers from the current request.
155+
*
156+
* This function is an alias for apache_request_headers.
157+
* Please read the apache_request_headers
158+
* documentation for more information on how this function works.
159+
*
160+
* @return array An associative array of all the HTTP headers in the current request.
161+
* @throws ApacheException
162+
*
163+
*/
164+
function getallheaders(): array
165+
{
166+
error_clear_last();
167+
$safeResult = \getallheaders();
168+
if ($safeResult === false) {
169+
throw ApacheException::createFromPhpError();
170+
}
171+
return $safeResult;
172+
}
173+
174+
175+
/**
176+
* virtual is an Apache-specific function which
177+
* is similar to &lt;!--#include virtual...--&gt; in
178+
* mod_include.
179+
* It performs an Apache sub-request. It is useful for including
180+
* CGI scripts or .shtml files, or anything else that you would
181+
* parse through Apache. Note that for a CGI script, the script
182+
* must generate valid CGI headers. At the minimum that means it
183+
* must generate a Content-Type header.
184+
*
185+
* To run the sub-request, all buffers are terminated and flushed to the
186+
* browser, pending headers are sent too.
187+
*
188+
* @param string $uri The file that the virtual command will be performed on.
189+
* @throws ApacheException
190+
*
191+
*/
192+
function virtual(string $uri): void
193+
{
194+
error_clear_last();
195+
$safeResult = \virtual($uri);
196+
if ($safeResult === false) {
197+
throw ApacheException::createFromPhpError();
198+
}
199+
}

generated/8.1/apcu.php

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
3+
namespace Safe;
4+
5+
use Safe\Exceptions\ApcuException;
6+
7+
/**
8+
* Retrieves cached information and meta-data from APC's data store.
9+
*
10+
* @param bool $limited If limited is TRUE, the
11+
* return value will exclude the individual list of cache entries. This
12+
* is useful when trying to optimize calls for statistics gathering.
13+
* @return array Array of cached data (and meta-data)
14+
* @throws ApcuException
15+
*
16+
*/
17+
function apcu_cache_info(bool $limited = false): array
18+
{
19+
error_clear_last();
20+
$safeResult = \apcu_cache_info($limited);
21+
if ($safeResult === false) {
22+
throw ApcuException::createFromPhpError();
23+
}
24+
return $safeResult;
25+
}
26+
27+
28+
/**
29+
* apcu_cas updates an already existing integer value if the
30+
* old parameter matches the currently stored value
31+
* with the value of the new parameter.
32+
*
33+
* @param string $key The key of the value being updated.
34+
* @param int $old The old value (the value currently stored).
35+
* @param int $new The new value to update to.
36+
* @throws ApcuException
37+
*
38+
*/
39+
function apcu_cas(string $key, int $old, int $new): void
40+
{
41+
error_clear_last();
42+
$safeResult = \apcu_cas($key, $old, $new);
43+
if ($safeResult === false) {
44+
throw ApcuException::createFromPhpError();
45+
}
46+
}
47+
48+
49+
/**
50+
* Decreases a stored integer value.
51+
*
52+
* @param string $key The key of the value being decreased.
53+
* @param int $step The step, or value to decrease.
54+
* @param bool|null $success Optionally pass the success or fail boolean value to
55+
* this referenced variable.
56+
* @param int $ttl TTL to use if the operation inserts a new value (rather than decrementing an existing one).
57+
* @return int Returns the current value of key's value on success
58+
* @throws ApcuException
59+
*
60+
*/
61+
function apcu_dec(string $key, int $step = 1, ?bool &$success = null, int $ttl = 0): int
62+
{
63+
error_clear_last();
64+
$safeResult = \apcu_dec($key, $step, $success, $ttl);
65+
if ($safeResult === false) {
66+
throw ApcuException::createFromPhpError();
67+
}
68+
return $safeResult;
69+
}
70+
71+
72+
/**
73+
* Increases a stored number.
74+
*
75+
* @param string $key The key of the value being increased.
76+
* @param int $step The step, or value to increase.
77+
* @param bool|null $success Optionally pass the success or fail boolean value to
78+
* this referenced variable.
79+
* @param int $ttl TTL to use if the operation inserts a new value (rather than incrementing an existing one).
80+
* @return int Returns the current value of key's value on success
81+
* @throws ApcuException
82+
*
83+
*/
84+
function apcu_inc(string $key, int $step = 1, ?bool &$success = null, int $ttl = 0): int
85+
{
86+
error_clear_last();
87+
$safeResult = \apcu_inc($key, $step, $success, $ttl);
88+
if ($safeResult === false) {
89+
throw ApcuException::createFromPhpError();
90+
}
91+
return $safeResult;
92+
}
93+
94+
95+
/**
96+
* Retrieves APCu Shared Memory Allocation information.
97+
*
98+
* @param bool $limited When set to FALSE (default) apcu_sma_info will
99+
* return a detailed information about each segment.
100+
* @return array Array of Shared Memory Allocation data; FALSE on failure.
101+
* @throws ApcuException
102+
*
103+
*/
104+
function apcu_sma_info(bool $limited = false): array
105+
{
106+
error_clear_last();
107+
$safeResult = \apcu_sma_info($limited);
108+
if ($safeResult === false) {
109+
throw ApcuException::createFromPhpError();
110+
}
111+
return $safeResult;
112+
}

0 commit comments

Comments
 (0)