Skip to content

Commit 311d66e

Browse files
authored
Merge pull request #7612 from ping-yee/230624_mix_in_helpers
docs: Replace type `mixed` in all helper files.
2 parents 89292d8 + 95cf346 commit 311d66e

6 files changed

Lines changed: 16 additions & 20 deletions

File tree

phpstan-baseline.neon.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ parameters:
155155
count: 1
156156
path: system/Helpers/filesystem_helper.php
157157

158-
-
159-
message: "#^Binary operation \"\\+\" between 0 and string results in an error\\.$#"
160-
count: 1
161-
path: system/Helpers/number_helper.php
162-
163158
-
164159
message: "#^Property CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:\\$image \\(CodeIgniter\\\\Images\\\\Image\\) in empty\\(\\) is not falsy\\.$#"
165160
count: 1

system/Helpers/array_helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function dot_array_search(string $index, array $array)
4141
*
4242
* @internal This should not be used on its own.
4343
*
44-
* @return mixed
44+
* @return array|bool|float|int|object|string|null
4545
*/
4646
function _array_search_dot(array $indexes, array $array)
4747
{
@@ -103,9 +103,9 @@ function _array_search_dot(array $indexes, array $array)
103103
/**
104104
* Returns the value of an element at a key in an array of uncertain depth.
105105
*
106-
* @param mixed $key
106+
* @param int|string $key
107107
*
108-
* @return mixed|null
108+
* @return array|bool|float|int|object|string|null
109109
*/
110110
function array_deep_search($key, array $array)
111111
{

system/Helpers/cookie_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function get_cookie($index, bool $xssClean = false, ?string $prefix = '')
8686
/**
8787
* Delete a cookie
8888
*
89-
* @param mixed $name
89+
* @param string $name
9090
* @param string $domain the cookie domain. Usually: .yourdomain.com
9191
* @param string $path the cookie path
9292
* @param string $prefix the cookie prefix

system/Helpers/filesystem_helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ function get_dir_file_info(string $sourceDir, bool $topLevelOnly = true, bool $r
292292
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
293293
* Returns false if the file cannot be found.
294294
*
295-
* @param string $file Path to file
296-
* @param mixed $returnedValues Array or comma separated string of information returned
295+
* @param string $file Path to file
296+
* @param array|string $returnedValues Array or comma separated string of information returned
297297
*
298298
* @return array|null
299299
*/

system/Helpers/number_helper.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
/**
1616
* Formats a numbers as bytes, based on size, and adds the appropriate suffix
1717
*
18-
* @param mixed $num Will be cast as int
19-
* @param string $locale
18+
* @param int|string $num Will be cast as int
19+
* @param string $locale
2020
*
2121
* @return bool|string
2222
*/
@@ -69,14 +69,15 @@ function number_to_size($num, int $precision = 1, ?string $locale = null)
6969
*
7070
* @see https://simple.wikipedia.org/wiki/Names_for_large_numbers
7171
*
72-
* @param string $num
72+
* @param int|string $num
7373
*
7474
* @return bool|string
7575
*/
7676
function number_to_amount($num, int $precision = 0, ?string $locale = null)
7777
{
7878
// Strip any formatting & ensure numeric input
7979
try {
80+
// @phpstan-ignore-next-line
8081
$num = 0 + str_replace(',', '', $num);
8182
} catch (ErrorException $ee) {
8283
return false;

system/Helpers/text_helper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ function word_wrap(string $str, int $charlim = 76): string
410410
*
411411
* This function will strip tags from a string, split it at its max_length and ellipsize
412412
*
413-
* @param string $str String to ellipsize
414-
* @param int $maxLength Max length of string
415-
* @param mixed $position int (1|0) or float, .5, .2, etc for position to split
416-
* @param string $ellipsis ellipsis ; Default '...'
413+
* @param string $str String to ellipsize
414+
* @param int $maxLength Max length of string
415+
* @param float|int $position int (1|0) or float, .5, .2, etc for position to split
416+
* @param string $ellipsis ellipsis ; Default '...'
417417
*
418418
* @return string Ellipsized string
419419
*/
@@ -446,9 +446,9 @@ function ellipsize(string $str, int $maxLength, $position = 1, string $ellipsis
446446
*
447447
* Removes slashes contained in a string or in an array
448448
*
449-
* @param mixed $str string or array
449+
* @param array|string $str string or array
450450
*
451-
* @return mixed string or array
451+
* @return array|string string or array
452452
*/
453453
function strip_slashes($str)
454454
{

0 commit comments

Comments
 (0)