@@ -426,9 +426,20 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **p
426
426
}
427
427
/* }}} */
428
428
429
+ static ZEND_COLD bool zend_null_arg_deprecated (const char * type ) {
430
+ zend_string * func_name = get_active_function_or_method_name ();
431
+ zend_error (E_DEPRECATED , "%s(): Passing null to argument of type %s is deprecated" ,
432
+ ZSTR_VAL (func_name ), type );
433
+ zend_string_release (func_name );
434
+ return !EG (exception );
435
+ }
436
+
429
437
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak (zval * arg , bool * dest ) /* {{{ */
430
438
{
431
439
if (EXPECTED (Z_TYPE_P (arg ) <= IS_STRING )) {
440
+ if (UNEXPECTED (Z_TYPE_P (arg ) == IS_NULL ) && !zend_null_arg_deprecated ("bool" )) {
441
+ return 0 ;
442
+ }
432
443
* dest = zend_is_true (arg );
433
444
} else {
434
445
return 0 ;
@@ -479,6 +490,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest)
479
490
return 0 ;
480
491
}
481
492
} else if (EXPECTED (Z_TYPE_P (arg ) < IS_TRUE )) {
493
+ if (UNEXPECTED (Z_TYPE_P (arg ) == IS_NULL ) && !zend_null_arg_deprecated ("int" )) {
494
+ return 0 ;
495
+ }
482
496
* dest = 0 ;
483
497
} else if (EXPECTED (Z_TYPE_P (arg ) == IS_TRUE )) {
484
498
* dest = 1 ;
@@ -517,6 +531,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest)
517
531
return 0 ;
518
532
}
519
533
} else if (EXPECTED (Z_TYPE_P (arg ) < IS_TRUE )) {
534
+ if (UNEXPECTED (Z_TYPE_P (arg ) == IS_NULL ) && !zend_null_arg_deprecated ("float" )) {
535
+ return 0 ;
536
+ }
520
537
* dest = 0.0 ;
521
538
} else if (EXPECTED (Z_TYPE_P (arg ) == IS_TRUE )) {
522
539
* dest = 1.0 ;
@@ -572,6 +589,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /
572
589
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak (zval * arg , zend_string * * dest ) /* {{{ */
573
590
{
574
591
if (EXPECTED (Z_TYPE_P (arg ) < IS_STRING )) {
592
+ if (UNEXPECTED (Z_TYPE_P (arg ) == IS_NULL ) && !zend_null_arg_deprecated ("string" )) {
593
+ return 0 ;
594
+ }
575
595
convert_to_string (arg );
576
596
* dest = Z_STR_P (arg );
577
597
} else if (UNEXPECTED (Z_TYPE_P (arg ) == IS_OBJECT )) {
0 commit comments