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.
This commit is contained in:
Nikita Popov 2020-10-22 14:49:48 +02:00
parent db5979dfe2
commit 97dd0eb98d
3 changed files with 7 additions and 5 deletions

View file

@ -36,7 +36,7 @@ function dba_exists($key, $dba): bool {}
*/
function dba_fetch($key, $skip, $dba = UNKNOWN): string|false {}
function dba_key_split(string $key): array|false {}
function dba_key_split(string|false|null $key): array|false {}
/** @param resource $dba */
function dba_firstkey($dba): string|false {}

View file

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 15c236854ed1d2e775486de5c8018adbd00506f9 */
* Stub hash: 63980c2a7227d1b5dbd566efb3efbf8c45c55c0d */
ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2)
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
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dba_key_split, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_FALSE|MAY_BE_NULL, NULL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dba_firstkey, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)

View file

@ -7,8 +7,9 @@ DBA Split Test
?>
--FILE--
<?php
var_dump(dba_key_split(1));
var_dump(dba_key_split(null));
var_dump(dba_key_split(false));
var_dump(dba_key_split(1));
var_dump(dba_key_split(""));
var_dump(dba_key_split("name1"));
var_dump(dba_key_split("[key1"));
@ -20,13 +21,14 @@ var_dump(dba_key_split("[key1]name1"));
?>
--EXPECT--
bool(false)
bool(false)
array(2) {
[0]=>
string(0) ""
[1]=>
string(1) "1"
}
bool(false)
array(2) {
[0]=>
string(0) ""