Skip to content

Commit 2cafaab

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 31c6c86 + d266ba4 commit 2cafaab

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

Zend/zend_vm_def.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8600,6 +8600,10 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
86008600
if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
86018601
break;
86028602
}
8603+
if (UNEXPECTED(EG(exception))) {
8604+
count = 0;
8605+
break;
8606+
}
86038607
}
86048608

86058609
/* if not and the object implements Countable we call its count() method */

Zend/zend_vm_execute.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9560,6 +9560,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_
95609560
if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
95619561
break;
95629562
}
9563+
if (UNEXPECTED(EG(exception))) {
9564+
count = 0;
9565+
break;
9566+
}
95639567
}
95649568

95659569
/* if not and the object implements Countable we call its count() method */
@@ -16689,6 +16693,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL
1668916693
if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
1669016694
break;
1669116695
}
16696+
if (UNEXPECTED(EG(exception))) {
16697+
count = 0;
16698+
break;
16699+
}
1669216700
}
1669316701

1669416702
/* if not and the object implements Countable we call its count() method */
@@ -47315,6 +47323,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z
4731547323
if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
4731647324
break;
4731747325
}
47326+
if (UNEXPECTED(EG(exception))) {
47327+
count = 0;
47328+
break;
47329+
}
4731847330
}
4731947331

4732047332
/* if not and the object implements Countable we call its count() method */

ext/ffi/tests/008.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ foreach ($a as $key => $val) {
1616

1717
$a = FFI::new("struct {int x,y;}");
1818
try {
19-
var_dump(@count($a));
19+
var_dump(count($a));
2020
} catch (Throwable $e) {
2121
echo get_class($e) . ": " . $e->getMessage()."\n";
2222
}

ext/standard/array.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,9 @@ PHP_FUNCTION(count)
792792
if (SUCCESS == Z_OBJ_HT(*array)->count_elements(Z_OBJ_P(array), &Z_LVAL_P(return_value))) {
793793
return;
794794
}
795+
if (EG(exception)) {
796+
return;
797+
}
795798
}
796799
/* if not and the object implements Countable we call its count() method */
797800
if (instanceof_function(Z_OBJCE_P(array), zend_ce_countable)) {

0 commit comments

Comments
 (0)