Skip to content

Conversation

MaxSem
Copy link
Contributor

@MaxSem MaxSem commented Feb 14, 2021

This is for the RFC being drafted at https://wiki.php.net/rfc/instanceof_improvements

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.

}
}

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.

4 participants