summaryrefslogtreecommitdiff
path: root/ext/tidy/tidy.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-09-22 14:29:42 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2019-09-22 16:18:33 +0200
commit6072fe4342760c4bb02f91328d95ebf425e55b93 (patch)
tree6b81ad6b0a7351dfca7bfec69a7b0280d54317e7 /ext/tidy/tidy.c
parent071ccee7f7fd9a3d3e2555be093f2e5fef40e507 (diff)
downloadphp-git-6072fe4342760c4bb02f91328d95ebf425e55b93.tar.gz
Properly use zend_parse_method_parameters()
`zend_parse_method_parameters()` is meant for dual (procedural and OO) APIs; there is no need to attempt to get "this" first, and to dispatch to `zend_parse_parameters()` and `zend_parse_method_parameters()`, respectively.
Diffstat (limited to 'ext/tidy/tidy.c')
-rw-r--r--ext/tidy/tidy.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 9da7037b71..86092b554e 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -54,15 +54,9 @@
#define TIDY_FETCH_OBJECT \
PHPTidyObj *obj; \
- TIDY_SET_CONTEXT; \
- if (object) { \
- if (zend_parse_parameters_none() == FAILURE) { \
- return; \
- } \
- } else { \
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), NULL, "O", &object, tidy_ce_doc) == FAILURE) { \
- RETURN_FALSE; \
- } \
+ zval *object; \
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, tidy_ce_doc) == FAILURE) { \
+ RETURN_FALSE; \
} \
obj = Z_TIDY_P(object); \
@@ -1404,17 +1398,10 @@ static PHP_FUNCTION(tidy_get_opt_doc)
char *optval, *optname;
size_t optname_len;
TidyOption opt;
+ zval *object;
- TIDY_SET_CONTEXT;
-
- if (object) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &optname, &optname_len) == FAILURE) {
- RETURN_FALSE;
- }
- } else {
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), NULL, "Os", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
- RETURN_FALSE;
- }
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
+ RETURN_FALSE;
}
obj = Z_TIDY_P(object);
@@ -1565,17 +1552,10 @@ static PHP_FUNCTION(tidy_getopt)
size_t optname_len;
TidyOption opt;
TidyOptionType optt;
+ zval *object;
- TIDY_SET_CONTEXT;
-
- if (object) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &optname, &optname_len) == FAILURE) {
- RETURN_FALSE;
- }
- } else {
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), NULL, "Os", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
- RETURN_FALSE;
- }
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
+ RETURN_FALSE;
}
obj = Z_TIDY_P(object);