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