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