Re: [PHP-DEV] rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON
On 10/30/2010 10:01 AM, Richard Quadling wrote: On 30 October 2010 02:51, Chad Emrys ad...@codeangel.org wrote: What is in a name anyway? Would a T_PAAMAYIM_NEKUDOTAYIM by any other name make a difference? To provide a counterargument, it certainly would. I don't consider myself an inexperienced PHP developer and have certainly done some OO programming, yet I only recently stumbled upon this error. I must admit that it is confusing. Most of these error messages are descriptive enough that just glossing over the code allows me to fix the issue 4 out of 5 times. For this one I had to do a Google search to reaffirm that my PHP installation didn't become the victim of a corrupted filesystem. Regards, Jorrit -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] Allowing an array as a parameter for snmpget()/snmpgetnext() [repost]
Chris and others, Since SNMP didn't have any unit tests to begin with, I just looked at some examples. I guess I looked at the wrong ones (in the current version 5811 unit tests have the SKIPIF sections, compared to 5416 that do not). Before I start adding these, can someone tell me what to do to get this patch included? The maintainers of the SNMP extension have been silent so far. I would love to make this patch fly, but if it's just not going to happen then that's fine with me too. Regards, Jorrit Kronjee On 10/11/2010 04:37 PM, Christopher Jones wrote: Hi Jorrit, I'm not able to comment on the question of inclusion, but I did notice that the .phpt files are missing SKIPIF sections. See http://qa.php.net/write-test.php Chris On 10/11/2010 05:43 AM, Jorrit Kronjee wrote: Dear list, A few weeks ago I submitted the attached patch to this list. Apart from some initial comments I've not heard if the patch is good enough now to be added to the PHP sources. Is there anything still missing? Regards, Jorrit Kronjee -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] [PATCH] Allowing an array as a parameter for snmpget()/snmpgetnext() [repost]
Dear list, A few weeks ago I submitted the attached patch to this list. Apart from some initial comments I've not heard if the patch is good enough now to be added to the PHP sources. Is there anything still missing? Regards, Jorrit Kronjee Index: ext/snmp/tests/snmpgetnext_error.phpt === --- ext/snmp/tests/snmpgetnext_error.phpt (revision 0) +++ ext/snmp/tests/snmpgetnext_error.phpt (revision 0) @@ -0,0 +1,24 @@ +--TEST-- +Test function snmpgetnext() by calling it more than or less than its expected arguments +--FILE-- +?php +include_once(connect.inc); + +echo *** Test by calling method or function with incorrect numbers of arguments ***\n; + +$extra_arg = ''; + +var_dump(snmpgetnext( $host, $community, $object_id, $timeout, $retries, $extra_arg ) ); + +var_dump(snmpgetnext( $host, $community ) ); + + +? +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: snmpgetnext() expects at most 5 parameters, 6 given in %s on line %d +NULL + +Warning: snmpgetnext() expects at least 3 parameters, 2 given in %s on line %d +NULL Index: ext/snmp/tests/snmpget_error.phpt === --- ext/snmp/tests/snmpget_error.phpt (revision 0) +++ ext/snmp/tests/snmpget_error.phpt (revision 0) @@ -0,0 +1,24 @@ +--TEST-- +Test function snmpget() by calling it more than or less than its expected arguments +--FILE-- +?php +include_once(connect.inc); + +echo *** Test by calling method or function with incorrect numbers of arguments ***\n; + +$extra_arg = ''; + +var_dump(snmpget( $host, $community, $object_id, $timeout, $retries, $extra_arg ) ); + +var_dump(snmpget( $host, $community ) ); + + +? +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: snmpget() expects at most 5 parameters, 6 given in %s on line %d +NULL + +Warning: snmpget() expects at least 3 parameters, 2 given in %s on line %d +NULL Index: ext/snmp/tests/connect.inc === --- ext/snmp/tests/connect.inc (revision 0) +++ ext/snmp/tests/connect.inc (revision 0) @@ -0,0 +1,17 @@ +?php +/* +Default configuration is below. +Change the SNMP_TEST_* environment values if you want to use another configuration. +*/ + +$hostname = getenv(SNMP_TEST_HOST) ? getenv(SNMP_TEST_HOST) : localhost; +$port = getenv(SNMP_TEST_PORT) ? getenv(SNMP_TEST_PORT) : 161; +$host = $hostname:$port; +$community = getenv(SNMP_TEST_COMMUNITY) ? getenv(SNMP_TEST_COMMUNITY) : abc123; +$object_id = getenv(SNMP_TEST_OBJECT_ID) ? getenv(SNMP_TEST_OBJECT_ID) : .1.3.6.1.2.1.1.1.0; +$another_object_id = getenv(SNMP_TEST_ANOTHER_OBJECT_ID) ? getenv(SNMP_TEST_ANOTHER_OBJECT_ID) : .1.3.6.1.2.1.1.3.0; +$timeout = 10; +$retries = 2; + + +? Index: ext/snmp/tests/snmpgetnextoid_basic.phpt === --- ext/snmp/tests/snmpgetnextoid_basic.phpt(revision 0) +++ ext/snmp/tests/snmpgetnextoid_basic.phpt(revision 0) @@ -0,0 +1,38 @@ +--TEST-- +Test function snmpgetnextoid() by calling it with its expected arguments +--FILE-- +?php +include_once(connect.inc); + +echo *** Test by calling method or function with its expected arguments ***\n; + +var_dump(snmpgetnextoid( $host, $community, $object_id ) ); + +var_dump(snmpgetnextoid( $host, $community, $object_id, $timeout ) ); + +var_dump(snmpgetnextoid( $host, $community, $object_id, $timeout, $retries ) ); + +var_dump(snmpgetnextoid( $host, $community, array($object_id, $another_object_id), $timeout, $retries ) ); + + +? +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +array(1) { + [%s]= + string(%d) %s +} +array(1) { + [%s]= + string(%d) %s +} +array(1) { + [%s]= + string(%d) %s +} +array(2) { + [%s]= + string(%d) %s + [%s]= + string(%d) %s +} Index: ext/snmp/tests/snmpgetoid_basic.phpt === --- ext/snmp/tests/snmpgetoid_basic.phpt(revision 0) +++ ext/snmp/tests/snmpgetoid_basic.phpt(revision 0) @@ -0,0 +1,38 @@ +--TEST-- +Test function snmpgetoid() by calling it with its expected arguments +--FILE-- +?php +include_once(connect.inc); + +echo *** Test by calling method or function with its expected arguments ***\n; + +var_dump(snmpgetoid( $host, $community, $object_id ) ); + +var_dump(snmpgetoid( $host, $community, $object_id, $timeout ) ); + +var_dump(snmpgetoid( $host, $community, $object_id, $timeout, $retries ) ); + +var_dump(snmpgetoid( $host, $community, array($object_id, $another_object_id), $timeout, $retries ) ); + + +? +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +array(1) { + [%s]= + string(%d) %s +} +array(1) { + [%s]= + string(%d) %s
Re: [PHP-DEV] [PATCH] Allowing an array as a parameter for snmpget()/snmpgetnext()
On 09/21/2010 01:36 AM, Chris Stockton wrote: Hello, On Mon, Sep 20, 2010 at 2:17 PM, Michael Maclean m...@php.net wrote: On 20/09/10 20:46, Jorrit Kronjee wrote: Dear list, To better reflect the behavior of the snmpget command that comes with the Net-SNMP package the patch attached makes an array of OIDs as a parameter for the snmpget()/snmpgetnext() function possible. snip Looks good to me, for what it's worth. Anyone got objections? I think the patch at a first glance looks good, although it is a minor cosmetic nitpick, I did catch a line with a couple of extra semi-colons. static void php_snmpv3(INTERNAL_FUNCTION_PARAMETERS, int st) { - char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; - int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len, a8_len; + char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;; + int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len, a8_len;; This patch does move around a bit of code, are there some tests to go along with this patch? -Chris Chris, Ouch, I forgot to remove those extra semicolons. Thanks for noticing. What kind of tests are you looking for? I did run a couple of tests against my own SNMP devices to check for regressions, like: oldphp -r 'print_r(snmpget($host, $community, $oid))' newphp -r 'print_r(snmpget($host, $community, $oid))' I also noticed that the tests/ directory for snmp was empty, otherwise I would've run and extended some of those. Shall I just write a couple and include that in a new patch? Regards, Jorrit Kronjee -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] Allowing an array as a parameter for snmpget()/snmpgetnext()
On 09/21/2010 08:13 AM, Jorrit Kronjee wrote: snip Shall I just write a couple and include that in a new patch? So I wrote a couple of tests: Running 8 tests PASS Test function snmpget() by calling it with its expected arguments[snmpget_basic.phpt] PASS Test function snmpget() by calling it more than or less than its expected arguments[snmpget_error.phpt] PASS Test function snmpgetnext() by calling it with its expected arguments[snmpgetnext_basic.phpt] PASS Test function snmpgetnext() by calling it more than or less than its expected arguments[snmpgetnext_error.phpt] PASS Test function snmpgetnextoid() by calling it with its expected arguments[snmpgetnextoid_basic.phpt] PASS Test function snmpgetnextoid() by calling it more than or less than its expected arguments[snmpgetnextoid_error.phpt] PASS Test function snmpgetoid() by calling it with its expected arguments[snmpgetoid_basic.phpt] PASS Test function snmpgetoid() by calling it more than or less than its expected arguments[snmpgetoid_error.phpt] TOTAL TIME: 00:01 8 PASSED TESTS 0 SKIPPED TESTS These tests only run correctly with the patch. I also removed the extra semicolons. HTH Regards, Jorrit Kronjee Index: ext/snmp/tests/snmpgetnext_error.phpt === --- ext/snmp/tests/snmpgetnext_error.phpt (revision 0) +++ ext/snmp/tests/snmpgetnext_error.phpt (revision 0) @@ -0,0 +1,24 @@ +--TEST-- +Test function snmpgetnext() by calling it more than or less than its expected arguments +--FILE-- +?php +include_once(connect.inc); + +echo *** Test by calling method or function with incorrect numbers of arguments ***\n; + +$extra_arg = ''; + +var_dump(snmpgetnext( $host, $community, $object_id, $timeout, $retries, $extra_arg ) ); + +var_dump(snmpgetnext( $host, $community ) ); + + +? +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: snmpgetnext() expects at most 5 parameters, 6 given in %s on line %d +NULL + +Warning: snmpgetnext() expects at least 3 parameters, 2 given in %s on line %d +NULL Index: ext/snmp/tests/snmpget_error.phpt === --- ext/snmp/tests/snmpget_error.phpt (revision 0) +++ ext/snmp/tests/snmpget_error.phpt (revision 0) @@ -0,0 +1,24 @@ +--TEST-- +Test function snmpget() by calling it more than or less than its expected arguments +--FILE-- +?php +include_once(connect.inc); + +echo *** Test by calling method or function with incorrect numbers of arguments ***\n; + +$extra_arg = ''; + +var_dump(snmpget( $host, $community, $object_id, $timeout, $retries, $extra_arg ) ); + +var_dump(snmpget( $host, $community ) ); + + +? +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: snmpget() expects at most 5 parameters, 6 given in %s on line %d +NULL + +Warning: snmpget() expects at least 3 parameters, 2 given in %s on line %d +NULL Index: ext/snmp/tests/connect.inc === --- ext/snmp/tests/connect.inc (revision 0) +++ ext/snmp/tests/connect.inc (revision 0) @@ -0,0 +1,17 @@ +?php +/* +Default configuration is below. +Change the SNMP_TEST_* environment values if you want to use another configuration. +*/ + +$hostname = getenv(SNMP_TEST_HOST) ? getenv(SNMP_TEST_HOST) : localhost; +$port = getenv(SNMP_TEST_PORT) ? getenv(SNMP_TEST_PORT) : 161; +$host = $hostname:$port; +$community = getenv(SNMP_TEST_COMMUNITY) ? getenv(SNMP_TEST_COMMUNITY) : abc123; +$object_id = getenv(SNMP_TEST_OBJECT_ID) ? getenv(SNMP_TEST_OBJECT_ID) : .1.3.6.1.2.1.1.1.0; +$another_object_id = getenv(SNMP_TEST_ANOTHER_OBJECT_ID) ? getenv(SNMP_TEST_ANOTHER_OBJECT_ID) : .1.3.6.1.2.1.1.3.0; +$timeout = 10; +$retries = 2; + + +? Index: ext/snmp/tests/snmpgetnextoid_basic.phpt === --- ext/snmp/tests/snmpgetnextoid_basic.phpt(revision 0) +++ ext/snmp/tests/snmpgetnextoid_basic.phpt(revision 0) @@ -0,0 +1,38 @@ +--TEST-- +Test function snmpgetnextoid() by calling it with its expected arguments +--FILE-- +?php +include_once(connect.inc); + +echo *** Test by calling method or function with its expected arguments ***\n; + +var_dump(snmpgetnextoid( $host, $community, $object_id ) ); + +var_dump(snmpgetnextoid( $host, $community, $object_id, $timeout ) ); + +var_dump(snmpgetnextoid( $host, $community, $object_id, $timeout, $retries ) ); + +var_dump(snmpgetnextoid( $host, $community, array($object_id, $another_object_id), $timeout, $retries ) ); + + +? +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +array(1) { + [%s]= + string(%d) %s +} +array(1) { + [%s]= + string(%d) %s +} +array(1) { + [%s]= + string(%d) %s +} +array(2) { + [%s]= + string(%d) %s + [%s]= + string(%d) %s +} Index: ext
[PHP-DEV] [PATCH] Allowing an array as a parameter for snmpget()/snmpgetnext()
Dear list, To better reflect the behavior of the snmpget command that comes with the Net-SNMP package the patch attached makes an array of OIDs as a parameter for the snmpget()/snmpgetnext() function possible. This allows more efficient querying over SNMP as the Net-SNMP API will bundle the OIDs into one request. The patch is backwards compatible, as in, snmpget()/snmpgetnext() will still accept a string and return a string in that case. For completeness' sake, I've also added snmpgetoid() and snmpgetnextoid() as the counterparts for snmpwalkoid(). Regards, Jorrit Kronjee Index: ext/snmp/php_snmp.h === --- ext/snmp/php_snmp.h (revision 303630) +++ ext/snmp/php_snmp.h (working copy) @@ -43,7 +43,9 @@ PHP_MINFO_FUNCTION(snmp); PHP_FUNCTION(snmpget); +PHP_FUNCTION(snmpgetoid); PHP_FUNCTION(snmpgetnext); +PHP_FUNCTION(snmpgetnextoid); PHP_FUNCTION(snmpwalk); PHP_FUNCTION(snmprealwalk); PHP_FUNCTION(snmp_get_quick_print); @@ -53,13 +55,17 @@ PHP_FUNCTION(snmpset); PHP_FUNCTION(snmp2_get); +PHP_FUNCTION(snmp2_getoid); PHP_FUNCTION(snmp2_getnext); +PHP_FUNCTION(snmp2_getnextoid); PHP_FUNCTION(snmp2_walk); PHP_FUNCTION(snmp2_real_walk); PHP_FUNCTION(snmp2_set); PHP_FUNCTION(snmp3_get); +PHP_FUNCTION(snmp3_getoid); PHP_FUNCTION(snmp3_getnext); +PHP_FUNCTION(snmp3_getnextoid); PHP_FUNCTION(snmp3_walk); PHP_FUNCTION(snmp3_real_walk); PHP_FUNCTION(snmp3_set); Index: ext/snmp/snmp.c === --- ext/snmp/snmp.c (revision 303630) +++ ext/snmp/snmp.c (working copy) @@ -121,6 +121,14 @@ ZEND_ARG_INFO(0, retries) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpgetoid, 0, 0, 3) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, community) + ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retries) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpgetnext, 0, 0, 3) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, community) @@ -129,6 +137,14 @@ ZEND_ARG_INFO(0, retries) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpgetnextoid, 0, 0, 3) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, community) + ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retries) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_snmpwalk, 0, 0, 3) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, community) @@ -181,6 +197,14 @@ ZEND_ARG_INFO(0, retries) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_getoid, 0, 0, 3) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, community) + ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retries) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_getnext, 0, 0, 3) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, community) @@ -189,6 +213,14 @@ ZEND_ARG_INFO(0, retries) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_getnextoid, 0, 0, 3) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, community) + ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retries) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp2_walk, 0, 0, 3) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, community) @@ -233,6 +265,19 @@ ZEND_ARG_INFO(0, retries) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_getoid, 0, 0, 8) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, sec_name) + ZEND_ARG_INFO(0, sec_level) + ZEND_ARG_INFO(0, auth_protocol) + ZEND_ARG_INFO(0, auth_passphrase) + ZEND_ARG_INFO(0, priv_protocol) + ZEND_ARG_INFO(0, priv_passphrase) + ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retries) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_getnext, 0, 0, 8) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, sec_name) @@ -246,6 +291,19 @@ ZEND_ARG_INFO(0, retries) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_getnextoid, 0, 0, 8) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, sec_name) + ZEND_ARG_INFO(0, sec_level) + ZEND_ARG_INFO(0, auth_protocol) + ZEND_ARG_INFO(0, auth_passphrase) + ZEND_ARG_INFO(0, priv_protocol) + ZEND_ARG_INFO(0, priv_passphrase) + ZEND_ARG_INFO(0, object_id) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retries) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp3_walk, 0, 0, 8) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, sec_name) @@ -303,7 +361,9 @@ */ const zend_function_entry snmp_functions[] = { PHP_FE(snmpget, arginfo_snmpget) + PHP_FE(snmpgetoid, arginfo_snmpgetoid) PHP_FE