Skip to content

Commit e58074e

Browse files
committed
adding array_flip to deprecated
1 parent 2297f41 commit e58074e

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"files": [
1414
"deprecated/apc.php",
15+
"deprecated/arrays.php",
1516
"deprecated/libevent.php",
1617
"deprecated/mssql.php",
1718
"deprecated/stats.php",

deprecated/arrays.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Safe;
4+
5+
use Safe\Exceptions\ArrayException;
6+
7+
/**
8+
* array_flip returns an array in flip
9+
* order, i.e. keys from array become values and values
10+
* from array become keys.
11+
*
12+
* Note that the values of array need to be valid
13+
* keys, i.e. they need to be either integer or
14+
* string. A warning will be emitted if a value has the wrong
15+
* type, and the key/value pair in question will not be included
16+
* in the result.
17+
*
18+
* If a value has several occurrences, the latest key will be
19+
* used as its value, and all others will be lost.
20+
*
21+
* @param array $array An array of key/value pairs to be flipped.
22+
* @return array Returns the flipped array on success.
23+
* @throws ArrayException
24+
*
25+
*/
26+
function array_flip(array $array): array
27+
{
28+
return \array_flip($array);
29+
}

deprecated/functionsList.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'apc_inc',
1212
'apc_load_constants',
1313
'apc_sma_info',
14+
'array_flip',
1415
'event_add',
1516
'event_base_loopbreak',
1617
'event_base_loopexit',

deprecated/strings.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,10 @@
298298
function sprintf(string $format, ...$params): string
299299
{
300300
if ($params !== []) {
301-
$result = \sprintf($format, ...$params);
301+
return \sprintf($format, ...$params);
302302
} else {
303-
$result = \sprintf($format);
303+
return \sprintf($format);
304304
}
305-
return $result;
306305
}
307306

308307
/**
@@ -358,9 +357,8 @@ function sprintf(string $format, ...$params): string
358357
function substr(string $string, int $start, int $length = null): string
359358
{
360359
if ($length !== null) {
361-
$result = \substr($string, $start, $length);
360+
return \substr($string, $start, $length);
362361
} else {
363-
$result = \substr($string, $start);
362+
return \substr($string, $start);
364363
}
365-
return $result;
366364
}

0 commit comments

Comments
 (0)