@@ -98,8 +98,8 @@ extern PHPAPI int php_array_merge(zend_array *dest, zend_array *src);
98
98
#define SWOOLE_SOCKETS_SUPPORT
99
99
#endif
100
100
101
- #if PHP_VERSION_ID < 70200
102
- #error "require PHP version 7 .2 or later"
101
+ #if PHP_VERSION_ID < 80200
102
+ #error "require PHP version 8 .2 or later"
103
103
#endif
104
104
105
105
#if defined(ZTS ) && defined(SW_USE_THREAD_CONTEXT )
@@ -377,22 +377,12 @@ zend_bool php_swoole_signal_isset_handler(int signo);
377
377
/*}}}*/
378
378
379
379
/* PHP 8 compatibility macro {{{*/
380
- #if PHP_VERSION_ID < 80000
381
- #define sw_zend7_object zval
382
- #define SW_Z7_OBJ_P (object ) Z_OBJ_P(object)
383
- #define SW_Z8_OBJ_P (zobj ) zobj
384
- #else
385
380
#define sw_zend7_object zend_object
386
381
#define SW_Z7_OBJ_P (object ) object
387
382
#define SW_Z8_OBJ_P (zobj ) Z_OBJ_P(zobj)
388
- #endif
389
383
/*}}}*/
390
384
391
- #if PHP_VERSION_ID < 70400
392
- typedef size_t php_stream_size_t ;
393
- #else
394
385
typedef ssize_t php_stream_size_t ;
395
- #endif
396
386
397
387
/* PHP 7 wrapper functions / macros */
398
388
@@ -406,18 +396,8 @@ typedef ssize_t php_stream_size_t;
406
396
(ptr) = &(val); \
407
397
} while (0)
408
398
409
- #if PHP_VERSION_ID < 80000
410
- #define SW_ZVAL_SOCKET (return_value , result ) \
411
- ZVAL_RES(return_value, zend_register_resource((void *) (result), php_sockets_le_socket()))
412
- #else
413
399
#define SW_ZVAL_SOCKET (return_value , result ) ZVAL_OBJ(return_value, &result->std)
414
- #endif
415
-
416
- #if PHP_VERSION_ID < 80000
417
- #define SW_Z_SOCKET_P (zsocket ) (php_socket *) zend_fetch_resource_ex(zsocket, nullptr, php_sockets_le_socket())
418
- #else
419
400
#define SW_Z_SOCKET_P (zsocket ) Z_SOCKET_P(zsocket)
420
- #endif
421
401
422
402
#ifndef ZVAL_IS_BOOL
423
403
static sw_inline zend_bool ZVAL_IS_BOOL (zval * v ) {
@@ -613,13 +593,7 @@ static sw_inline void add_assoc_ulong_safe(zval *arg, const char *key, zend_ulon
613
593
} \
614
594
} while (0)
615
595
616
- #if PHP_VERSION_ID < 80100
617
- #define SW_SET_CLASS_NOT_SERIALIZABLE (module ) \
618
- module##_ce->serialize = zend_class_serialize_deny; \
619
- module##_ce->unserialize = zend_class_unserialize_deny;
620
- #else
621
596
#define SW_SET_CLASS_NOT_SERIALIZABLE (module ) module##_ce->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
622
- #endif
623
597
624
598
#define sw_zend_class_clone_deny NULL
625
599
#define SW_SET_CLASS_CLONEABLE (module , _clone_obj ) module##_handlers.clone_obj = _clone_obj
@@ -690,25 +664,9 @@ static sw_inline int sw_zend_register_class_alias(const char *name, size_t name_
690
664
691
665
zend_string * _interned_name = zend_new_interned_string (_name );
692
666
693
- #if PHP_VERSION_ID >= 70300
694
667
return zend_register_class_alias_ex (ZSTR_VAL (_interned_name ), ZSTR_LEN (_interned_name ), ce , 1 );
695
- #else
696
- return zend_register_class_alias_ex (ZSTR_VAL (_interned_name ), ZSTR_LEN (_interned_name ), ce );
697
- #endif
698
668
}
699
669
700
- #if PHP_VERSION_ID < 70300
701
- /* Allocates object type and zeros it, but not the properties.
702
- * Properties MUST be initialized using object_properties_init(). */
703
- static zend_always_inline void * zend_object_alloc (size_t obj_size , zend_class_entry * ce ) {
704
- void * obj = emalloc (obj_size + zend_object_properties_size (ce ));
705
- /* Subtraction of sizeof(zval) is necessary, because zend_object_properties_size() may be
706
- * -sizeof(zval), if the object has no properties. */
707
- memset (obj , 0 , obj_size - sizeof (zval ));
708
- return obj ;
709
- }
710
- #endif
711
-
712
670
static sw_inline zend_object * sw_zend_create_object (zend_class_entry * ce , zend_object_handlers * handlers ) {
713
671
zend_object * object = (zend_object * ) zend_object_alloc (sizeof (zend_object ), ce );
714
672
zend_object_std_init (object , ce );
@@ -733,21 +691,6 @@ static sw_inline zend_object *sw_zend_create_object_deny(zend_class_entry *ce) {
733
691
return object ;
734
692
}
735
693
736
- #if PHP_VERSION_ID < 80000
737
- static sw_inline void sw_zend_class_unset_property_deny (zval * zobject , zval * zmember , void * * cache_slot ) {
738
- zend_class_entry * ce = Z_OBJCE_P (zobject );
739
- while (ce -> parent ) {
740
- ce = ce -> parent ;
741
- }
742
- SW_ASSERT (ce -> type == ZEND_INTERNAL_CLASS );
743
- if (EXPECTED (zend_hash_find (& ce -> properties_info , Z_STR_P (zmember )))) {
744
- zend_throw_error (
745
- NULL , "Property %s of class %s cannot be unset" , Z_STRVAL_P (zmember ), SW_Z_OBJCE_NAME_VAL_P (zobject ));
746
- return ;
747
- }
748
- std_object_handlers .unset_property (zobject , zmember , cache_slot );
749
- }
750
- #else
751
694
static sw_inline void sw_zend_class_unset_property_deny (zend_object * object , zend_string * member , void * * cache_slot ) {
752
695
zend_class_entry * ce = object -> ce ;
753
696
while (ce -> parent ) {
@@ -760,7 +703,6 @@ static sw_inline void sw_zend_class_unset_property_deny(zend_object *object, zen
760
703
}
761
704
std_object_handlers .unset_property (object , member , cache_slot );
762
705
}
763
- #endif
764
706
765
707
static sw_inline zval * sw_zend_read_property (zend_class_entry * ce , zval * obj , const char * s , int len , int silent ) {
766
708
zval rv , * property = zend_read_property (ce , SW_Z8_OBJ_P (obj ), s , len , silent , & rv );
@@ -873,12 +815,8 @@ static sw_inline zend_bool sw_zend_is_callable_at_frame(zval *zcallable,
873
815
char * * error ) {
874
816
zend_string * name ;
875
817
zend_bool ret ;
876
- #if PHP_VERSION_ID < 80000
877
- ret = zend_is_callable_ex (zcallable , zobject ? Z_OBJ_P (zobject ) : NULL , check_flags , & name , fci_cache , error );
878
- #else
879
818
ret = zend_is_callable_at_frame (zcallable , zobject ? Z_OBJ_P (zobject ) : NULL , frame , check_flags , fci_cache , error );
880
819
name = zend_get_callable_name_ex (zcallable , zobject ? Z_OBJ_P (zobject ) : NULL );
881
- #endif
882
820
if (callable_name ) {
883
821
* callable_name = estrndup (ZSTR_VAL (name ), ZSTR_LEN (name ));
884
822
}
@@ -921,11 +859,7 @@ static sw_inline int sw_zend_call_function_ex(
921
859
fci .retval = retval ? retval : & _retval ;
922
860
fci .param_count = param_count ;
923
861
fci .params = params ;
924
- #if PHP_VERSION_ID >= 80000
925
862
fci .named_params = NULL ;
926
- #else
927
- fci .no_separation = 0 ;
928
- #endif
929
863
930
864
ret = zend_call_function (& fci , fci_cache );
931
865
@@ -1038,10 +972,7 @@ static sw_inline char *php_swoole_url_encode(const char *value, size_t value_len
1038
972
}
1039
973
1040
974
static sw_inline char * php_swoole_http_build_query (zval * zdata , size_t * length , smart_str * formstr ) {
1041
- #if PHP_VERSION_ID < 80000
1042
- if (php_url_encode_hash_ex (
1043
- HASH_OF (zdata ), formstr , NULL , 0 , NULL , 0 , NULL , 0 , NULL , NULL , (int ) PHP_QUERY_RFC1738 ) == FAILURE ) {
1044
- #elif PHP_VERSION_ID < 80300
975
+ #if PHP_VERSION_ID < 80300
1045
976
if (HASH_OF (zdata )) {
1046
977
php_url_encode_hash_ex (HASH_OF (zdata ), formstr , NULL , 0 , NULL , 0 , NULL , 0 , NULL , NULL , (int ) PHP_QUERY_RFC1738 );
1047
978
} else {
0 commit comments