Skip to content

Commit

Permalink
handlers: ZEND_VERIFY_NEVER_TYPE conditional for PHP 8.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
kornrunner committed Aug 7, 2024
1 parent 510989a commit 02de1dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 14 additions & 0 deletions src/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@

ZEND_EXTERN_MODULE_GLOBALS(uopz);

#if PHP_VERSION_ID >= 80100
#define UOPZ_HANDLERS_COUNT 13
#else
#define UOPZ_HANDLERS_COUNT 12
#endif

#ifdef ZEND_VM_FP_GLOBAL_REG
# define UOPZ_OPCODE_HANDLER_ARGS
Expand Down Expand Up @@ -99,7 +103,9 @@ typedef struct _uopz_vm_handler_t {
} uopz_vm_handler_t;

zend_vm_handler_t zend_vm_exit;
#if PHP_VERSION_ID >= 80100
zend_vm_handler_t zend_vm_verify_never_type;
#endif
zend_vm_handler_t zend_vm_new;
zend_vm_handler_t zend_vm_fetch_constant;
zend_vm_handler_t zend_vm_do_fcall;
Expand All @@ -113,7 +119,9 @@ zend_vm_handler_t zend_vm_init_method_call;
zend_vm_handler_t zend_vm_init_static_method_call;

int uopz_vm_exit(UOPZ_OPCODE_HANDLER_ARGS);
#if PHP_VERSION_ID >= 80100
int uopz_vm_verify_never_type(UOPZ_OPCODE_HANDLER_ARGS);
#endif
int uopz_vm_new(UOPZ_OPCODE_HANDLER_ARGS);
int uopz_vm_fetch_constant(UOPZ_OPCODE_HANDLER_ARGS);
int uopz_vm_do_fcall(UOPZ_OPCODE_HANDLER_ARGS);
Expand All @@ -127,7 +135,9 @@ int uopz_vm_init_static_method_call(UOPZ_OPCODE_HANDLER_ARGS);

UOPZ_HANDLERS_DECL_BEGIN()
UOPZ_HANDLER_DECL(ZEND_EXIT, exit)
#if PHP_VERSION_ID >= 80100
UOPZ_HANDLER_DECL(ZEND_VERIFY_NEVER_TYPE, verify_never_type)
#endif
UOPZ_HANDLER_DECL(ZEND_NEW, new)
UOPZ_HANDLER_DECL(ZEND_FETCH_CONSTANT, fetch_constant)
UOPZ_HANDLER_DECL(ZEND_FETCH_CLASS_CONSTANT, fetch_class_constant)
Expand Down Expand Up @@ -176,9 +186,11 @@ static zend_always_inline int _uopz_vm_dispatch(UOPZ_OPCODE_HANDLER_ARGS) {
zend = zend_vm_exit;
break;

#if PHP_VERSION_ID >= 80100
case ZEND_VERIFY_NEVER_TYPE:
zend = zend_vm_verify_never_type;
break;
#endif

case ZEND_NEW:
zend = zend_vm_new;
Expand Down Expand Up @@ -274,11 +286,13 @@ int uopz_vm_exit(UOPZ_OPCODE_HANDLER_ARGS) { /* {{{ */
}
} /* }}} */

#if PHP_VERSION_ID >= 80100
int uopz_vm_verify_never_type(UOPZ_OPCODE_HANDLER_ARGS) { /* {{{ */
if (UOPZ(exit)) {
UOPZ_VM_DISPATCH();
} else UOPZ_VM_RETURN();
} /* }}} */
#endif

int uopz_vm_new(UOPZ_OPCODE_HANDLER_ARGS) { /* {{{ */
UOPZ_USE_OPLINE;
Expand Down
4 changes: 0 additions & 4 deletions uopz.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ ZEND_END_MODULE_GLOBALS(uopz)
#define uopz_exception(message, ...) zend_throw_exception_ex\
(spl_ce_RuntimeException, 0, message, ##__VA_ARGS__)

#if PHP_VERSION_ID < 80100
#define ZEND_VERIFY_NEVER_TYPE 201
#endif

#endif /* UOPZ_H */

/*
Expand Down

0 comments on commit 02de1dc

Please sign in to comment.