|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-12-20 14:46 UTC] remi@php.net
Description: ------------ When trying to overload a class, with function where parameters have ZEND_SEND_PREFER_REF Ex : Memcached::get() in version 2.2.0b1 ZEND_BEGIN_ARG_INFO_EX(arginfo_get, 0, 0, 1) ZEND_ARG_INFO(0, key) ZEND_ARG_INFO(0, cache_cb) ZEND_ARG_INFO(2, cas_token) ZEND_ARG_INFO(1, udf_flags) ZEND_END_ARG_INFO() Real use case: try to mock the class using PHPUnit for test suite. See https://github.com/symfony/symfony/issues/9797 Test script: --------------- <?php class MyMemcached extends memcached { public function get($key, $cache_cb = NULL, &$cas_token = NULL, &$udf_flags = NULL) { } } Expected result: ---------------- No error. Actual result: -------------- Strict standards: Declaration of MyMemcached::get() should be compatible with Memcached::get($key, $cache_cb = NULL, &$cas_token = NULL, &$udf_flags = NULL) in /tmp/foo.php on line 5 Patchespass-by-ref-proto-check.patch (last revision 2013-12-20 17:56 UTC by remi@php.net)pass-by-ref-recv-init.patch (last revision 2013-12-20 16:06 UTC by krakjoe@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 06:00:02 2025 UTC |
the patch is correct, what is not correct is the arg info in memcached extension. however, it is not currently possible to write the arginfo with the current macros, the correct arginfo as it is expected is: ZEND_BEGIN_ARG_INFO_EX(arginfo_get, 0, 0, 1) ZEND_ARG_INFO(0, key) { "cache_cb", sizeof("cache_cb")-1, NULL, 0, 0, 1, 0}, { "cas_token", sizeof("cas_token")-1, NULL, 0, 0, 1, 2}, { "udf_flags", sizeof("udf_flags")-1, NULL, 0, 0, 1, 2} ZEND_END_ARG_INFO() To hide the symptoms is not enough, the arg_info must reflect what is actually required, it should be parsed, and have a way to be specified in C correctly.