@@ -523,71 +523,70 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32
523
523
return !EG (exception );
524
524
}
525
525
526
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak (const zval * arg , bool * dest , uint32_t arg_num ) /* {{{ */
526
+ ZEND_API zend_opt_bool ZEND_FASTCALL zend_parse_arg_bool_weak (const zval * arg , uint32_t arg_num ) /* {{{ */
527
527
{
528
528
if (EXPECTED (Z_TYPE_P (arg ) <= IS_STRING )) {
529
529
if (UNEXPECTED (Z_TYPE_P (arg ) == IS_NULL ) && !zend_null_arg_deprecated ("bool" , arg_num )) {
530
- return 0 ;
530
+ return ( zend_opt_bool ){false, false} ;
531
531
}
532
- * dest = zend_is_true (arg );
532
+ return ( zend_opt_bool ){ zend_is_true (arg ), true} ;
533
533
} else {
534
- return 0 ;
534
+ return ( zend_opt_bool ){false, false} ;
535
535
}
536
- return 1 ;
537
536
}
538
537
/* }}} */
539
538
540
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow (const zval * arg , bool * dest , uint32_t arg_num ) /* {{{ */
539
+ ZEND_API zend_opt_bool ZEND_FASTCALL zend_parse_arg_bool_slow (const zval * arg , uint32_t arg_num ) /* {{{ */
541
540
{
542
541
if (UNEXPECTED (ZEND_ARG_USES_STRICT_TYPES ())) {
543
- return 0 ;
542
+ return ( zend_opt_bool ){false, false} ;
544
543
}
545
- return zend_parse_arg_bool_weak (arg , dest , arg_num );
544
+ return zend_parse_arg_bool_weak (arg , arg_num );
546
545
}
547
546
/* }}} */
548
547
549
- ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_bool_slow (const zval * arg , bool * dest , uint32_t arg_num )
548
+ ZEND_API zend_opt_bool ZEND_FASTCALL zend_flf_parse_arg_bool_slow (const zval * arg , uint32_t arg_num )
550
549
{
551
550
if (UNEXPECTED (ZEND_FLF_ARG_USES_STRICT_TYPES ())) {
552
- return 0 ;
551
+ return ( zend_opt_bool ){false, false} ;
553
552
}
554
- return zend_parse_arg_bool_weak (arg , dest , arg_num );
553
+ return zend_parse_arg_bool_weak (arg , arg_num );
555
554
}
556
555
557
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak (const zval * arg , zend_long * dest , uint32_t arg_num ) /* {{{ */
556
+ ZEND_API zend_opt_long ZEND_FASTCALL zend_parse_arg_long_weak (const zval * arg , uint32_t arg_num ) /* {{{ */
558
557
{
559
558
if (EXPECTED (Z_TYPE_P (arg ) == IS_DOUBLE )) {
560
559
if (UNEXPECTED (zend_isnan (Z_DVAL_P (arg )))) {
561
- return 0 ;
560
+ goto fail ;
562
561
}
563
562
if (UNEXPECTED (!ZEND_DOUBLE_FITS_LONG (Z_DVAL_P (arg )))) {
564
- return 0 ;
563
+ goto fail ;
565
564
} else {
566
565
zend_long lval = zend_dval_to_lval (Z_DVAL_P (arg ));
567
566
if (UNEXPECTED (!zend_is_long_compatible (Z_DVAL_P (arg ), lval ))) {
568
567
/* Check arg_num is not (uint32_t)-1, as otherwise its called by
569
568
* zend_verify_weak_scalar_type_hint_no_sideeffect() */
570
569
if (arg_num != (uint32_t )-1 ) {
571
570
zend_incompatible_double_to_long_error (Z_DVAL_P (arg ));
572
- }
573
- if ( UNEXPECTED ( EG ( exception ))) {
574
- return 0 ;
571
+ if ( UNEXPECTED ( EG ( exception ))) {
572
+ goto fail ;
573
+ }
575
574
}
576
575
}
577
- * dest = lval ;
576
+ return ( zend_opt_long ){ lval , true} ;
578
577
}
579
578
} else if (EXPECTED (Z_TYPE_P (arg ) == IS_STRING )) {
580
579
double d ;
581
580
uint8_t type ;
581
+ zend_long lval ;
582
582
583
- if (UNEXPECTED ((type = is_numeric_str_function (Z_STR_P (arg ), dest , & d )) != IS_LONG )) {
583
+ if (UNEXPECTED ((type = is_numeric_str_function (Z_STR_P (arg ), & lval , & d )) != IS_LONG )) {
584
584
if (EXPECTED (type != 0 )) {
585
- zend_long lval ;
586
585
if (UNEXPECTED (zend_isnan (d ))) {
587
- return 0 ;
586
+ goto fail ;
588
587
}
589
588
if (UNEXPECTED (!ZEND_DOUBLE_FITS_LONG (d ))) {
590
- return 0 ;
589
+ goto fail ;
591
590
}
592
591
593
592
lval = zend_dval_to_lval (d );
@@ -597,95 +596,101 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, zend_long
597
596
* zend_verify_weak_scalar_type_hint_no_sideeffect() */
598
597
if (arg_num != (uint32_t )-1 ) {
599
598
zend_incompatible_string_to_long_error (Z_STR_P (arg ));
600
- }
601
- if ( UNEXPECTED ( EG ( exception ))) {
602
- return 0 ;
599
+ if ( UNEXPECTED ( EG ( exception ))) {
600
+ goto fail ;
601
+ }
603
602
}
604
603
}
605
- * dest = lval ;
606
604
} else {
607
- return 0 ;
605
+ goto fail ;
608
606
}
609
607
}
610
- if (UNEXPECTED (EG (exception ))) {
611
- return 0 ;
612
- }
608
+ return (zend_opt_long ){lval , true};
613
609
} else if (EXPECTED (Z_TYPE_P (arg ) < IS_TRUE )) {
614
610
if (UNEXPECTED (Z_TYPE_P (arg ) == IS_NULL ) && !zend_null_arg_deprecated ("int" , arg_num )) {
615
- return 0 ;
611
+ goto fail ;
616
612
}
617
- * dest = 0 ;
613
+ return ( zend_opt_long ){ 0 , true} ;
618
614
} else if (EXPECTED (Z_TYPE_P (arg ) == IS_TRUE )) {
619
- * dest = 1 ;
620
- } else {
621
- return 0 ;
615
+ return (zend_opt_long ){1 , true};
622
616
}
623
- return 1 ;
617
+
618
+ fail :;
619
+ zend_opt_long result ;
620
+ result .has_value = false;
621
+ return result ;
624
622
}
625
623
/* }}} */
626
624
627
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow (const zval * arg , zend_long * dest , uint32_t arg_num ) /* {{{ */
625
+ ZEND_API zend_opt_long ZEND_FASTCALL zend_parse_arg_long_slow (const zval * arg , uint32_t arg_num ) /* {{{ */
628
626
{
629
627
if (UNEXPECTED (ZEND_ARG_USES_STRICT_TYPES ())) {
630
- return 0 ;
628
+ zend_opt_long result ;
629
+ result .has_value = false;
630
+ return result ;
631
631
}
632
- return zend_parse_arg_long_weak (arg , dest , arg_num );
632
+ return zend_parse_arg_long_weak (arg , arg_num );
633
633
}
634
634
/* }}} */
635
635
636
- ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_long_slow (const zval * arg , zend_long * dest , uint32_t arg_num )
636
+ ZEND_API zend_opt_long ZEND_FASTCALL zend_flf_parse_arg_long_slow (const zval * arg , uint32_t arg_num )
637
637
{
638
638
if (UNEXPECTED (ZEND_FLF_ARG_USES_STRICT_TYPES ())) {
639
- return 0 ;
639
+ zend_opt_long result ;
640
+ result .has_value = false;
641
+ return result ;
640
642
}
641
- return zend_parse_arg_long_weak (arg , dest , arg_num );
643
+ return zend_parse_arg_long_weak (arg , arg_num );
642
644
}
643
645
644
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak (const zval * arg , double * dest , uint32_t arg_num ) /* {{{ */
646
+ ZEND_API zend_opt_double ZEND_FASTCALL zend_parse_arg_double_weak (const zval * arg , uint32_t arg_num ) /* {{{ */
645
647
{
646
648
if (EXPECTED (Z_TYPE_P (arg ) == IS_LONG )) {
647
- * dest = ( double )Z_LVAL_P (arg );
649
+ return ( zend_opt_double ){( double )Z_LVAL_P (arg ), true} ;
648
650
} else if (EXPECTED (Z_TYPE_P (arg ) == IS_STRING )) {
649
651
zend_long l ;
650
652
uint8_t type ;
653
+ double d ;
651
654
652
- if (UNEXPECTED ((type = is_numeric_str_function (Z_STR_P (arg ), & l , dest )) != IS_DOUBLE )) {
655
+ if (UNEXPECTED ((type = is_numeric_str_function (Z_STR_P (arg ), & l , & d )) != IS_DOUBLE )) {
653
656
if (EXPECTED (type != 0 )) {
654
- * dest = (double )(l );
655
- } else {
656
- return 0 ;
657
+ return (zend_opt_double ){(double )l , true};
657
658
}
658
- }
659
- if ( UNEXPECTED ( EG ( exception ))) {
660
- return 0 ;
659
+ goto fail ;
660
+ } else {
661
+ return ( zend_opt_double ){ d , true} ;
661
662
}
662
663
} else if (EXPECTED (Z_TYPE_P (arg ) < IS_TRUE )) {
663
664
if (UNEXPECTED (Z_TYPE_P (arg ) == IS_NULL ) && !zend_null_arg_deprecated ("float" , arg_num )) {
664
- return 0 ;
665
+ goto fail ;
665
666
}
666
- * dest = 0.0 ;
667
+ return ( zend_opt_double ){ 0.0 , true} ;
667
668
} else if (EXPECTED (Z_TYPE_P (arg ) == IS_TRUE )) {
668
- * dest = 1.0 ;
669
- } else {
670
- return 0 ;
669
+ return (zend_opt_double ){1.0 , true};
671
670
}
672
- return 1 ;
671
+
672
+ fail :;
673
+ zend_opt_double result ;
674
+ result .has_value = false;
675
+ return result ;
673
676
}
674
677
/* }}} */
675
678
676
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow (const zval * arg , double * dest , uint32_t arg_num ) /* {{{ */
679
+ ZEND_API zend_opt_double ZEND_FASTCALL zend_parse_arg_double_slow (const zval * arg , uint32_t arg_num ) /* {{{ */
677
680
{
678
681
if (EXPECTED (Z_TYPE_P (arg ) == IS_LONG )) {
679
682
/* SSTH Exception: IS_LONG may be accepted instead as IS_DOUBLE */
680
- * dest = ( double )Z_LVAL_P (arg );
683
+ return ( zend_opt_double ){( double )Z_LVAL_P (arg ), true} ;
681
684
} else if (UNEXPECTED (ZEND_ARG_USES_STRICT_TYPES ())) {
682
- return 0 ;
685
+ zend_opt_double result ;
686
+ result .has_value = false;
687
+ return result ;
683
688
}
684
- return zend_parse_arg_double_weak (arg , dest , arg_num );
689
+ return zend_parse_arg_double_weak (arg , arg_num );
685
690
}
686
691
/* }}} */
687
692
688
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow (zval * arg , zval * * dest , uint32_t arg_num ) /* {{{ */
693
+ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow (zval * arg , uint32_t arg_num ) /* {{{ */
689
694
{
690
695
if (UNEXPECTED (ZEND_ARG_USES_STRICT_TYPES ())) {
691
696
return 0 ;
@@ -713,13 +718,12 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest, u
713
718
} else {
714
719
return 0 ;
715
720
}
716
- * dest = arg ;
717
721
return 1 ;
718
722
}
719
723
/* }}} */
720
724
721
725
722
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow (zval * arg , zval * * dest , uint32_t arg_num ) /* {{{ */
726
+ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow (zval * arg , uint32_t arg_num ) /* {{{ */
723
727
{
724
728
if (UNEXPECTED (ZEND_ARG_USES_STRICT_TYPES ())) {
725
729
return false;
@@ -737,72 +741,74 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow(zval *arg, zval **
737
741
if (zobj -> handlers -> cast_object (zobj , & obj , IS_STRING ) == SUCCESS ) {
738
742
OBJ_RELEASE (zobj );
739
743
ZVAL_COPY_VALUE (arg , & obj );
740
- * dest = arg ;
741
744
return true;
742
745
}
743
746
return false;
744
747
} else {
745
748
return false;
746
749
}
747
- * dest = arg ;
748
750
return true;
749
751
}
750
752
751
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak (zval * arg , zend_string * * dest , uint32_t arg_num ) /* {{{ */
753
+ ZEND_API zend_string * ZEND_FASTCALL zend_parse_arg_str_weak (zval * arg , uint32_t arg_num ) /* {{{ */
752
754
{
753
755
if (EXPECTED (Z_TYPE_P (arg ) < IS_STRING )) {
754
756
if (UNEXPECTED (Z_TYPE_P (arg ) == IS_NULL ) && !zend_null_arg_deprecated ("string" , arg_num )) {
755
- return 0 ;
757
+ return NULL ;
756
758
}
757
759
convert_to_string (arg );
758
- * dest = Z_STR_P (arg );
760
+ return Z_STR_P (arg );
759
761
} else if (UNEXPECTED (Z_TYPE_P (arg ) == IS_OBJECT )) {
760
762
zend_object * zobj = Z_OBJ_P (arg );
761
763
zval obj ;
762
764
if (zobj -> handlers -> cast_object (zobj , & obj , IS_STRING ) == SUCCESS ) {
763
765
OBJ_RELEASE (zobj );
764
766
ZVAL_COPY_VALUE (arg , & obj );
765
- * dest = Z_STR_P (arg );
766
- return 1 ;
767
+ return Z_STR_P (arg );
767
768
}
768
- return 0 ;
769
+ return NULL ;
769
770
} else {
770
- return 0 ;
771
+ return NULL ;
771
772
}
772
- return 1 ;
773
773
}
774
774
/* }}} */
775
775
776
- ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow (zval * arg , zend_string * * dest , uint32_t arg_num ) /* {{{ */
776
+ ZEND_API zend_string * ZEND_FASTCALL zend_parse_arg_str_slow (zval * arg , uint32_t arg_num ) /* {{{ */
777
777
{
778
778
if (UNEXPECTED (ZEND_ARG_USES_STRICT_TYPES ())) {
779
- return 0 ;
779
+ return NULL ;
780
780
}
781
- return zend_parse_arg_str_weak (arg , dest , arg_num );
781
+ return zend_parse_arg_str_weak (arg , arg_num );
782
782
}
783
783
/* }}} */
784
784
785
- ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_str_slow (zval * arg , zend_string * * dest , uint32_t arg_num )
785
+ ZEND_API zend_string * ZEND_FASTCALL zend_flf_parse_arg_str_slow (zval * arg , uint32_t arg_num )
786
786
{
787
787
if (UNEXPECTED (ZEND_FLF_ARG_USES_STRICT_TYPES ())) {
788
788
return 0 ;
789
789
}
790
- return zend_parse_arg_str_weak (arg , dest , arg_num );
790
+ return zend_parse_arg_str_weak (arg , arg_num );
791
791
}
792
792
793
793
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow (zval * arg , zend_string * * dest_str , zend_long * dest_long , uint32_t arg_num ) /* {{{ */
794
794
{
795
795
if (UNEXPECTED (ZEND_ARG_USES_STRICT_TYPES ())) {
796
796
return 0 ;
797
797
}
798
- if (zend_parse_arg_long_weak (arg , dest_long , arg_num )) {
798
+ zend_opt_long result = zend_parse_arg_long_weak (arg , arg_num );
799
+ if (result .has_value ) {
800
+ * dest_long = result .value ;
799
801
* dest_str = NULL ;
800
802
return 1 ;
801
- } else if (zend_parse_arg_str_weak (arg , dest_str , arg_num )) {
802
- * dest_long = 0 ;
803
- return 1 ;
804
803
} else {
805
- return 0 ;
804
+ zend_string * str = zend_parse_arg_str_weak (arg , arg_num );
805
+ if (str ) {
806
+ * dest_long = 0 ;
807
+ * dest_str = str ;
808
+ return 1 ;
809
+ } else {
810
+ return 0 ;
811
+ }
806
812
}
807
813
}
808
814
/* }}} */
0 commit comments