Fix callable and iterable handling

This commit is contained in:
Máté Kocsis 2021-08-24 19:19:35 +02:00
parent bdfe0ab505
commit 4a7a414735
No known key found for this signature in database
GPG key ID: FD055E41728BF310
4 changed files with 20 additions and 13 deletions

View file

@ -61,4 +61,5 @@ static const func_info_t func_infos[] = {
FN("oci_password_change", MAY_BE_RESOURCE|MAY_BE_BOOL), FN("oci_password_change", MAY_BE_RESOURCE|MAY_BE_BOOL),
FN("oci_new_cursor", MAY_BE_RESOURCE|MAY_BE_FALSE), FN("oci_new_cursor", MAY_BE_RESOURCE|MAY_BE_FALSE),
F1("pg_socket", MAY_BE_RESOURCE|MAY_BE_FALSE), F1("pg_socket", MAY_BE_RESOURCE|MAY_BE_FALSE),
FN("pcntl_signal_get_handler", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_OBJECT|MAY_BE_LONG),
}; };

View file

@ -91,13 +91,13 @@ function trigger_error(string $message, int $error_level = E_USER_NOTICE): bool
/** @alias trigger_error */ /** @alias trigger_error */
function user_error(string $message, int $error_level = E_USER_NOTICE): bool {} function user_error(string $message, int $error_level = E_USER_NOTICE): bool {}
/** @return string|array<int, string|object>|object|null */ /** @return callable|null */
function set_error_handler(?callable $callback, int $error_levels = E_ALL) {} function set_error_handler(?callable $callback, int $error_levels = E_ALL) {}
/** @return true */ /** @return true */
function restore_error_handler(): bool {} function restore_error_handler(): bool {}
/** @return string|array<int, string|object>|object|null */ /** @return callable|null */
function set_exception_handler(?callable $callback) {} function set_exception_handler(?callable $callback) {}
/** @return true */ /** @return true */

View file

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead. /* This is a generated file, edit the .stub.php file instead.
* Stub hash: cf84a097dab1a043133faf0b03f002748b3c8eda */ * Stub hash: 830eee0780adba8fc87cd5aed7f755d4d85ed82b */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()

View file

@ -192,6 +192,7 @@ class SimpleType {
case "int": case "int":
case "float": case "float":
case "string": case "string":
case "callable":
case "iterable": case "iterable":
case "object": case "object":
case "resource": case "resource":
@ -297,8 +298,12 @@ class SimpleType {
return "MAY_BE_OBJECT"; return "MAY_BE_OBJECT";
case "callable": case "callable":
return "MAY_BE_CALLABLE"; return "MAY_BE_CALLABLE";
case "iterable":
return "MAY_BE_ITERABLE";
case "mixed": case "mixed":
return "MAY_BE_ANY"; return "MAY_BE_ANY";
case "void":
return "MAY_BE_VOID";
case "static": case "static":
return "MAY_BE_STATIC"; return "MAY_BE_STATIC";
case "never": case "never":
@ -357,16 +362,17 @@ class SimpleType {
return "MAY_BE_OBJECT"; return "MAY_BE_OBJECT";
} }
if ($this->name === "resource") { switch ($this->name) {
return "MAY_BE_RESOURCE"; case "true":
} return "MAY_BE_TRUE";
case "resource":
if ($this->name === "true") { return "MAY_BE_RESOURCE";
return "MAY_BE_TRUE"; case "callable":
} return "MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_OBJECT";
case "iterable":
if ($this->name === "mixed") { return "MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_OBJECT";
return "MAY_BE_ANY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY"; case "mixed":
return "MAY_BE_ANY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY";
} }
return $this->toTypeMask(); return $this->toTypeMask();