@@ -1623,33 +1623,48 @@ static zend_property_info *zend_get_prop_not_accepting_double(zend_reference *re
1623
1623
return NULL ;
1624
1624
}
1625
1625
1626
- static ZEND_COLD void zend_throw_incdec_ref_error (zend_reference * ref , zend_bool inc )
1626
+ static ZEND_COLD zend_long zend_throw_incdec_ref_error (zend_reference * ref OPLINE_DC )
1627
1627
{
1628
1628
zend_property_info * error_prop = zend_get_prop_not_accepting_double (ref );
1629
1629
/* Currently there should be no way for a typed reference to accept both int and double.
1630
1630
* Generalize this and the related property code once this becomes possible. */
1631
1631
ZEND_ASSERT (error_prop );
1632
- zend_type_error (
1633
- "Cannot %s a reference held by property %s::$%s of type %sint past its %simal value" ,
1634
- inc ? "increment" : "decrement" ,
1635
- ZSTR_VAL (error_prop -> ce -> name ),
1636
- zend_get_unmangled_property_name (error_prop -> name ),
1637
- ZEND_TYPE_ALLOW_NULL (error_prop -> type ) ? "?" : "" ,
1638
- inc ? "max" : "min" );
1632
+ if (ZEND_IS_INCREMENT (opline -> opcode )) {
1633
+ zend_type_error (
1634
+ "Cannot increment a reference held by property %s::$%s of type %sint past its maximal value" ,
1635
+ ZSTR_VAL (error_prop -> ce -> name ),
1636
+ zend_get_unmangled_property_name (error_prop -> name ),
1637
+ ZEND_TYPE_ALLOW_NULL (error_prop -> type ) ? "?" : "" );
1638
+ return ZEND_LONG_MAX ;
1639
+ } else {
1640
+ zend_type_error (
1641
+ "Cannot decrement a reference held by property %s::$%s of type %sint past its minimal value" ,
1642
+ ZSTR_VAL (error_prop -> ce -> name ),
1643
+ zend_get_unmangled_property_name (error_prop -> name ),
1644
+ ZEND_TYPE_ALLOW_NULL (error_prop -> type ) ? "?" : "" );
1645
+ return ZEND_LONG_MIN ;
1646
+ }
1639
1647
}
1640
1648
1641
- static ZEND_COLD void zend_throw_incdec_prop_error (zend_property_info * prop , zend_bool inc ) {
1649
+ static ZEND_COLD zend_long zend_throw_incdec_prop_error (zend_property_info * prop OPLINE_DC ) {
1642
1650
const char * prop_type1 , * prop_type2 ;
1643
1651
zend_format_type (prop -> type , & prop_type1 , & prop_type2 );
1644
- zend_type_error ("Cannot %s property %s::$%s of type %s%s past its %simal value" ,
1645
- inc ? "increment" : "decrement" ,
1646
- ZSTR_VAL (prop -> ce -> name ),
1647
- zend_get_unmangled_property_name (prop -> name ),
1648
- prop_type1 , prop_type2 ,
1649
- inc ? "max" : "min" );
1652
+ if (ZEND_IS_INCREMENT (opline -> opcode )) {
1653
+ zend_type_error ("Cannot increment property %s::$%s of type %s%s past its maximal value" ,
1654
+ ZSTR_VAL (prop -> ce -> name ),
1655
+ zend_get_unmangled_property_name (prop -> name ),
1656
+ prop_type1 , prop_type2 );
1657
+ return ZEND_LONG_MAX ;
1658
+ } else {
1659
+ zend_type_error ("Cannot decrement property %s::$%s of type %s%s past its minimal value" ,
1660
+ ZSTR_VAL (prop -> ce -> name ),
1661
+ zend_get_unmangled_property_name (prop -> name ),
1662
+ prop_type1 , prop_type2 );
1663
+ return ZEND_LONG_MIN ;
1664
+ }
1650
1665
}
1651
1666
1652
- static void zend_incdec_typed_ref (zend_reference * ref , zval * copy , int inc EXECUTE_DATA_DC )
1667
+ static void zend_incdec_typed_ref (zend_reference * ref , zval * copy OPLINE_DC EXECUTE_DATA_DC )
1653
1668
{
1654
1669
zval tmp ;
1655
1670
zval * var_ptr = & ref -> val ;
@@ -1660,15 +1675,15 @@ static void zend_incdec_typed_ref(zend_reference *ref, zval *copy, int inc EXECU
1660
1675
1661
1676
ZVAL_COPY (copy , var_ptr );
1662
1677
1663
- if (inc ) {
1678
+ if (ZEND_IS_INCREMENT ( opline -> opcode ) ) {
1664
1679
increment_function (var_ptr );
1665
1680
} else {
1666
1681
decrement_function (var_ptr );
1667
1682
}
1668
1683
1669
1684
if (UNEXPECTED (Z_TYPE_P (var_ptr ) == IS_DOUBLE ) && Z_TYPE_P (copy ) == IS_LONG ) {
1670
- zend_throw_incdec_ref_error (ref , inc );
1671
- ZVAL_COPY_VALUE (var_ptr , copy );
1685
+ zend_long val = zend_throw_incdec_ref_error (ref OPLINE_CC );
1686
+ ZVAL_LONG (var_ptr , val );
1672
1687
} else if (UNEXPECTED (!zend_verify_ref_assignable_zval (ref , var_ptr , EX_USES_STRICT_TYPES ()))) {
1673
1688
zval_ptr_dtor (var_ptr );
1674
1689
ZVAL_COPY_VALUE (var_ptr , copy );
@@ -1678,7 +1693,7 @@ static void zend_incdec_typed_ref(zend_reference *ref, zval *copy, int inc EXECU
1678
1693
}
1679
1694
}
1680
1695
1681
- static void zend_incdec_typed_prop (zend_property_info * prop_info , zval * var_ptr , zval * copy , int inc EXECUTE_DATA_DC )
1696
+ static void zend_incdec_typed_prop (zend_property_info * prop_info , zval * var_ptr , zval * copy OPLINE_DC EXECUTE_DATA_DC )
1682
1697
{
1683
1698
zval tmp ;
1684
1699
@@ -1688,15 +1703,15 @@ static void zend_incdec_typed_prop(zend_property_info *prop_info, zval *var_ptr,
1688
1703
1689
1704
ZVAL_COPY (copy , var_ptr );
1690
1705
1691
- if (inc ) {
1706
+ if (ZEND_IS_INCREMENT ( opline -> opcode ) ) {
1692
1707
increment_function (var_ptr );
1693
1708
} else {
1694
1709
decrement_function (var_ptr );
1695
1710
}
1696
1711
1697
1712
if (UNEXPECTED (Z_TYPE_P (var_ptr ) == IS_DOUBLE ) && Z_TYPE_P (copy ) == IS_LONG ) {
1698
- zend_throw_incdec_prop_error (prop_info , inc );
1699
- ZVAL_COPY_VALUE (var_ptr , copy );
1713
+ zend_long val = zend_throw_incdec_prop_error (prop_info OPLINE_CC );
1714
+ ZVAL_LONG (var_ptr , val );
1700
1715
} else if (UNEXPECTED (!zend_verify_property_type (prop_info , var_ptr , EX_USES_STRICT_TYPES ()))) {
1701
1716
zval_ptr_dtor (var_ptr );
1702
1717
ZVAL_COPY_VALUE (var_ptr , copy );
@@ -1706,36 +1721,32 @@ static void zend_incdec_typed_prop(zend_property_info *prop_info, zval *var_ptr,
1706
1721
}
1707
1722
}
1708
1723
1709
- static void zend_pre_incdec_property_zval (zval * prop , zend_property_info * prop_info , int inc OPLINE_DC EXECUTE_DATA_DC )
1724
+ static void zend_pre_incdec_property_zval (zval * prop , zend_property_info * prop_info OPLINE_DC EXECUTE_DATA_DC )
1710
1725
{
1711
1726
if (EXPECTED (Z_TYPE_P (prop ) == IS_LONG )) {
1712
- if (inc ) {
1727
+ if (ZEND_IS_INCREMENT ( opline -> opcode ) ) {
1713
1728
fast_long_increment_function (prop );
1714
1729
} else {
1715
1730
fast_long_decrement_function (prop );
1716
1731
}
1717
1732
if (UNEXPECTED (Z_TYPE_P (prop ) != IS_LONG ) && UNEXPECTED (prop_info )) {
1718
- zend_throw_incdec_prop_error (prop_info , inc );
1719
- if (inc ) {
1720
- ZVAL_LONG (prop , ZEND_LONG_MAX );
1721
- } else {
1722
- ZVAL_LONG (prop , ZEND_LONG_MIN );
1723
- }
1733
+ zend_long val = zend_throw_incdec_prop_error (prop_info OPLINE_CC );
1734
+ ZVAL_LONG (prop , val );
1724
1735
}
1725
1736
} else {
1726
1737
do {
1727
1738
if (Z_ISREF_P (prop )) {
1728
1739
zend_reference * ref = Z_REF_P (prop );
1729
1740
if (UNEXPECTED (ZEND_REF_HAS_TYPE_SOURCES (ref ))) {
1730
- zend_incdec_typed_ref (ref , NULL , inc EXECUTE_DATA_CC );
1741
+ zend_incdec_typed_ref (ref , NULL OPLINE_CC EXECUTE_DATA_CC );
1731
1742
break ;
1732
1743
}
1733
1744
prop = Z_REFVAL_P (prop );
1734
1745
}
1735
1746
1736
1747
if (UNEXPECTED (prop_info )) {
1737
- zend_incdec_typed_prop (prop_info , prop , NULL , inc EXECUTE_DATA_CC );
1738
- } else if (inc ) {
1748
+ zend_incdec_typed_prop (prop_info , prop , NULL OPLINE_CC EXECUTE_DATA_CC );
1749
+ } else if (ZEND_IS_INCREMENT ( opline -> opcode ) ) {
1739
1750
increment_function (prop );
1740
1751
} else {
1741
1752
decrement_function (prop );
@@ -1747,38 +1758,34 @@ static void zend_pre_incdec_property_zval(zval *prop, zend_property_info *prop_i
1747
1758
}
1748
1759
}
1749
1760
1750
- static void zend_post_incdec_property_zval (zval * prop , zend_property_info * prop_info , int inc OPLINE_DC EXECUTE_DATA_DC )
1761
+ static void zend_post_incdec_property_zval (zval * prop , zend_property_info * prop_info OPLINE_DC EXECUTE_DATA_DC )
1751
1762
{
1752
1763
if (EXPECTED (Z_TYPE_P (prop ) == IS_LONG )) {
1753
1764
ZVAL_LONG (EX_VAR (opline -> result .var ), Z_LVAL_P (prop ));
1754
- if (inc ) {
1765
+ if (ZEND_IS_INCREMENT ( opline -> opcode ) ) {
1755
1766
fast_long_increment_function (prop );
1756
1767
} else {
1757
1768
fast_long_decrement_function (prop );
1758
1769
}
1759
1770
if (UNEXPECTED (Z_TYPE_P (prop ) != IS_LONG ) && UNEXPECTED (prop_info )) {
1760
- zend_throw_incdec_prop_error (prop_info , inc );
1761
- if (inc ) {
1762
- ZVAL_LONG (prop , ZEND_LONG_MAX );
1763
- } else {
1764
- ZVAL_LONG (prop , ZEND_LONG_MIN );
1765
- }
1771
+ zend_long val = zend_throw_incdec_prop_error (prop_info OPLINE_CC );
1772
+ ZVAL_LONG (prop , val );
1766
1773
}
1767
1774
} else {
1768
1775
if (Z_ISREF_P (prop )) {
1769
1776
zend_reference * ref = Z_REF_P (prop );
1770
1777
if (ZEND_REF_HAS_TYPE_SOURCES (ref )) {
1771
- zend_incdec_typed_ref (ref , EX_VAR (opline -> result .var ), inc EXECUTE_DATA_CC );
1778
+ zend_incdec_typed_ref (ref , EX_VAR (opline -> result .var ) OPLINE_CC EXECUTE_DATA_CC );
1772
1779
return ;
1773
1780
}
1774
1781
prop = Z_REFVAL_P (prop );
1775
1782
}
1776
1783
1777
1784
if (UNEXPECTED (prop_info )) {
1778
- zend_incdec_typed_prop (prop_info , prop , EX_VAR (opline -> result .var ), inc EXECUTE_DATA_CC );
1785
+ zend_incdec_typed_prop (prop_info , prop , EX_VAR (opline -> result .var ) OPLINE_CC EXECUTE_DATA_CC );
1779
1786
} else {
1780
1787
ZVAL_COPY (EX_VAR (opline -> result .var ), prop );
1781
- if (inc ) {
1788
+ if (ZEND_IS_INCREMENT ( opline -> opcode ) ) {
1782
1789
increment_function (prop );
1783
1790
} else {
1784
1791
decrement_function (prop );
@@ -1787,7 +1794,7 @@ static void zend_post_incdec_property_zval(zval *prop, zend_property_info *prop_
1787
1794
}
1788
1795
}
1789
1796
1790
- static zend_never_inline void zend_post_incdec_overloaded_property (zval * object , zval * property , void * * cache_slot , int inc OPLINE_DC EXECUTE_DATA_DC )
1797
+ static zend_never_inline void zend_post_incdec_overloaded_property (zval * object , zval * property , void * * cache_slot OPLINE_DC EXECUTE_DATA_DC )
1791
1798
{
1792
1799
zval rv , obj ;
1793
1800
zval * z ;
@@ -1813,7 +1820,7 @@ static zend_never_inline void zend_post_incdec_overloaded_property(zval *object,
1813
1820
1814
1821
ZVAL_COPY_DEREF (& z_copy , z );
1815
1822
ZVAL_COPY (EX_VAR (opline -> result .var ), & z_copy );
1816
- if (inc ) {
1823
+ if (ZEND_IS_INCREMENT ( opline -> opcode ) ) {
1817
1824
increment_function (& z_copy );
1818
1825
} else {
1819
1826
decrement_function (& z_copy );
@@ -1824,7 +1831,7 @@ static zend_never_inline void zend_post_incdec_overloaded_property(zval *object,
1824
1831
zval_ptr_dtor (z );
1825
1832
}
1826
1833
1827
- static zend_never_inline void zend_pre_incdec_overloaded_property (zval * object , zval * property , void * * cache_slot , int inc OPLINE_DC EXECUTE_DATA_DC )
1834
+ static zend_never_inline void zend_pre_incdec_overloaded_property (zval * object , zval * property , void * * cache_slot OPLINE_DC EXECUTE_DATA_DC )
1828
1835
{
1829
1836
zval rv ;
1830
1837
zval * z , obj ;
@@ -1851,7 +1858,7 @@ static zend_never_inline void zend_pre_incdec_overloaded_property(zval *object,
1851
1858
ZVAL_COPY_VALUE (z , value );
1852
1859
}
1853
1860
ZVAL_COPY_DEREF (& z_copy , z );
1854
- if (inc ) {
1861
+ if (ZEND_IS_INCREMENT ( opline -> opcode ) ) {
1855
1862
increment_function (& z_copy );
1856
1863
} else {
1857
1864
decrement_function (& z_copy );
0 commit comments