@@ -9259,53 +9259,41 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_
9259
9259
{
9260
9260
USE_OPLINE
9261
9261
zval *op1;
9262
- zend_long count;
9262
+ zend_long count = 1 ;
9263
9263
9264
9264
SAVE_OPLINE();
9265
9265
op1 = RT_CONSTANT(opline, opline->op1);
9266
- while (1) {
9267
- if (Z_TYPE_P(op1) == IS_ARRAY) {
9268
- count = zend_array_count(Z_ARRVAL_P(op1));
9269
- break;
9270
- } else if (Z_TYPE_P(op1) == IS_OBJECT) {
9271
- zend_object *zobj = Z_OBJ_P(op1);
9272
-
9273
- /* first, we check if the handler is defined */
9274
- if (zobj->handlers->count_elements) {
9275
- if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
9276
- break;
9277
- }
9278
- if (UNEXPECTED(EG(exception))) {
9279
- count = 0;
9280
- break;
9281
- }
9282
- }
9283
9266
9284
- /* if not and the object implements Countable we call its count() method */
9285
- if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
9286
- zval retval;
9267
+ if ((IS_CONST & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) {
9268
+ op1 = Z_REFVAL_P(op1);
9269
+ }
9287
9270
9288
- zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
9289
- count = zval_get_long(&retval);
9290
- zval_ptr_dtor(&retval);
9291
- break;
9292
- }
9271
+ if (Z_TYPE_P(op1) <= IS_NULL) {
9272
+ /* Intentionally not converted to an exception */
9273
+ zend_error(E_DEPRECATED, "%s(): Passing null is deprecated", opline->extended_value ? "sizeof" : "count");
9274
+ if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
9275
+ ZVAL_UNDEFINED_OP1();
9276
+ }
9277
+ count = 0;
9278
+ } else if (Z_TYPE_P(op1) == IS_ARRAY) {
9279
+ count = zend_array_count(Z_ARRVAL_P(op1));
9280
+ } else if (Z_TYPE_P(op1) == IS_OBJECT) {
9281
+ zend_object *zobj = Z_OBJ_P(op1);
9282
+ /* First, check if the handler is defined as it is faster */
9283
+ if (zobj->handlers->count_elements) {
9284
+ zobj->handlers->count_elements(zobj, &count);
9285
+ /* Otherwise check if the object implements Countable and call its count() method */
9286
+ } else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
9287
+ zval retval;
9293
9288
9294
- /* If There's no handler and it doesn't implement Countable then add a warning */
9295
- count = 1;
9296
- } else if ((IS_CONST & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) {
9297
- op1 = Z_REFVAL_P(op1);
9298
- continue;
9299
- } else if (Z_TYPE_P(op1) <= IS_NULL) {
9300
- if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
9301
- ZVAL_UNDEFINED_OP1();
9302
- }
9303
- count = 0;
9289
+ zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
9290
+ count = zval_get_long(&retval);
9291
+ zval_ptr_dtor(&retval);
9304
9292
} else {
9305
- count = 1 ;
9293
+ zend_type_error("Parameter must be an array or an object that implements Countable") ;
9306
9294
}
9307
- zend_error(E_WARNING, "%s(): Parameter must be an array or an object that implements Countable", opline->extended_value ? "sizeof" : "count");
9308
- break ;
9295
+ } else {
9296
+ zend_type_error("Parameter must be an array or an object that implements Countable") ;
9309
9297
}
9310
9298
9311
9299
ZVAL_LONG(EX_VAR(opline->result.var), count);
@@ -16338,53 +16326,41 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL
16338
16326
{
16339
16327
USE_OPLINE
16340
16328
zval *op1;
16341
- zend_long count;
16329
+ zend_long count = 1 ;
16342
16330
16343
16331
SAVE_OPLINE();
16344
16332
op1 = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC);
16345
- while (1) {
16346
- if (Z_TYPE_P(op1) == IS_ARRAY) {
16347
- count = zend_array_count(Z_ARRVAL_P(op1));
16348
- break;
16349
- } else if (Z_TYPE_P(op1) == IS_OBJECT) {
16350
- zend_object *zobj = Z_OBJ_P(op1);
16351
16333
16352
- /* first, we check if the handler is defined */
16353
- if (zobj->handlers->count_elements) {
16354
- if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
16355
- break;
16356
- }
16357
- if (UNEXPECTED(EG(exception))) {
16358
- count = 0;
16359
- break;
16360
- }
16361
- }
16362
-
16363
- /* if not and the object implements Countable we call its count() method */
16364
- if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
16365
- zval retval;
16334
+ if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) {
16335
+ op1 = Z_REFVAL_P(op1);
16336
+ }
16366
16337
16367
- zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
16368
- count = zval_get_long(&retval);
16369
- zval_ptr_dtor(&retval);
16370
- break;
16371
- }
16338
+ if (Z_TYPE_P(op1) <= IS_NULL) {
16339
+ /* Intentionally not converted to an exception */
16340
+ zend_error(E_DEPRECATED, "%s(): Passing null is deprecated", opline->extended_value ? "sizeof" : "count");
16341
+ if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
16342
+ ZVAL_UNDEFINED_OP1();
16343
+ }
16344
+ count = 0;
16345
+ } else if (Z_TYPE_P(op1) == IS_ARRAY) {
16346
+ count = zend_array_count(Z_ARRVAL_P(op1));
16347
+ } else if (Z_TYPE_P(op1) == IS_OBJECT) {
16348
+ zend_object *zobj = Z_OBJ_P(op1);
16349
+ /* First, check if the handler is defined as it is faster */
16350
+ if (zobj->handlers->count_elements) {
16351
+ zobj->handlers->count_elements(zobj, &count);
16352
+ /* Otherwise check if the object implements Countable and call its count() method */
16353
+ } else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
16354
+ zval retval;
16372
16355
16373
- /* If There's no handler and it doesn't implement Countable then add a warning */
16374
- count = 1;
16375
- } else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) {
16376
- op1 = Z_REFVAL_P(op1);
16377
- continue;
16378
- } else if (Z_TYPE_P(op1) <= IS_NULL) {
16379
- if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
16380
- ZVAL_UNDEFINED_OP1();
16381
- }
16382
- count = 0;
16356
+ zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
16357
+ count = zval_get_long(&retval);
16358
+ zval_ptr_dtor(&retval);
16383
16359
} else {
16384
- count = 1 ;
16360
+ zend_type_error("Parameter must be an array or an object that implements Countable") ;
16385
16361
}
16386
- zend_error(E_WARNING, "%s(): Parameter must be an array or an object that implements Countable", opline->extended_value ? "sizeof" : "count");
16387
- break ;
16362
+ } else {
16363
+ zend_type_error("Parameter must be an array or an object that implements Countable") ;
16388
16364
}
16389
16365
16390
16366
ZVAL_LONG(EX_VAR(opline->result.var), count);
@@ -45185,53 +45161,41 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z
45185
45161
{
45186
45162
USE_OPLINE
45187
45163
zval *op1;
45188
- zend_long count;
45164
+ zend_long count = 1 ;
45189
45165
45190
45166
SAVE_OPLINE();
45191
45167
op1 = EX_VAR(opline->op1.var);
45192
- while (1) {
45193
- if (Z_TYPE_P(op1) == IS_ARRAY) {
45194
- count = zend_array_count(Z_ARRVAL_P(op1));
45195
- break;
45196
- } else if (Z_TYPE_P(op1) == IS_OBJECT) {
45197
- zend_object *zobj = Z_OBJ_P(op1);
45198
45168
45199
- /* first, we check if the handler is defined */
45200
- if (zobj->handlers->count_elements) {
45201
- if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
45202
- break;
45203
- }
45204
- if (UNEXPECTED(EG(exception))) {
45205
- count = 0;
45206
- break;
45207
- }
45208
- }
45209
-
45210
- /* if not and the object implements Countable we call its count() method */
45211
- if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
45212
- zval retval;
45169
+ if ((IS_CV & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) {
45170
+ op1 = Z_REFVAL_P(op1);
45171
+ }
45213
45172
45214
- zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
45215
- count = zval_get_long(&retval);
45216
- zval_ptr_dtor(&retval);
45217
- break;
45218
- }
45173
+ if (Z_TYPE_P(op1) <= IS_NULL) {
45174
+ /* Intentionally not converted to an exception */
45175
+ zend_error(E_DEPRECATED, "%s(): Passing null is deprecated", opline->extended_value ? "sizeof" : "count");
45176
+ if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
45177
+ ZVAL_UNDEFINED_OP1();
45178
+ }
45179
+ count = 0;
45180
+ } else if (Z_TYPE_P(op1) == IS_ARRAY) {
45181
+ count = zend_array_count(Z_ARRVAL_P(op1));
45182
+ } else if (Z_TYPE_P(op1) == IS_OBJECT) {
45183
+ zend_object *zobj = Z_OBJ_P(op1);
45184
+ /* First, check if the handler is defined as it is faster */
45185
+ if (zobj->handlers->count_elements) {
45186
+ zobj->handlers->count_elements(zobj, &count);
45187
+ /* Otherwise check if the object implements Countable and call its count() method */
45188
+ } else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
45189
+ zval retval;
45219
45190
45220
- /* If There's no handler and it doesn't implement Countable then add a warning */
45221
- count = 1;
45222
- } else if ((IS_CV & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) {
45223
- op1 = Z_REFVAL_P(op1);
45224
- continue;
45225
- } else if (Z_TYPE_P(op1) <= IS_NULL) {
45226
- if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
45227
- ZVAL_UNDEFINED_OP1();
45228
- }
45229
- count = 0;
45191
+ zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
45192
+ count = zval_get_long(&retval);
45193
+ zval_ptr_dtor(&retval);
45230
45194
} else {
45231
- count = 1 ;
45195
+ zend_type_error("Parameter must be an array or an object that implements Countable") ;
45232
45196
}
45233
- zend_error(E_WARNING, "%s(): Parameter must be an array or an object that implements Countable", opline->extended_value ? "sizeof" : "count");
45234
- break ;
45197
+ } else {
45198
+ zend_type_error("Parameter must be an array or an object that implements Countable") ;
45235
45199
}
45236
45200
45237
45201
ZVAL_LONG(EX_VAR(opline->result.var), count);
0 commit comments