-
Notifications
You must be signed in to change notification settings - Fork 7.9k
RFC: Turn clone()
into a function
#18919
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
base: master
Are you sure you want to change the base?
Conversation
… wording with functions This is in preparation of also exposing `clone()` as a function.
This is necessary for `clone()` which does not currently accept a parameter-less syntax, unless fully-qualified.
For use in stubs. see 9c7a3f8 see https://wiki.php.net/rfc/clone_with_v2 see php/php-src#18919
For use in stubs. see 9c7a3f8 see https://wiki.php.net/rfc/clone_with_v2 see php/php-src#18919
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.
LGTM in general
$a[0]->b = 0; | ||
try { | ||
$a = clone 0; | ||
$a[0]->b = 0; |
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.
Nit: Useless line
array_push($a->b, $c); | ||
try { | ||
$a = clone(null); | ||
array_push($a->b, $c); |
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.
Nit: Useless line
RETURN_THROWS(); | ||
} | ||
} | ||
} |
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.
This duplicates some logic from zend_vm_def.h. Can we consolidate? If not, we may at least link to the other function so that they are kept in-sync.
} | ||
} | ||
|
||
zend_object *cloned; |
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.
Nit: Combine declaration & init.
{ | ||
znode arg_node; | ||
|
||
if (args->children != 1) { |
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.
Could be an ZEND_ASSERT
for now.
RFC: https://wiki.php.net/rfc/clone_with_v2
Spun out of #18747.