Skip to content

Commit 97dd0eb

Browse files
committed
Fix stub for dba_key_split()
This is an extremely weird function, but the behavior seems to be intentional, and is quite clearly documented. So we adjust the stub to also accept false|null as arguments. I believe the implementation already correctly matches union type semantics.
1 parent db5979d commit 97dd0eb

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

ext/dba/dba.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function dba_exists($key, $dba): bool {}
3636
*/
3737
function dba_fetch($key, $skip, $dba = UNKNOWN): string|false {}
3838

39-
function dba_key_split(string $key): array|false {}
39+
function dba_key_split(string|false|null $key): array|false {}
4040

4141
/** @param resource $dba */
4242
function dba_firstkey($dba): string|false {}

ext/dba/dba_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 15c236854ed1d2e775486de5c8018adbd00506f9 */
2+
* Stub hash: 63980c2a7227d1b5dbd566efb3efbf8c45c55c0d */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2)
55
ZEND_ARG_INFO(0, path)
@@ -26,7 +26,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dba_fetch, 0, 2, MAY_BE_STRING|M
2626
ZEND_END_ARG_INFO()
2727

2828
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dba_key_split, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
29-
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
29+
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_FALSE|MAY_BE_NULL, NULL)
3030
ZEND_END_ARG_INFO()
3131

3232
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dba_firstkey, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)

ext/dba/tests/dba_split.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ DBA Split Test
77
?>
88
--FILE--
99
<?php
10-
var_dump(dba_key_split(1));
1110
var_dump(dba_key_split(null));
11+
var_dump(dba_key_split(false));
12+
var_dump(dba_key_split(1));
1213
var_dump(dba_key_split(""));
1314
var_dump(dba_key_split("name1"));
1415
var_dump(dba_key_split("[key1"));
@@ -20,13 +21,14 @@ var_dump(dba_key_split("[key1]name1"));
2021

2122
?>
2223
--EXPECT--
24+
bool(false)
25+
bool(false)
2326
array(2) {
2427
[0]=>
2528
string(0) ""
2629
[1]=>
2730
string(1) "1"
2831
}
29-
bool(false)
3032
array(2) {
3133
[0]=>
3234
string(0) ""

0 commit comments

Comments
 (0)