Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed bug #64248 #282

Closed
wants to merge 1 commit into from

4 participants

@bwoebi

This little patch enables unset() to behave as a normal expr. This has for result that unset now returns a random int. While a good alternative for the (mt_)rand() functions, an idea would be to make unset return true if the variable has existed else false?

@MartinZottmann

[...] an idea would be to make unset return true if the variable has existed else false?

+1

@laruence
Owner

this definitely need a RFC

@lstrojny

For more information on what an RFC is, refer to https://wiki.php.net/rfc

@lstrojny

Otherwise I'll like it but the patch needs tests and making it return a boolean return value is a good idea as well.

@bwoebi

I've requested a php-wiki account for creating a rfc. I'll now change the unset language construct and rebase it to PHP-5.5 as you don't consider it as a bug fix only.

@bwoebi bwoebi closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 19, 2013
  1. @bwoebi

    Fixed bug #64248

    bwoebi authored
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  Zend/zend_language_parser.y
View
2  Zend/zend_language_parser.y
@@ -302,7 +302,6 @@ unticked_statement:
| T_ECHO echo_expr_list ';'
| T_INLINE_HTML { zend_do_echo(&$1 TSRMLS_CC); }
| expr ';' { zend_do_free(&$1 TSRMLS_CC); }
- | T_UNSET '(' unset_variables ')' ';'
| T_FOREACH '(' variable T_AS
{ zend_do_foreach_begin(&$1, &$2, &$3, &$4, 1 TSRMLS_CC); }
foreach_variable foreach_optional_arg ')' { zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
@@ -722,6 +721,7 @@ new_expr:
expr_without_variable:
T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' '=' expr { zend_do_list_end(&$$, &$7 TSRMLS_CC); }
+ | T_UNSET '(' unset_variables ')'
| variable '=' expr { zend_check_writable_variable(&$1); zend_do_assign(&$$, &$1, &$3 TSRMLS_CC); }
| variable '=' '&' variable { zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$4, BP_VAR_W, 1 TSRMLS_CC); zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$4 TSRMLS_CC); }
| variable '=' '&' T_NEW class_name_reference { zend_error(E_DEPRECATED, "Assigning the return value of new by reference is deprecated"); zend_check_writable_variable(&$1); zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$4, &$5 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$3, &$4, &$7 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); $3.EA = ZEND_PARSED_NEW; zend_do_assign_ref(&$$, &$1, &$3 TSRMLS_CC); }
Something went wrong with that request. Please try again.