@@ -577,7 +577,7 @@ static inline void make_real_object(zval **object_ptr TSRMLS_DC)
577
577
}
578
578
}
579
579
580
- static inline char * zend_verify_arg_class_kind (const zend_arg_info * cur_arg_info , ulong fetch_type , const char * * class_name , zend_class_entry * * pce TSRMLS_DC )
580
+ ZEND_API char * zend_verify_arg_class_kind (const zend_arg_info * cur_arg_info , ulong fetch_type , const char * * class_name , zend_class_entry * * pce TSRMLS_DC )
581
581
{
582
582
* pce = zend_fetch_class (cur_arg_info -> class_name , cur_arg_info -> class_name_len , (fetch_type | ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD ) TSRMLS_CC );
583
583
@@ -589,7 +589,7 @@ static inline char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_inf
589
589
}
590
590
}
591
591
592
- static inline int zend_verify_arg_error (const zend_function * zf , zend_uint arg_num , const char * need_msg , const char * need_kind , const char * given_msg , char * given_kind TSRMLS_DC )
592
+ ZEND_API int zend_verify_arg_error (int error_type , const zend_function * zf , zend_uint arg_num , const char * need_msg , const char * need_kind , const char * given_msg , char * given_kind TSRMLS_DC )
593
593
{
594
594
zend_execute_data * ptr = EG (current_execute_data )-> prev_execute_data ;
595
595
char * fname = zf -> common .function_name ;
@@ -605,9 +605,9 @@ static inline int zend_verify_arg_error(const zend_function *zf, zend_uint arg_n
605
605
}
606
606
607
607
if (ptr && ptr -> op_array ) {
608
- zend_error (E_RECOVERABLE_ERROR , "Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d and defined" , arg_num , fclass , fsep , fname , need_msg , need_kind , given_msg , given_kind , ptr -> op_array -> filename , ptr -> opline -> lineno );
608
+ zend_error (error_type , "Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d and defined" , arg_num , fclass , fsep , fname , need_msg , need_kind , given_msg , given_kind , ptr -> op_array -> filename , ptr -> opline -> lineno );
609
609
} else {
610
- zend_error (E_RECOVERABLE_ERROR , "Argument %d passed to %s%s%s() must %s%s, %s%s given" , arg_num , fclass , fsep , fname , need_msg , need_kind , given_msg , given_kind );
610
+ zend_error (error_type , "Argument %d passed to %s%s%s() must %s%s, %s%s given" , arg_num , fclass , fsep , fname , need_msg , need_kind , given_msg , given_kind );
611
611
}
612
612
return 0 ;
613
613
}
@@ -630,44 +630,25 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
630
630
631
631
if (!arg ) {
632
632
need_msg = zend_verify_arg_class_kind (cur_arg_info , fetch_type , & class_name , & ce TSRMLS_CC );
633
- return zend_verify_arg_error (zf , arg_num , need_msg , class_name , "none" , "" TSRMLS_CC );
633
+ return zend_verify_arg_error (E_RECOVERABLE_ERROR , zf , arg_num , need_msg , class_name , "none" , "" TSRMLS_CC );
634
634
}
635
635
if (Z_TYPE_P (arg ) == IS_OBJECT ) {
636
636
need_msg = zend_verify_arg_class_kind (cur_arg_info , fetch_type , & class_name , & ce TSRMLS_CC );
637
637
if (!ce || !instanceof_function (Z_OBJCE_P (arg ), ce TSRMLS_CC )) {
638
- return zend_verify_arg_error (zf , arg_num , need_msg , class_name , "instance of " , Z_OBJCE_P (arg )-> name TSRMLS_CC );
638
+ return zend_verify_arg_error (E_RECOVERABLE_ERROR , zf , arg_num , need_msg , class_name , "instance of " , Z_OBJCE_P (arg )-> name TSRMLS_CC );
639
639
}
640
640
} else if (Z_TYPE_P (arg ) != IS_NULL || !cur_arg_info -> allow_null ) {
641
641
need_msg = zend_verify_arg_class_kind (cur_arg_info , fetch_type , & class_name , & ce TSRMLS_CC );
642
- return zend_verify_arg_error (zf , arg_num , need_msg , class_name , zend_zval_type_name (arg ), "" TSRMLS_CC );
642
+ return zend_verify_arg_error (E_RECOVERABLE_ERROR , zf , arg_num , need_msg , class_name , zend_zval_type_name (arg ), "" TSRMLS_CC );
643
643
}
644
- } else if (cur_arg_info -> type_hint ) {
644
+ } else if (cur_arg_info -> type_hint && cur_arg_info -> type_hint == IS_ARRAY ) {
645
645
if (!arg ) {
646
- return zend_verify_arg_error (zf , arg_num , "be of the type " , zend_get_type_by_const ( cur_arg_info -> type_hint ) , "none" , "" TSRMLS_CC );
646
+ return zend_verify_arg_error (E_RECOVERABLE_ERROR , zf , arg_num , "be of the type array " , "" , "none" , "" TSRMLS_CC );
647
647
}
648
648
649
- /* existing type already matches the hint or forced type */
650
- if (Z_TYPE_P (arg ) == cur_arg_info -> type_hint ) {
651
- return 1 ;
649
+ if (Z_TYPE_P (arg ) != IS_ARRAY && (Z_TYPE_P (arg ) != IS_NULL || !cur_arg_info -> allow_null )) {
650
+ return zend_verify_arg_error (E_RECOVERABLE_ERROR , zf , arg_num , "be of the type array" , "" , zend_zval_type_name (arg ), "" TSRMLS_CC );
652
651
}
653
-
654
- /* NULL type given, check if parameter is optional */
655
- if (Z_TYPE_P (arg ) == IS_NULL && cur_arg_info -> allow_null ) {
656
- return 1 ;
657
- }
658
-
659
- if (cur_arg_info -> type_hint == IS_SCALAR && Z_TYPE_P (arg ) != IS_NULL && Z_TYPE_P (arg ) != IS_ARRAY && Z_TYPE_P (arg ) != IS_OBJECT && Z_TYPE_P (arg ) != IS_RESOURCE ) {
660
- return 1 ;
661
- }
662
-
663
- if (cur_arg_info -> type_hint == IS_NUMERIC && (
664
- (Z_TYPE_P (arg ) == IS_LONG || Z_TYPE_P (arg ) == IS_DOUBLE )
665
- || (Z_TYPE_P (arg ) == IS_STRING && is_numeric_string (Z_STRVAL_P (arg ), Z_STRLEN_P (arg ), NULL , NULL , 0 ))
666
- )) {
667
- return 1 ;
668
- }
669
-
670
- return zend_verify_arg_error (zf , arg_num , "be of the type " , zend_get_type_by_const (cur_arg_info -> type_hint ), "" , zend_zval_type_name (arg ) TSRMLS_CC );
671
652
}
672
653
return 1 ;
673
654
}
0 commit comments