Skip to content

Commit

Permalink
Merge pull request #90 from moufmouf/ignore_some_functions
Browse files Browse the repository at this point in the history
Removing array_search and mb_check_encoding from the list of Safe functions
  • Loading branch information
moufmouf authored Jan 30, 2019
2 parents 0ed4676 + 373b994 commit a18b1fe
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 64 deletions.
36 changes: 0 additions & 36 deletions generated/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,42 +102,6 @@ function array_multisort(array &$array1, $array1_sort_order = SORT_ASC, $array1_
}


/**
* Searches haystack for needle.
*
* @param mixed $needle The searched value.
*
* If needle is a string, the comparison is done
* in a case-sensitive manner.
* @param array $haystack The array.
* @param bool $strict If the third parameter strict is set to TRUE
* then the array_search function will search for
* identical elements in the
* haystack. This means it will also perform a
* strict type comparison of the
* needle in the haystack,
* and objects must be the same instance.
* @return int|string Returns the key for needle if it is found in the
* array, FALSE otherwise.
*
* If needle is found in haystack
* more than once, the first matching key is returned. To return the keys for
* all matching values, use array_keys with the optional
* search_value parameter instead.
* @throws ArrayException
*
*/
function array_search($needle, array $haystack, bool $strict = false)
{
error_clear_last();
$result = \array_search($needle, $haystack, $strict);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
return $result;
}


/**
* Applies the user-defined callback function to each
* element of the array. This function will recurse
Expand Down
2 changes: 0 additions & 2 deletions generated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
'apcu_sma_info',
'array_combine',
'array_multisort',
'array_search',
'array_walk_recursive',
'arsort',
'asort',
Expand Down Expand Up @@ -451,7 +450,6 @@
'mailparse_msg_parse_file',
'mailparse_msg_parse',
'mailparse_stream_encode',
'mb_check_encoding',
'mb_chr',
'mb_detect_order',
'mb_encoding_aliases',
Expand Down
24 changes: 0 additions & 24 deletions generated/mbstring.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,6 @@

use Safe\Exceptions\MbstringException;

/**
* Checks if the specified byte stream is valid for the specified encoding.
* It is useful to prevent so-called "Invalid Encoding Attack".
*
* @param string $var The byte stream to check. If it is omitted, this function checks
* all the input from the beginning of the request.
* @param string $encoding The expected encoding.
* @throws MbstringException
*
*/
function mb_check_encoding(string $var = null, string $encoding = null): void
{
error_clear_last();
if ($encoding !== null) {
$result = \mb_check_encoding($var, $encoding);
} else {
$result = \mb_check_encoding($var);
}
if ($result === false) {
throw MbstringException::createFromPhpError();
}
}


/**
*
*
Expand Down
2 changes: 2 additions & 0 deletions generator/config/ignoredFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
'func_get_arg',
//'mktime', // 7th parameter has been removed in PHP 7
'call_user_func_array',
'mb_check_encoding',
'array_search',
];
2 changes: 0 additions & 2 deletions rector-migrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ services:
apcu_sma_info: 'Safe\apcu_sma_info'
array_combine: 'Safe\array_combine'
array_multisort: 'Safe\array_multisort'
array_search: 'Safe\array_search'
array_walk_recursive: 'Safe\array_walk_recursive'
arsort: 'Safe\arsort'
asort: 'Safe\asort'
Expand Down Expand Up @@ -452,7 +451,6 @@ services:
mailparse_msg_parse_file: 'Safe\mailparse_msg_parse_file'
mailparse_msg_parse: 'Safe\mailparse_msg_parse'
mailparse_stream_encode: 'Safe\mailparse_stream_encode'
mb_check_encoding: 'Safe\mb_check_encoding'
mb_chr: 'Safe\mb_chr'
mb_detect_order: 'Safe\mb_detect_order'
mb_encoding_aliases: 'Safe\mb_encoding_aliases'
Expand Down

0 comments on commit a18b1fe

Please # to comment.