Skip to content

Add hint-type for method_exists & property_exists #11555

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
wants to merge 1 commit into from

Conversation

milwad-dev
Copy link

The get_class_methods has a type-hint, but method_exists & property_exists have no type-hint for object_or_class parameters.

@iluuu1994
Copy link
Member

@kocsismate What's the reason for using doc types here rather than real parameter types here? ZPP already restricts this to objects and strings.

@kocsismate
Copy link
Member

What's the reason for using doc types here rather than real parameter types here? ZPP already restricts this to objects and strings.

Huh, I'm not sure anymore... As far as I remember, I wanted to use Z_PARAM_OBJ_OR_CLASS_NAME first, but we decided not to do it due to the RETURN_FALSE when the class cannot be autoloaded.

And that's all what I remember... object|string should work and we could even use fast ZPP.

@kocsismate
Copy link
Member

Ok, I've just found the answer: I already suspected that it may be because of loose vs strict parameter parsing, but George's comment in property_exists() makes the situation 100% clear:

/* We do not use Z_PARAM_OBJ_OR_STR here to be able to exclude int, float, and bool which are bogus class names */

@Girgias
Copy link
Member

Girgias commented Jun 29, 2023

@kocsismate What's the reason for using doc types here rather than real parameter types here? ZPP already restricts this to objects and strings.

The issue is when the coercive typing mode is used, as booleans, integers, and floating point numbers are going to be converted to string, however we know those are completely wrong as no class would satisfy those sorts of names.

I suppose we could also enhance those functions by adding a check for an empty string, but the zend_lookup_class() kinda takes care of that already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants