Skip to content

Allow passing a second argument to gettype to resolve class names#5142

Closed
markrandall wants to merge 1 commit into
php:masterfrom
markrandall:extended-gettype
Closed

Allow passing a second argument to gettype to resolve class names#5142
markrandall wants to merge 1 commit into
php:masterfrom
markrandall:extended-gettype

Conversation

@markrandall
Copy link
Copy Markdown

No description provided.

Adding blessed changes

Replaced spaces with tabs

Return zend_string without intern

Returning copy of name
Comment thread ext/standard/type.c
ZEND_PARSE_PARAMETERS_END();

if (resolve_object_names && Z_TYPE_P(arg) == IS_OBJECT) {
RETURN_STR_COPY(Z_OBJ_P(arg)->ce->name);
Copy link
Copy Markdown
Member

@kocsismate kocsismate Feb 2, 2020

Choose a reason for hiding this comment

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

One gotcha I see with this solution is the ambiguous result when a resource class instance is passed to get_type(). See https://3v4l.org/5aEd2 for example. I admit though that this is an edge case (and maybe resource should be reserved independently from this PR?).

@markrandall
Copy link
Copy Markdown
Author

markrandall commented Feb 2, 2020

Possible alternative would be another function, maybe describe_type which would give int / float / bool / object(classname) / resource(resname) ?

CC @beberlei

@nikic
Copy link
Copy Markdown
Member

nikic commented Feb 2, 2020

Please add a new function, as you'll also want to fix the returned type names.

@markrandall
Copy link
Copy Markdown
Author

Implemented as new function in #5143

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants