Skip to content

Make instanceof useful for more things #6694

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
Closed

Conversation

MaxSem
Copy link
Contributor

@MaxSem MaxSem commented Feb 14, 2021

zend_uchar t = zend_lookup_builtin_type_by_name(Z_STR(class_node.u.constant));

if (t == IS_NULL || t == _IS_BOOL || t == IS_LONG || t == IS_STRING || t == IS_DOUBLE || t == IS_OBJECT) {
zend_compile_func_typecheck_impl(result, obj_ast, t);
Copy link
Member

Choose a reason for hiding this comment

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

Needs a zval_ptr_dtor_nogc(&class_node.u.constant) to avoid leaking.

return;
}
}

opline = zend_emit_op_tmp(result, ZEND_INSTANCEOF, &obj_node, NULL);
Copy link
Member

Choose a reason for hiding this comment

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

ZEND_INSTANCEOF would have to be adjusted to make sure that you get the same behavior with a dynamic type name.

@nikic
Copy link
Member

nikic commented Feb 15, 2021

See also https://wiki.php.net/rfc/variable_syntax_tweaks#arbitrary_expression_support_for_new_and_instanceof for currently allowed syntax and the note in "Future Scope" on potential complications with omitted parentheses.

@iluuu1994
Copy link
Member

@MaxSem Are you planning on pursuing an RFC for this?

@MaxSem MaxSem closed this Apr 18, 2022
@MaxSem
Copy link
Contributor Author

MaxSem commented Apr 18, 2022

No, since then I noticed an RFC for is as part of ADT work.

@iluuu1994
Copy link
Member

Thanks, I closed the corresponding RFC as well.

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.

None yet

4 participants