From a0638f421b3167412de2a4af6d8369e07c1cb18f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Schl=C3=BCter?= Date: Mon, 25 Jan 2010 17:29:37 +0000 Subject: [PATCH] Merge tidynode changes: (pierrick) r292635 - Changed tidyNode class to disallow manual node creation. r292719 - Set the tidyNode constructor private r292765 - Add a test for tidyNode::__construct() --- NEWS | 1 + ext/tidy/php_tidy.h | 1 + ext/tidy/tests/023.phpt | 8 -------- ext/tidy/tests/025.phpt | 14 -------------- ext/tidy/tests/035.phpt | 12 ++++++++++++ ext/tidy/tidy.c | 10 ++++++++++ 6 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 ext/tidy/tests/035.phpt diff --git a/NEWS b/NEWS index e2a7a52c5d..2abdb5eee8 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,7 @@ PHP NEWS (David Soria Parra) - Changed "post_max_size" php.ini directive to allow unlimited post size by setting it to 0. (Rasmus) +- Changed tidyNode class to disallow manual node creation. (Pierrick) - Removed automatic file descriptor unlocking happening on shutdown and/or stream close (on all OSes). (Tony, Ilia) diff --git a/ext/tidy/php_tidy.h b/ext/tidy/php_tidy.h index 03ddb32872..90a3e095d2 100644 --- a/ext/tidy/php_tidy.h +++ b/ext/tidy/php_tidy.h @@ -28,6 +28,7 @@ extern zend_module_entry tidy_module_entry; ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types) #define TIDY_NODE_METHOD(name) PHP_FUNCTION(tnm_ ##name) #define TIDY_NODE_ME(name, param) TIDY_METHOD_MAP(name, tnm_ ##name, param) +#define TIDY_NODE_PRIVATE_ME(name, param) ZEND_NAMED_ME(name, ZEND_FN(tnm_ ##name), param, ZEND_ACC_PRIVATE) #define TIDY_DOC_METHOD(name) PHP_FUNCTION(tdm_ ##name) #define TIDY_DOC_ME(name, param) TIDY_METHOD_MAP(name, tdm_ ##name, param) #define TIDY_ATTR_METHOD(name) PHP_FUNCTION(tam_ ##name) diff --git a/ext/tidy/tests/023.phpt b/ext/tidy/tests/023.phpt index e7ee4b3c0c..1f7b02d56b 100644 --- a/ext/tidy/tests/023.phpt +++ b/ext/tidy/tests/023.phpt @@ -6,16 +6,11 @@ tidy and tidyNode OO isHtml()); - $tidy = new tidy(); $tidy->parseString(''); @@ -30,8 +25,6 @@ var_dump(tidy_get_root($tidy)->child[0]->child[0]->hasChildren()); ?> --EXPECT-- -object(tidyNode)#1 (0) { -} object(tidy)#1 (2) { ["errorBuffer"]=> NULL @@ -39,7 +32,6 @@ object(tidy)#1 (2) { NULL } ------- -bool(false) bool(true) bool(true) bool(false) diff --git a/ext/tidy/tests/025.phpt b/ext/tidy/tests/025.phpt index a7bd544d67..631ec2e5e9 100644 --- a/ext/tidy/tests/025.phpt +++ b/ext/tidy/tests/025.phpt @@ -5,15 +5,6 @@ tidyNode tests --FILE-- isPhp()); -var_dump($node->isText()); -var_dump($node->isComment()); -var_dump($node->hasSiblings()); -var_dump((string)$node); - $tidy=tidy_parse_string('<% %>'); var_dump($tidy->Root()->child[0]->isAsp()); @@ -34,11 +25,6 @@ var_dump($tidy->Root()->child[0]->child[0]->hasSiblings()); ?> --EXPECT-- -bool(false) -bool(false) -bool(false) -bool(false) -string(0) "" bool(true) bool(true) bool(true) diff --git a/ext/tidy/tests/035.phpt b/ext/tidy/tests/035.phpt new file mode 100644 index 0000000000..832f90fe57 --- /dev/null +++ b/ext/tidy/tests/035.phpt @@ -0,0 +1,12 @@ +--TEST-- +tidyNode::__construct() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Fatal error: Call to private tidyNode::__construct() from invalid context in %s on line %d diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 64da737d66..28982d7b19 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -268,6 +268,7 @@ static TIDY_NODE_METHOD(isJste); static TIDY_NODE_METHOD(isAsp); static TIDY_NODE_METHOD(isPhp); static TIDY_NODE_METHOD(getParent); +static TIDY_NODE_METHOD(__construct); /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(tidy) @@ -443,6 +444,7 @@ static const zend_function_entry tidy_funcs_node[] = { TIDY_NODE_ME(isAsp, NULL) TIDY_NODE_ME(isPhp, NULL) TIDY_NODE_ME(getParent, NULL) + TIDY_NODE_PRIVATE_ME(__construct, NULL) {NULL, NULL, NULL} }; @@ -1790,6 +1792,14 @@ static TIDY_NODE_METHOD(getParent) } /* }}} */ +/* {{{ proto void tidyNode::__construct() + __constructor for tidyNode. */ +static TIDY_NODE_METHOD(__construct) +{ + php_error_docref(NULL TSRMLS_CC, E_ERROR, "You should not create a tidyNode manually"); +} +/* }}} */ + static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS) { TIDY_NODE_CONST(ROOT, Root); -- 2.40.0