Skip to content

Add a few types to zend_builtin_functions stub #13636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ static const func_info_t func_infos[] = {
F1("get_class_vars", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
F1("get_class_methods", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_included_files", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
FN("set_error_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_NULL),
FN("set_exception_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_NULL),
F1("get_declared_classes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_declared_traits", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_declared_interfaces", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
Expand Down
12 changes: 4 additions & 8 deletions Zend/zend_builtin_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ function get_mangled_object_vars(object $object): array {}
*/
function get_class_methods(object|string $object_or_class): array {}

/** @param object|string $object_or_class */
function method_exists($object_or_class, string $method): bool {}
function method_exists(object|string $object_or_class, string $method): bool {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were multiple attempts to add these param types but at last we settled on not to add them. See
#11555 (comment) for reasoning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, got it 👍


/**
* @param object|string $object_or_class
* @frameless-function {"arity": 2}
*/
function property_exists($object_or_class, string $property): bool {}
function property_exists(object|string $object_or_class, string $property): bool {}

/**
* @frameless-function {"arity": 1}
Expand Down Expand Up @@ -107,13 +105,11 @@ function trigger_error(string $message, int $error_level = E_USER_NOTICE): true
/** @alias trigger_error */
function user_error(string $message, int $error_level = E_USER_NOTICE): true {}

/** @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): ?callable {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason these return types are not documented is described in Nikita's comment: #5618 (review)


function restore_error_handler(): true {}

/** @return callable|null */
function set_exception_handler(?callable $callback) {}
function set_exception_handler(?callable $callback): ?callable {}

function restore_exception_handler(): true {}

Expand Down
10 changes: 5 additions & 5 deletions Zend/zend_builtin_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.