Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t
}
/* }}} */

ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code, uint32_t num, char *name, zend_expected_type expected_type, const zval *arg) /* {{{ */
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(zpp_error error_code, uint32_t num, char *name, zend_expected_type expected_type, const zval *arg) /* {{{ */
{
switch (error_code) {
case ZPP_ERROR_WRONG_CALLBACK:
Expand Down Expand Up @@ -261,7 +261,8 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code,
case ZPP_ERROR_FAILURE:
ZEND_ASSERT(EG(exception) && "Should have produced an error already");
break;
default: ZEND_UNREACHABLE();
case ZPP_ERROR_OK:
ZEND_UNREACHABLE();
}
}
/* }}} */
Expand Down
33 changes: 17 additions & 16 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,24 @@ typedef enum _zend_expected_type {
Z_EXPECTED_LAST
} zend_expected_type;

C23_ENUM(zpp_error, uint8_t) {
ZPP_ERROR_OK,
ZPP_ERROR_FAILURE,
ZPP_ERROR_WRONG_CALLBACK,
ZPP_ERROR_WRONG_CLASS,
ZPP_ERROR_WRONG_CLASS_OR_NULL,
ZPP_ERROR_WRONG_CLASS_OR_STRING,
ZPP_ERROR_WRONG_CLASS_OR_STRING_OR_NULL,
ZPP_ERROR_WRONG_CLASS_OR_LONG,
ZPP_ERROR_WRONG_CLASS_OR_LONG_OR_NULL,
ZPP_ERROR_WRONG_ARG,
ZPP_ERROR_UNEXPECTED_EXTRA_NAMED,
ZPP_ERROR_WRONG_CALLBACK_OR_NULL,
};

ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_none_error(void);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t min_num_args, uint32_t max_num_args);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code, uint32_t num, char *name, zend_expected_type expected_type, const zval *arg);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(zpp_error error_code, uint32_t num, char *name, zend_expected_type expected_type, const zval *arg);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(uint32_t num, zend_expected_type expected_type, const zval *arg);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(uint32_t num, const char *name, const zval *arg);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_null_error(uint32_t num, const char *name, const zval *arg);
Expand All @@ -1604,20 +1619,6 @@ ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num);
ZEND_API ZEND_COLD void zend_class_redeclaration_error(int type, const zend_class_entry *old_ce);
ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string *new_name, const zend_class_entry *old_ce);

#define ZPP_ERROR_OK 0
#define ZPP_ERROR_FAILURE 1
#define ZPP_ERROR_WRONG_CALLBACK 2
#define ZPP_ERROR_WRONG_CLASS 3
#define ZPP_ERROR_WRONG_CLASS_OR_NULL 4
#define ZPP_ERROR_WRONG_CLASS_OR_STRING 5
#define ZPP_ERROR_WRONG_CLASS_OR_STRING_OR_NULL 6
#define ZPP_ERROR_WRONG_CLASS_OR_LONG 7
#define ZPP_ERROR_WRONG_CLASS_OR_LONG_OR_NULL 8
#define ZPP_ERROR_WRONG_ARG 9
#define ZPP_ERROR_WRONG_COUNT 10
#define ZPP_ERROR_UNEXPECTED_EXTRA_NAMED 11
#define ZPP_ERROR_WRONG_CALLBACK_OR_NULL 12

#define ZEND_PARSE_PARAMETERS_START_EX(flags, min_num_args, max_num_args) do { \
const int _flags = (flags); \
uint32_t _min_num_args = (min_num_args); \
Expand All @@ -1629,7 +1630,7 @@ ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string
char *_error = NULL; \
bool _dummy = 0; \
bool _optional = 0; \
int _error_code = ZPP_ERROR_OK; \
zpp_error _error_code = ZPP_ERROR_OK; \
((void)_i); \
((void)_real_arg); \
((void)_arg); \
Expand Down
Loading