Skip to content

Commit 04f9ffa

Browse files
authored
Merge pull request #217 from Kharhamel/imagecreatefromstring
Imagecreatefromstring
2 parents f440677 + 5611d76 commit 04f9ffa

File tree

12 files changed

+111
-8
lines changed

12 files changed

+111
-8
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"generated/ps.php",
7070
"generated/pspell.php",
7171
"generated/readline.php",
72+
"generated/rpminfo.php",
7273
"generated/rrd.php",
7374
"generated/sem.php",
7475
"generated/session.php",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
namespace Safe\Exceptions;
3+
4+
class RpminfoException extends \ErrorException implements SafeExceptionInterface
5+
{
6+
public static function createFromPhpError(): self
7+
{
8+
$error = error_get_last();
9+
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
10+
}
11+
}

generated/curl.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,11 @@ function curl_multi_init()
13871387
* CURL_HTTP_VERSION_NONE (default, lets CURL
13881388
* decide which version to use),
13891389
* CURL_HTTP_VERSION_1_0 (forces HTTP/1.0),
1390-
* or CURL_HTTP_VERSION_1_1 (forces HTTP/1.1).
1390+
* CURL_HTTP_VERSION_1_1 (forces HTTP/1.1),
1391+
* CURL_HTTP_VERSION_2_0 (attempts HTTP 2),
1392+
* CURL_HTTP_VERSION_2 (alias of CURL_HTTP_VERSION_2_0),
1393+
* CURL_HTTP_VERSION_2TLS (attempts HTTP 2 over TLS (HTTPS) only) or
1394+
* CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE (issues non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade).
13911395
*
13921396
*
13931397
*

generated/functionsList.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
'imagecreatefromgif',
303303
'imagecreatefromjpeg',
304304
'imagecreatefrompng',
305+
'imagecreatefromstring',
305306
'imagecreatefromwbmp',
306307
'imagecreatefromwebp',
307308
'imagecreatefromxbm',
@@ -482,6 +483,7 @@
482483
'mb_regex_encoding',
483484
'mb_send_mail',
484485
'mb_split',
486+
'mb_str_split',
485487
'md5_file',
486488
'metaphone',
487489
'mime_content_type',
@@ -927,6 +929,7 @@
927929
'rewind',
928930
'rewinddir',
929931
'rmdir',
932+
'rpmaddtag',
930933
'rrd_create',
931934
'rsort',
932935
'sapi_windows_cp_conv',

generated/image.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,30 @@ function imagecreatefrompng(string $filename)
809809
}
810810

811811

812+
/**
813+
* imagecreatefromstring returns an image identifier
814+
* representing the image obtained from the given image.
815+
* These types will be automatically detected if your build of PHP supports
816+
* them: JPEG, PNG, GIF, BMP, WBMP, and GD2.
817+
*
818+
* @param string $image A string containing the image data.
819+
* @return resource An image resource will be returned on success. FALSE is returned if
820+
* the image type is unsupported, the data is not in a recognised format,
821+
* or the image is corrupt and cannot be loaded.
822+
* @throws ImageException
823+
*
824+
*/
825+
function imagecreatefromstring(string $image)
826+
{
827+
error_clear_last();
828+
$result = \imagecreatefromstring($image);
829+
if ($result === false) {
830+
throw ImageException::createFromPhpError();
831+
}
832+
return $result;
833+
}
834+
835+
812836
/**
813837
* imagecreatefromwbmp returns an image identifier
814838
* representing the image obtained from the given filename.

generated/mbstring.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,34 @@ function mb_split(string $pattern, string $string, int $limit = -1): array
493493
}
494494
return $result;
495495
}
496+
497+
498+
/**
499+
* This function will return an array of strings, it is a version of str_split with support for encodings of variable character size as well as fixed-size encodings of 1,2 or 4 byte characters.
500+
* If the split_length parameter is specified, the string is broken down into chunks of the specified length in characters (not bytes).
501+
* The encoding parameter can be optionally specified and it is good practice to do so.
502+
*
503+
* @param string $string The string to split into characters or chunks.
504+
* @param int $split_length If specified, each element of the returned array will be composed of multiple characters instead of a single character.
505+
* @param string $encoding The encoding
506+
* parameter is the character encoding. If it is omitted, the internal character
507+
* encoding value will be used.
508+
*
509+
* A string specifying one of the supported encodings.
510+
* @return array mb_str_split returns an array of strings.
511+
* @throws MbstringException
512+
*
513+
*/
514+
function mb_str_split(string $string, int $split_length = 1, string $encoding = null): array
515+
{
516+
error_clear_last();
517+
if ($encoding !== null) {
518+
$result = \mb_str_split($string, $split_length, $encoding);
519+
} else {
520+
$result = \mb_str_split($string, $split_length);
521+
}
522+
if ($result === false) {
523+
throw MbstringException::createFromPhpError();
524+
}
525+
return $result;
526+
}

generated/pgsql.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function pg_dbname($connection = null): string
305305
* By default pg_delete passes raw values. Values
306306
* must be escaped or PGSQL_DML_ESCAPE option must be
307307
* specified. PGSQL_DML_ESCAPE quotes and escapes
308-
* paramters/identifiers. Therefore, table/column names became case
308+
* parameters/identifiers. Therefore, table/column names became case
309309
* sensitive.
310310
*
311311
* Note that neither escape nor prepared query can protect LIKE query,
@@ -586,7 +586,7 @@ function pg_host($connection = null): string
586586
* By default pg_insert passes raw values. Values
587587
* must be escaped or PGSQL_DML_ESCAPE option must be
588588
* specified. PGSQL_DML_ESCAPE quotes and escapes
589-
* paramters/identifiers. Therefore, table/column names became case
589+
* parameters/identifiers. Therefore, table/column names became case
590590
* sensitive.
591591
*
592592
* Note that neither escape nor prepared query can protect LIKE query,
@@ -1536,7 +1536,7 @@ function pg_result_seek($result, int $offset): void
15361536
* By default pg_select passes raw values. Values
15371537
* must be escaped or PGSQL_DML_ESCAPE option must be
15381538
* specified. PGSQL_DML_ESCAPE quotes and escapes
1539-
* paramters/identifiers. Therefore, table/column names became case
1539+
* parameters/identifiers. Therefore, table/column names became case
15401540
* sensitive.
15411541
*
15421542
* Note that neither escape nor prepared query can protect LIKE query,
@@ -1810,7 +1810,7 @@ function pg_tty($connection = null): string
18101810
* By default pg_update passes raw values. Values
18111811
* must be escaped or PGSQL_DML_ESCAPE option must be
18121812
* specified. PGSQL_DML_ESCAPE quotes and escapes
1813-
* paramters/identifiers. Therefore, table/column names became case
1813+
* parameters/identifiers. Therefore, table/column names became case
18141814
* sensitive.
18151815
*
18161816
* Note that neither escape nor prepared query can protect LIKE query,

generated/pspell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function pspell_clear_session(int $dictionary_link): void
8686
* 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned
8787
* 32'. This parameter is largely untested, so be careful when
8888
* using.
89-
* @return int Retuns a pspell config identifier.
89+
* @return int Returns a pspell config identifier.
9090
* @throws PspellException
9191
*
9292
*/

generated/rpminfo.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Safe;
4+
5+
use Safe\Exceptions\RpminfoException;
6+
7+
/**
8+
* Add an additional retrieved tag in subsequent queries.
9+
*
10+
* @param int $tag One of RPMTAG_* constant, see the rpminfo constants page.
11+
* @throws RpminfoException
12+
*
13+
*/
14+
function rpmaddtag(int $tag): void
15+
{
16+
error_clear_last();
17+
$result = \rpmaddtag($tag);
18+
if ($result === false) {
19+
throw RpminfoException::createFromPhpError();
20+
}
21+
}

generated/strings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ function soundex(string $str): string
363363
* G
364364
*
365365
* Like the g specifier but uses
366-
* E and F.
366+
* E and f.
367367
*
368368
*
369369
*
@@ -734,7 +734,7 @@ function substr(string $string, int $start, int $length = null): string
734734
* G
735735
*
736736
* Like the g specifier but uses
737-
* E and F.
737+
* E and f.
738738
*
739739
*
740740
*

0 commit comments

Comments
 (0)