Skip to content

Commit 308dfd2

Browse files
committed
remove useless old php logics
1 parent ed8bfd5 commit 308dfd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+10
-1740
lines changed

ext-src/php_swoole.cc

+1-16
Original file line numberDiff line numberDiff line change
@@ -160,26 +160,11 @@ static void php_swoole_init_globals(zend_openswoole_globals *openswoole_globals)
160160

161161
void php_swoole_register_shutdown_function(const char *function) {
162162
php_shutdown_function_entry shutdown_function_entry;
163-
#if PHP_VERSION_ID >= 80100
164163
zval function_name;
165164
ZVAL_STRING(&function_name, function);
166165
zend_fcall_info_init(
167166
&function_name, 0, &shutdown_function_entry.fci, &shutdown_function_entry.fci_cache, NULL, NULL);
168167
register_user_shutdown_function(Z_STRVAL(function_name), Z_STRLEN(function_name), &shutdown_function_entry);
169-
#else
170-
zval *function_name;
171-
#if PHP_VERSION_ID >= 80000
172-
shutdown_function_entry.arg_count = 0;
173-
shutdown_function_entry.arguments = NULL;
174-
function_name = &shutdown_function_entry.function_name;
175-
#else
176-
shutdown_function_entry.arg_count = 1;
177-
shutdown_function_entry.arguments = (zval *) safe_emalloc(sizeof(zval), 1, 0);
178-
function_name = &shutdown_function_entry.arguments[0];
179-
#endif
180-
ZVAL_STRING(function_name, function);
181-
register_user_shutdown_function(Z_STRVAL_P(function_name), Z_STRLEN_P(function_name), &shutdown_function_entry);
182-
#endif
183168
}
184169

185170
void php_swoole_set_global_option(HashTable *vht) {
@@ -1198,7 +1183,7 @@ PHP_MINIT_FUNCTION(openswoole) {
11981183
SwooleG.dns_cache_refresh_time = 60;
11991184

12001185
// enable pcre.jit and use swoole extension on MacOS will lead to coredump, disable it temporarily
1201-
#if defined(PHP_PCRE_VERSION) && defined(HAVE_PCRE_JIT_SUPPORT) && PHP_VERSION_ID >= 70300 && __MACH__ && \
1186+
#if defined(PHP_PCRE_VERSION) && defined(HAVE_PCRE_JIT_SUPPORT) && __MACH__ && \
12021187
!defined(SW_DEBUG)
12031188
PCRE_G(jit) = 0;
12041189
#endif

ext-src/php_swoole_coroutine.h

-6
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ struct PHPContext {
5353
zend_vm_stack vm_stack;
5454
size_t vm_stack_page_size;
5555
zend_execute_data *execute_data;
56-
#if PHP_VERSION_ID >= 80000
5756
uint32_t jit_trace_num;
58-
#endif
5957
#ifdef ZEND_CHECK_STACK_LIMIT
6058
void *stack_base;
6159
void *stack_limit;
@@ -64,10 +62,6 @@ struct PHPContext {
6462
zend_class_entry *exception_class;
6563
zend_object *exception;
6664
zend_output_globals *output_ptr;
67-
#if PHP_VERSION_ID < 80100
68-
/* for array_walk non-reentrancy */
69-
zend::Function *array_walk_fci;
70-
#endif
7165
/* for error control `@` */
7266
bool in_silence;
7367
bool enable_scheduler;

ext-src/php_swoole_cxx.cc

-17
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,8 @@ SW_API zend_string **sw_zend_known_strings = nullptr;
1212

1313
//----------------------------------Swoole known string------------------------------------
1414

15-
#if PHP_VERSION_ID < 80000
16-
typedef zval zend_source_string_t;
17-
#else
1815
typedef zend_string zend_source_string_t;
19-
#endif
2016

21-
#if PHP_VERSION_ID < 80200
22-
static zend_op_array *swoole_compile_string(zend_source_string_t *source_string, ZEND_STR_CONST char *filename);
23-
24-
// for compatibly with dis_eval
25-
static zend_op_array *(*old_compile_string)(zend_source_string_t *source_string, ZEND_STR_CONST char *filename);
26-
27-
static zend_op_array *swoole_compile_string(zend_source_string_t *source_string, ZEND_STR_CONST char *filename) {
28-
zend_op_array *opa = old_compile_string(source_string, filename);
29-
opa->type = ZEND_USER_FUNCTION;
30-
return opa;
31-
}
32-
#else
3317
static zend_op_array *swoole_compile_string(zend_source_string_t *source_string,
3418
ZEND_STR_CONST char *filename,
3519
zend_compile_position position);
@@ -45,7 +29,6 @@ static zend_op_array *swoole_compile_string(zend_source_string_t *source_string,
4529
opa->type = ZEND_USER_FUNCTION;
4630
return opa;
4731
}
48-
#endif
4932

5033
namespace zend {
5134
bool eval(const std::string &code, std::string const &filename) {

ext-src/php_swoole_cxx.h

-4
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,7 @@ static inline void assign_zend_string_by_val(zval *zdata, char *addr, size_t len
443443
ZVAL_STR(zdata, zstr);
444444
}
445445

446-
#if PHP_VERSION_ID < 80000
447-
#define ZEND_STR_CONST
448-
#else
449446
#define ZEND_STR_CONST const
450-
#endif
451447

452448
#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX
453449
#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \

ext-src/php_swoole_private.h

+3-72
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ extern PHPAPI int php_array_merge(zend_array *dest, zend_array *src);
9898
#define SWOOLE_SOCKETS_SUPPORT
9999
#endif
100100

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"
103103
#endif
104104

105105
#if defined(ZTS) && defined(SW_USE_THREAD_CONTEXT)
@@ -377,22 +377,12 @@ zend_bool php_swoole_signal_isset_handler(int signo);
377377
/*}}}*/
378378

379379
/* 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
385380
#define sw_zend7_object zend_object
386381
#define SW_Z7_OBJ_P(object) object
387382
#define SW_Z8_OBJ_P(zobj) Z_OBJ_P(zobj)
388-
#endif
389383
/*}}}*/
390384

391-
#if PHP_VERSION_ID < 70400
392-
typedef size_t php_stream_size_t;
393-
#else
394385
typedef ssize_t php_stream_size_t;
395-
#endif
396386

397387
/* PHP 7 wrapper functions / macros */
398388

@@ -406,18 +396,8 @@ typedef ssize_t php_stream_size_t;
406396
(ptr) = &(val); \
407397
} while (0)
408398

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
413399
#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
419400
#define SW_Z_SOCKET_P(zsocket) Z_SOCKET_P(zsocket)
420-
#endif
421401

422402
#ifndef ZVAL_IS_BOOL
423403
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
613593
} \
614594
} while (0)
615595

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
621596
#define SW_SET_CLASS_NOT_SERIALIZABLE(module) module##_ce->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
622-
#endif
623597

624598
#define sw_zend_class_clone_deny NULL
625599
#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_
690664

691665
zend_string *_interned_name = zend_new_interned_string(_name);
692666

693-
#if PHP_VERSION_ID >= 70300
694-
return zend_register_class_alias_ex(ZSTR_VAL(_interned_name), ZSTR_LEN(_interned_name), ce, 1);
695-
#else
696667
return zend_register_class_alias_ex(ZSTR_VAL(_interned_name), ZSTR_LEN(_interned_name), ce);
697-
#endif
698668
}
699669

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-
712670
static sw_inline zend_object *sw_zend_create_object(zend_class_entry *ce, zend_object_handlers *handlers) {
713671
zend_object *object = (zend_object *) zend_object_alloc(sizeof(zend_object), ce);
714672
zend_object_std_init(object, ce);
@@ -733,21 +691,6 @@ static sw_inline zend_object *sw_zend_create_object_deny(zend_class_entry *ce) {
733691
return object;
734692
}
735693

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
751694
static sw_inline void sw_zend_class_unset_property_deny(zend_object *object, zend_string *member, void **cache_slot) {
752695
zend_class_entry *ce = object->ce;
753696
while (ce->parent) {
@@ -760,7 +703,6 @@ static sw_inline void sw_zend_class_unset_property_deny(zend_object *object, zen
760703
}
761704
std_object_handlers.unset_property(object, member, cache_slot);
762705
}
763-
#endif
764706

765707
static sw_inline zval *sw_zend_read_property(zend_class_entry *ce, zval *obj, const char *s, int len, int silent) {
766708
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,
873815
char **error) {
874816
zend_string *name;
875817
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
879818
ret = zend_is_callable_at_frame(zcallable, zobject ? Z_OBJ_P(zobject) : NULL, frame, check_flags, fci_cache, error);
880819
name = zend_get_callable_name_ex(zcallable, zobject ? Z_OBJ_P(zobject) : NULL);
881-
#endif
882820
if (callable_name) {
883821
*callable_name = estrndup(ZSTR_VAL(name), ZSTR_LEN(name));
884822
}
@@ -921,11 +859,7 @@ static sw_inline int sw_zend_call_function_ex(
921859
fci.retval = retval ? retval : &_retval;
922860
fci.param_count = param_count;
923861
fci.params = params;
924-
#if PHP_VERSION_ID >= 80000
925862
fci.named_params = NULL;
926-
#else
927-
fci.no_separation = 0;
928-
#endif
929863

930864
ret = zend_call_function(&fci, fci_cache);
931865

@@ -1038,10 +972,7 @@ static sw_inline char *php_swoole_url_encode(const char *value, size_t value_len
1038972
}
1039973

1040974
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
1045976
if (HASH_OF(zdata)) {
1046977
php_url_encode_hash_ex(HASH_OF(zdata), formstr, NULL, 0, NULL, 0, NULL, 0, NULL, NULL, (int) PHP_QUERY_RFC1738);
1047978
} else {

ext-src/swoole_atomic.cc

-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
#include "php_swoole_private.h"
1818
#include "swoole_memory.h"
1919

20-
#if PHP_VERSION_ID >= 80000
2120
#include "swoole_atomic_arginfo.h"
22-
#else
23-
#include "swoole_atomic_arginfo_legacy.h"
24-
#endif
2521

2622
#ifdef HAVE_FUTEX
2723
#include <linux/futex.h>

ext-src/swoole_atomic_arginfo_legacy.h

-32
This file was deleted.

ext-src/swoole_channel_coro.cc

-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121

2222
#include "swoole_coroutine_channel.h"
2323

24-
#if PHP_VERSION_ID >= 80000
2524
#include "swoole_channel_coro_arginfo.h"
26-
#else
27-
#include "swoole_channel_coro_arginfo_legacy.h"
28-
#endif
2925

3026
using swoole::coroutine::Channel;
3127

ext-src/swoole_channel_coro_arginfo_legacy.h

-23
This file was deleted.

ext-src/swoole_client.cc

-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
#include "php_swoole_client.h"
1919
#include "swoole_mqtt.h"
2020

21-
#if PHP_VERSION_ID >= 80000
2221
#include "swoole_client_arginfo.h"
23-
#else
24-
#include "swoole_client_arginfo_legacy.h"
25-
#endif
2622

2723
#include <string>
2824
#include <queue>

0 commit comments

Comments
 (0)