Skip to content

Commit 6ec9a70

Browse files
committed
integrating thewilkybarkid PR
2 parents aab612d + 7073dc7 commit 6ec9a70

17 files changed

+528
-4
lines changed

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"generated/msql.php",
5353
"generated/mssql.php",
5454
"generated/mysql.php",
55+
"generated/mysqli.php",
5556
"generated/mysqlndMs.php",
5657
"generated/mysqlndQc.php",
5758
"generated/network.php",
@@ -78,6 +79,7 @@
7879
"generated/solr.php",
7980
"generated/spl.php",
8081
"generated/sqlsrv.php",
82+
"generated/ssdeep.php",
8183
"generated/ssh2.php",
8284
"generated/stats.php",
8385
"generated/stream.php",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
namespace Safe\Exceptions;
3+
4+
class MysqliException extends AbstractSafeException
5+
{
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
namespace Safe\Exceptions;
3+
4+
class SsdeepException extends AbstractSafeException
5+
{
6+
}

generated/array.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,42 @@ function array_multisort(array &$array1, $array1_sort_order = SORT_ASC, $array1_
102102
}
103103

104104

105+
/**
106+
* Searches haystack for needle.
107+
*
108+
* @param mixed $needle The searched value.
109+
*
110+
* If needle is a string, the comparison is done
111+
* in a case-sensitive manner.
112+
* @param array $haystack The array.
113+
* @param bool $strict If the third parameter strict is set to TRUE
114+
* then the array_search function will search for
115+
* identical elements in the
116+
* haystack. This means it will also perform a
117+
* strict type comparison of the
118+
* needle in the haystack,
119+
* and objects must be the same instance.
120+
* @return int|string Returns the key for needle if it is found in the
121+
* array, FALSE otherwise.
122+
*
123+
* If needle is found in haystack
124+
* more than once, the first matching key is returned. To return the keys for
125+
* all matching values, use array_keys with the optional
126+
* search_value parameter instead.
127+
* @throws ArrayException
128+
*
129+
*/
130+
function array_search($needle, array $haystack, bool $strict = false)
131+
{
132+
error_clear_last();
133+
$result = \array_search($needle, $haystack, $strict);
134+
if ($result === false) {
135+
throw ArrayException::createFromPhpError();
136+
}
137+
return $result;
138+
}
139+
140+
105141
/**
106142
* Applies the user-defined callback function to each
107143
* element of the array. This function will recurse

generated/filter.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,55 @@ function filter_has_var(int $type, string $variable_name): void
2424
}
2525

2626

27+
/**
28+
* This function is useful for retrieving many values without
29+
* repetitively calling filter_input.
30+
*
31+
* @param int $type One of INPUT_GET, INPUT_POST,
32+
* INPUT_COOKIE, INPUT_SERVER, or
33+
* INPUT_ENV.
34+
* @param int|array $definition An array defining the arguments. A valid key is a string
35+
* containing a variable name and a valid value is either a filter type, or an array
36+
* optionally specifying the filter, flags and options. If the value is an
37+
* array, valid keys are filter which specifies the
38+
* filter type,
39+
* flags which specifies any flags that apply to the
40+
* filter, and options which specifies any options that
41+
* apply to the filter. See the example below for a better understanding.
42+
*
43+
* This parameter can be also an integer holding a filter constant. Then all values in the
44+
* input array are filtered by this filter.
45+
* @param bool $add_empty Add missing keys as NULL to the return value.
46+
* @return mixed An array containing the values of the requested variables on success.
47+
* If the input array designated by type is not populated,
48+
* the function returns NULL if the FILTER_NULL_ON_FAILURE
49+
* flag is not given, or FALSE otherwise. For other failures, FALSE is returned.
50+
*
51+
* An array value will be FALSE if the filter fails, or NULL if
52+
* the variable is not set. Or if the flag FILTER_NULL_ON_FAILURE
53+
* is used, it returns FALSE if the variable is not set and NULL if the filter
54+
* fails. If the add_empty parameter is FALSE, no array
55+
* element will be added for unset variables.
56+
* @throws FilterException
57+
*
58+
*/
59+
function filter_input_array(int $type, $definition = null, bool $add_empty = true)
60+
{
61+
error_clear_last();
62+
if ($add_empty !== true) {
63+
$result = \filter_input_array($type, $definition, $add_empty);
64+
} elseif ($definition !== null) {
65+
$result = \filter_input_array($type, $definition);
66+
} else {
67+
$result = \filter_input_array($type);
68+
}
69+
if ($result === false) {
70+
throw FilterException::createFromPhpError();
71+
}
72+
return $result;
73+
}
74+
75+
2776
/**
2877
* This function is useful for retrieving many values without
2978
* repetitively calling filter_var.

generated/functionsList.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'apcu_sma_info',
2828
'array_combine',
2929
'array_multisort',
30+
'array_search',
3031
'array_walk_recursive',
3132
'arsort',
3233
'asort',
@@ -171,6 +172,7 @@
171172
'touch',
172173
'unlink',
173174
'filter_has_var',
175+
'filter_input_array',
174176
'filter_var_array',
175177
'fastcgi_finish_request',
176178
'ftp_alloc',
@@ -296,6 +298,10 @@
296298
'imageopenpolygon',
297299
'imagepng',
298300
'imagepolygon',
301+
'imagepsencodefont',
302+
'imagepsextendfont',
303+
'imagepsfreefont',
304+
'imagepsslantfont',
299305
'imagerectangle',
300306
'imagerotate',
301307
'imagesavealpha',
@@ -437,6 +443,7 @@
437443
'event_priority_set',
438444
'event_set',
439445
'event_timer_set',
446+
'libxml_get_last_error',
440447
'libxml_set_external_entity_loader',
441448
'lzf_compress',
442449
'lzf_decompress',
@@ -492,6 +499,7 @@
492499
'mssql_data_seek',
493500
'mssql_field_length',
494501
'mssql_field_name',
502+
'mssql_field_seek',
495503
'mssql_field_type',
496504
'mssql_free_result',
497505
'mssql_free_statement',
@@ -530,6 +538,8 @@
530538
'mysql_tablename',
531539
'mysql_thread_id',
532540
'mysql_unbuffered_query',
541+
'mysqli_get_cache_stats',
542+
'mysqli_get_client_stats',
533543
'mysqlnd_ms_dump_servers',
534544
'mysqlnd_ms_fabric_select_global',
535545
'mysqlnd_ms_fabric_select_shard',
@@ -914,16 +924,22 @@
914924
'spl_autoload_unregister',
915925
'sqlsrv_begin_transaction',
916926
'sqlsrv_cancel',
927+
'sqlsrv_client_info',
917928
'sqlsrv_close',
918929
'sqlsrv_commit',
919930
'sqlsrv_configure',
920931
'sqlsrv_execute',
921932
'sqlsrv_free_stmt',
933+
'sqlsrv_get_field',
922934
'sqlsrv_next_result',
935+
'sqlsrv_num_fields',
923936
'sqlsrv_num_rows',
924937
'sqlsrv_prepare',
925938
'sqlsrv_query',
926939
'sqlsrv_rollback',
940+
'ssdeep_fuzzy_compare',
941+
'ssdeep_fuzzy_hash_filename',
942+
'ssdeep_fuzzy_hash',
927943
'ssh2_auth_agent',
928944
'ssh2_auth_hostbased_file',
929945
'ssh2_auth_password',
@@ -970,7 +986,9 @@
970986
'convert_uudecode',
971987
'convert_uuencode',
972988
'hex2bin',
989+
'md5_file',
973990
'metaphone',
991+
'sha1_file',
974992
'sprintf',
975993
'substr',
976994
'swoole_async_write',

generated/image.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,92 @@ function imagepolygon($image, array $points, int $num_points, int $color): void
14991499
}
15001500

15011501

1502+
/**
1503+
* Loads a character encoding vector from a file and changes the fonts
1504+
* encoding vector to it. As a PostScript fonts default vector lacks most of
1505+
* the character positions above 127, you'll definitely want to change this
1506+
* if you use a language other than English.
1507+
*
1508+
* If you find yourself using this function all the time, a much
1509+
* better way to define the encoding is to set ps.default_encoding in
1510+
* the configuration file
1511+
* to point to the right encoding file and all fonts you load will
1512+
* automatically have the right encoding.
1513+
*
1514+
* @param resource $font_index A font resource, returned by imagepsloadfont.
1515+
* @param string $encodingfile The exact format of this file is described in T1libs documentation.
1516+
* T1lib comes with two ready-to-use files,
1517+
* IsoLatin1.enc and
1518+
* IsoLatin2.enc.
1519+
* @throws ImageException
1520+
*
1521+
*/
1522+
function imagepsencodefont($font_index, string $encodingfile): void
1523+
{
1524+
error_clear_last();
1525+
$result = \imagepsencodefont($font_index, $encodingfile);
1526+
if ($result === false) {
1527+
throw ImageException::createFromPhpError();
1528+
}
1529+
}
1530+
1531+
1532+
/**
1533+
* Extend or condense a font (font_index), if
1534+
* the value of the extend parameter is less
1535+
* than one you will be condensing the font.
1536+
*
1537+
* @param resource $font_index A font resource, returned by imagepsloadfont.
1538+
* @param float $extend Extension value, must be greater than 0.
1539+
* @throws ImageException
1540+
*
1541+
*/
1542+
function imagepsextendfont($font_index, float $extend): void
1543+
{
1544+
error_clear_last();
1545+
$result = \imagepsextendfont($font_index, $extend);
1546+
if ($result === false) {
1547+
throw ImageException::createFromPhpError();
1548+
}
1549+
}
1550+
1551+
1552+
/**
1553+
* imagepsfreefont frees memory used by a PostScript
1554+
* Type 1 font.
1555+
*
1556+
* @param resource $font_index A font resource, returned by imagepsloadfont.
1557+
* @throws ImageException
1558+
*
1559+
*/
1560+
function imagepsfreefont($font_index): void
1561+
{
1562+
error_clear_last();
1563+
$result = \imagepsfreefont($font_index);
1564+
if ($result === false) {
1565+
throw ImageException::createFromPhpError();
1566+
}
1567+
}
1568+
1569+
1570+
/**
1571+
* Slant a given font.
1572+
*
1573+
* @param resource $font_index A font resource, returned by imagepsloadfont.
1574+
* @param float $slant Slant level.
1575+
* @throws ImageException
1576+
*
1577+
*/
1578+
function imagepsslantfont($font_index, float $slant): void
1579+
{
1580+
error_clear_last();
1581+
$result = \imagepsslantfont($font_index, $slant);
1582+
if ($result === false) {
1583+
throw ImageException::createFromPhpError();
1584+
}
1585+
}
1586+
1587+
15021588
/**
15031589
* imagerectangle creates a rectangle starting at
15041590
* the specified coordinates.

generated/libxml.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44

55
use Safe\Exceptions\LibxmlException;
66

7+
/**
8+
* Retrieve last error from libxml.
9+
*
10+
* @return object Returns a LibXMLError object if there is any error in the
11+
* buffer, FALSE otherwise.
12+
* @throws LibxmlException
13+
*
14+
*/
15+
function libxml_get_last_error(): \LibXMLError
16+
{
17+
error_clear_last();
18+
$result = \libxml_get_last_error();
19+
if ($result === false) {
20+
throw LibxmlException::createFromPhpError();
21+
}
22+
return $result;
23+
}
24+
25+
726
/**
827
* Changes the default external entity loader.
928
*

generated/mssql.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,27 @@ function mssql_field_name($result, int $offset = -1): string
184184
}
185185

186186

187+
/**
188+
* Seeks to the specified field offset. If the next call to
189+
* mssql_fetch_field won't include a field
190+
* offset, this field would be returned.
191+
*
192+
* @param resource $result The result resource that is being evaluated. This result comes from a
193+
* call to mssql_query.
194+
* @param int $field_offset The field offset, starts at 0.
195+
* @throws MssqlException
196+
*
197+
*/
198+
function mssql_field_seek($result, int $field_offset): void
199+
{
200+
error_clear_last();
201+
$result = \mssql_field_seek($result, $field_offset);
202+
if ($result === false) {
203+
throw MssqlException::createFromPhpError();
204+
}
205+
}
206+
207+
187208
/**
188209
* Returns the type of field no. offset in
189210
* result.

0 commit comments

Comments
 (0)