com php-src: guard add array element: Zend/tests/type_declara tions/typed_properties_034.phpt Zend/zend_vm_ def.h Zend/zend_vm_execute.h

From: Date: Mon, 21 Mar 2016 19:10:56 +0000
Subject: com php-src: guard add array element: Zend/tests/type_declara tions/typed_properties_034.phpt Zend/zend_vm_ def.h Zend/zend_vm_execute.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95658@lists.php.net to get a copy of this message
Commit: b1543e5aae335ec7ef151970d6ad458416b5d06c Author: Joe Watkins <krakjoe@php.net> Mon, 21 Mar 2016 19:10:56 +0000 Parents: 1dfbed47157063f573f117f222f426c87752dcc1 Branches: typed_ref_properties Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b1543e5aae335ec7ef151970d6ad458416b5d06c Log: guard add array element Changed paths: A Zend/tests/type_declarations/typed_properties_034.phpt M Zend/zend_vm_def.h M Zend/zend_vm_execute.h Diff: diff --git a/Zend/tests/type_declarations/typed_properties_034.phpt b/Zend/tests/type_declarations/typed_properties_034.phpt new file mode 100644 index 0000000..64a6c5d --- /dev/null +++ b/Zend/tests/type_declarations/typed_properties_034.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test typed properties add array element guard +--FILE-- +<?php +$foo = new class +{ + public int $bar = 42; + + public function getIterator() + { + foreach(['1', &$this->bar] as $item) + { + yield $item; + } + } +}; + +foreach($foo->getIterator() as $item); +--EXPECTF-- +Fatal error: Uncaught TypeError: Typed property class@anonymous::$bar must not be referenced in %s:8 +Stack trace: +#0 %s(15): class@anonymous->getIterator() +#1 {main} + thrown in %s on line 8 diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 50ed50a..580ffb7 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1990,7 +1990,8 @@ ZEND_VM_HANDLER(85, ZEND_FETCH_OBJ_W, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV) case ZEND_SEND_REF: case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: - case ZEND_INIT_ARRAY: + case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 757733e..24622a3 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -18361,6 +18361,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CONST_HAN case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, @@ -22908,6 +22909,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CV_HANDLE case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, @@ -25650,6 +25652,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_TMPVAR_HA case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, @@ -28177,6 +28180,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CONST_ case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, @@ -31675,6 +31679,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CV_HAN case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, @@ -34115,6 +34120,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_TMPVAR case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, @@ -39151,6 +39157,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CONST_HAND case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, @@ -45720,6 +45727,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CV_HANDLER case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type, @@ -49459,6 +49467,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_TMPVAR_HAN case ZEND_RETURN_BY_REF: case ZEND_ASSIGN_REF: case ZEND_INIT_ARRAY: + case ZEND_ADD_ARRAY_ELEMENT: case ZEND_YIELD: { zend_throw_exception_ex( zend_ce_type_error, prop_info->type,

« previous php.cvs (#95658) next »