Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"generated/ps.php",
"generated/pspell.php",
"generated/readline.php",
"generated/rpminfo.php",
"generated/rrd.php",
"generated/sem.php",
"generated/session.php",
Expand Down
11 changes: 11 additions & 0 deletions generated/Exceptions/RpminfoException.php
Original file line number Diff line number Diff line change
@@ -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);
}
}
6 changes: 5 additions & 1 deletion generated/curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,11 @@ function curl_multi_init()
* CURL_HTTP_VERSION_NONE (default, lets CURL
* decide which version to use),
* CURL_HTTP_VERSION_1_0 (forces HTTP/1.0),
* or CURL_HTTP_VERSION_1_1 (forces HTTP/1.1).
* CURL_HTTP_VERSION_1_1 (forces HTTP/1.1),
* CURL_HTTP_VERSION_2_0 (attempts HTTP 2),
* CURL_HTTP_VERSION_2 (alias of CURL_HTTP_VERSION_2_0),
* CURL_HTTP_VERSION_2TLS (attempts HTTP 2 over TLS (HTTPS) only) or
* CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE (issues non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade).
*
*
*
Expand Down
3 changes: 3 additions & 0 deletions generated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
'imagecreatefromgif',
'imagecreatefromjpeg',
'imagecreatefrompng',
'imagecreatefromstring',
'imagecreatefromwbmp',
'imagecreatefromwebp',
'imagecreatefromxbm',
Expand Down Expand Up @@ -482,6 +483,7 @@
'mb_regex_encoding',
'mb_send_mail',
'mb_split',
'mb_str_split',
'md5_file',
'metaphone',
'mime_content_type',
Expand Down Expand Up @@ -927,6 +929,7 @@
'rewind',
'rewinddir',
'rmdir',
'rpmaddtag',
'rrd_create',
'rsort',
'sapi_windows_cp_conv',
Expand Down
24 changes: 24 additions & 0 deletions generated/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,30 @@ function imagecreatefrompng(string $filename)
}


/**
* imagecreatefromstring returns an image identifier
* representing the image obtained from the given image.
* These types will be automatically detected if your build of PHP supports
* them: JPEG, PNG, GIF, BMP, WBMP, and GD2.
*
* @param string $image A string containing the image data.
* @return resource An image resource will be returned on success. FALSE is returned if
* the image type is unsupported, the data is not in a recognised format,
* or the image is corrupt and cannot be loaded.
* @throws ImageException
*
*/
function imagecreatefromstring(string $image)
{
error_clear_last();
$result = \imagecreatefromstring($image);
if ($result === false) {
throw ImageException::createFromPhpError();
}
return $result;
}


/**
* imagecreatefromwbmp returns an image identifier
* representing the image obtained from the given filename.
Expand Down
31 changes: 31 additions & 0 deletions generated/mbstring.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,34 @@ function mb_split(string $pattern, string $string, int $limit = -1): array
}
return $result;
}


/**
* 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.
* If the split_length parameter is specified, the string is broken down into chunks of the specified length in characters (not bytes).
* The encoding parameter can be optionally specified and it is good practice to do so.
*
* @param string $string The string to split into characters or chunks.
* @param int $split_length If specified, each element of the returned array will be composed of multiple characters instead of a single character.
* @param string $encoding The encoding
* parameter is the character encoding. If it is omitted, the internal character
* encoding value will be used.
*
* A string specifying one of the supported encodings.
* @return array mb_str_split returns an array of strings.
* @throws MbstringException
*
*/
function mb_str_split(string $string, int $split_length = 1, string $encoding = null): array
{
error_clear_last();
if ($encoding !== null) {
$result = \mb_str_split($string, $split_length, $encoding);
} else {
$result = \mb_str_split($string, $split_length);
}
if ($result === false) {
throw MbstringException::createFromPhpError();
}
return $result;
}
8 changes: 4 additions & 4 deletions generated/pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function pg_dbname($connection = null): string
* By default pg_delete passes raw values. Values
* must be escaped or PGSQL_DML_ESCAPE option must be
* specified. PGSQL_DML_ESCAPE quotes and escapes
* paramters/identifiers. Therefore, table/column names became case
* parameters/identifiers. Therefore, table/column names became case
* sensitive.
*
* Note that neither escape nor prepared query can protect LIKE query,
Expand Down Expand Up @@ -586,7 +586,7 @@ function pg_host($connection = null): string
* By default pg_insert passes raw values. Values
* must be escaped or PGSQL_DML_ESCAPE option must be
* specified. PGSQL_DML_ESCAPE quotes and escapes
* paramters/identifiers. Therefore, table/column names became case
* parameters/identifiers. Therefore, table/column names became case
* sensitive.
*
* Note that neither escape nor prepared query can protect LIKE query,
Expand Down Expand Up @@ -1536,7 +1536,7 @@ function pg_result_seek($result, int $offset): void
* By default pg_select passes raw values. Values
* must be escaped or PGSQL_DML_ESCAPE option must be
* specified. PGSQL_DML_ESCAPE quotes and escapes
* paramters/identifiers. Therefore, table/column names became case
* parameters/identifiers. Therefore, table/column names became case
* sensitive.
*
* Note that neither escape nor prepared query can protect LIKE query,
Expand Down Expand Up @@ -1810,7 +1810,7 @@ function pg_tty($connection = null): string
* By default pg_update passes raw values. Values
* must be escaped or PGSQL_DML_ESCAPE option must be
* specified. PGSQL_DML_ESCAPE quotes and escapes
* paramters/identifiers. Therefore, table/column names became case
* parameters/identifiers. Therefore, table/column names became case
* sensitive.
*
* Note that neither escape nor prepared query can protect LIKE query,
Expand Down
2 changes: 1 addition & 1 deletion generated/pspell.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function pspell_clear_session(int $dictionary_link): void
* 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned
* 32'. This parameter is largely untested, so be careful when
* using.
* @return int Retuns a pspell config identifier.
* @return int Returns a pspell config identifier.
* @throws PspellException
*
*/
Expand Down
21 changes: 21 additions & 0 deletions generated/rpminfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Safe;

use Safe\Exceptions\RpminfoException;

/**
* Add an additional retrieved tag in subsequent queries.
*
* @param int $tag One of RPMTAG_* constant, see the rpminfo constants page.
* @throws RpminfoException
*
*/
function rpmaddtag(int $tag): void
{
error_clear_last();
$result = \rpmaddtag($tag);
if ($result === false) {
throw RpminfoException::createFromPhpError();
}
}
4 changes: 2 additions & 2 deletions generated/strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ function soundex(string $str): string
* G
*
* Like the g specifier but uses
* E and F.
* E and f.
*
*
*
Expand Down Expand Up @@ -734,7 +734,7 @@ function substr(string $string, int $start, int $length = null): string
* G
*
* Like the g specifier but uses
* E and F.
* E and f.
*
*
*
Expand Down
5 changes: 5 additions & 0 deletions generator/src/DocPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public function detectFalsyFunction(): bool
return true;
}

//used to detect imagecreatefromstring
if (preg_match('/will be returned on success\. &false; is returned if/m', $file)) {
return true;
}

return false;
}

Expand Down
3 changes: 3 additions & 0 deletions rector-migrate-0.7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ services:
imagecreatefromgif: 'Safe\imagecreatefromgif'
imagecreatefromjpeg: 'Safe\imagecreatefromjpeg'
imagecreatefrompng: 'Safe\imagecreatefrompng'
imagecreatefromstring: 'Safe\imagecreatefromstring'
imagecreatefromwbmp: 'Safe\imagecreatefromwbmp'
imagecreatefromwebp: 'Safe\imagecreatefromwebp'
imagecreatefromxbm: 'Safe\imagecreatefromxbm'
Expand Down Expand Up @@ -484,6 +485,7 @@ services:
mb_regex_encoding: 'Safe\mb_regex_encoding'
mb_send_mail: 'Safe\mb_send_mail'
mb_split: 'Safe\mb_split'
mb_str_split: 'Safe\mb_str_split'
md5_file: 'Safe\md5_file'
metaphone: 'Safe\metaphone'
mime_content_type: 'Safe\mime_content_type'
Expand Down Expand Up @@ -929,6 +931,7 @@ services:
rewind: 'Safe\rewind'
rewinddir: 'Safe\rewinddir'
rmdir: 'Safe\rmdir'
rpmaddtag: 'Safe\rpmaddtag'
rrd_create: 'Safe\rrd_create'
rsort: 'Safe\rsort'
sapi_windows_cp_conv: 'Safe\sapi_windows_cp_conv'
Expand Down