Skip to content

Commit

Permalink
Fix callable and iterable handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed Aug 25, 2021
1 parent bdfe0ab commit 4a7a414
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ static const func_info_t func_infos[] = {
FN("oci_password_change", MAY_BE_RESOURCE|MAY_BE_BOOL),
FN("oci_new_cursor", 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),
};
4 changes: 2 additions & 2 deletions Zend/zend_builtin_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ function trigger_error(string $message, int $error_level = E_USER_NOTICE): bool
/** @alias trigger_error */
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) {}

/** @return true */
function restore_error_handler(): bool {}

/** @return string|array<int, string|object>|object|null */
/** @return callable|null */
function set_exception_handler(?callable $callback) {}

/** @return true */
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_builtin_functions_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 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_END_ARG_INFO()
Expand Down
26 changes: 16 additions & 10 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public static function fromString(string $typeString): SimpleType
case "int":
case "float":
case "string":
case "callable":
case "iterable":
case "object":
case "resource":
Expand Down Expand Up @@ -297,8 +298,12 @@ public function toTypeMask(): string {
return "MAY_BE_OBJECT";
case "callable":
return "MAY_BE_CALLABLE";
case "iterable":
return "MAY_BE_ITERABLE";
case "mixed":
return "MAY_BE_ANY";
case "void":
return "MAY_BE_VOID";
case "static":
return "MAY_BE_STATIC";
case "never":
Expand Down Expand Up @@ -357,16 +362,17 @@ public function toOptimizerTypeMask(): string {
return "MAY_BE_OBJECT";
}

if ($this->name === "resource") {
return "MAY_BE_RESOURCE";
}

if ($this->name === "true") {
return "MAY_BE_TRUE";
}

if ($this->name === "mixed") {
return "MAY_BE_ANY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY";
switch ($this->name) {
case "true":
return "MAY_BE_TRUE";
case "resource":
return "MAY_BE_RESOURCE";
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":
return "MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_OBJECT";
case "mixed":
return "MAY_BE_ANY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY";
}

return $this->toTypeMask();
Expand Down

0 comments on commit 4a7a414

Please sign in to comment.