-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
cb6ff32
to
e4b793c
Compare
7b17e1e
to
189a625
Compare
@@ -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 {} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, got it 👍
@@ -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 {} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically as @kocsismate has already indicated from prior discussion it is not really doable.
However, for set_error_handler
/set_exception_handler
I can imagine that if we return a Closure
instead of just a callable
that would solve the scoping issue that Nikita mentioned. But this might break some userland expectations?
There's no broken expectation I can see. What could be done in userland is either use |
Inspired by #13614, it seems we can add these return types to stubs?