attempt to fix #118: PHP-8.1 compat
authorMichael Wallner <mike@php.net>
Tue, 10 Aug 2021 12:41:20 +0000 (14:41 +0200)
committerMichael Wallner <mike@php.net>
Tue, 10 Aug 2021 12:41:20 +0000 (14:41 +0200)
src/php_http_client.c
src/php_http_message.c
src/php_http_misc.h
src/php_http_params.c
src/php_http_querystring.c
tests/client002.phpt
tests/client013.phpt
tests/client030.phpt
tests/envresponse016.phpt

index f1ef55d578b451aabc0d94aa8227e6a5003509b4..32679352af14b5e3ee05199c1a975c8cc9fca920 100644 (file)
@@ -804,7 +804,7 @@ static PHP_METHOD(HttpClient, requeue)
        RETVAL_ZVAL(getThis(), 1, 0);
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpClient_count, 0, 0, IS_LONG, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpClient_count, 0, 0, IS_LONG, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpClient, count)
 {
@@ -984,7 +984,11 @@ static int notify(zend_object_iterator *iter, void *puser)
        return ZEND_HASH_APPLY_STOP;
 }
 
+#if PHP_VERSION_ID >= 80100
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpClient_notify, 0, 0, IS_VOID, 0)
+#else
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_notify, 0, 0, 0)
+#endif
        ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 1)
        ZEND_ARG_INFO(0, progress)
 ZEND_END_ARG_INFO();
@@ -1028,11 +1032,16 @@ static PHP_METHOD(HttpClient, notify)
                        zval_ptr_dtor(zprogress);
                }
        }
-
+#if PHP_VERSION_ID < 80100
        RETVAL_ZVAL(getThis(), 1, 0);
+#endif
 }
 
+#if PHP_VERSION_ID >= 80100
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpClient_attach, 0, 1, IS_VOID, 0)
+#else
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_attach, 0, 0, 1)
+#endif
        ZEND_ARG_OBJ_INFO(0, observer, SplObserver, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpClient, attach)
@@ -1057,11 +1066,16 @@ static PHP_METHOD(HttpClient, attach)
        ZVAL_UNDEF(&retval);
        zend_call_method_with_1_params(Z_OBJ_P(observers), NULL, NULL, "attach", &retval, observer);
        zval_ptr_dtor(&retval);
-
+#if PHP_VERSION_ID < 80100
        RETVAL_ZVAL(getThis(), 1, 0);
+#endif
 }
 
+#if PHP_VERSION_ID >= 80100
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpClient_detach, 0, 1, IS_VOID, 0)
+#else
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_detach, 0, 0, 1)
+#endif
        ZEND_ARG_OBJ_INFO(0, observer, SplObserver, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpClient, detach)
@@ -1080,8 +1094,9 @@ static PHP_METHOD(HttpClient, detach)
        ZVAL_UNDEF(&retval);
        zend_call_method_with_1_params(Z_OBJ_P(observers), NULL, NULL, "detach", &retval, observer);
        zval_ptr_dtor(&retval);
-
+#if PHP_VERSION_ID < 80100
        RETVAL_ZVAL(getThis(), 1, 0);
+#endif
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getObservers, 0, 0, 0)
index 72870313b8575429a39e78ae04965d1f63df66c4..ac3c641968ac9a944041970fbac23b762b935492 100644 (file)
@@ -1971,7 +1971,7 @@ static PHP_METHOD(HttpMessage, splitMultipartBody)
        RETURN_OBJ(&php_http_message_object_new_ex(obj->zo.ce, msg)->zo);
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_count, 0, 0, IS_LONG, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpMessage_count, 0, 0, IS_LONG, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, count)
 {
@@ -1986,7 +1986,7 @@ static PHP_METHOD(HttpMessage, count)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_rewind, 0, 0, IS_VOID, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpMessage_rewind, 0, 0, IS_VOID, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, rewind)
 {
@@ -2001,7 +2001,7 @@ static PHP_METHOD(HttpMessage, rewind)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_valid, 0, 0, _IS_BOOL, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpMessage_valid, 0, 0, _IS_BOOL, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, valid)
 {
@@ -2012,7 +2012,7 @@ static PHP_METHOD(HttpMessage, valid)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_next, 0, 0, IS_VOID, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpMessage_next, 0, 0, IS_VOID, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, next)
 {
@@ -2036,7 +2036,7 @@ static PHP_METHOD(HttpMessage, next)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_key, 0, 0, IS_LONG, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpMessage_key, 0, 0, IS_LONG, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, key)
 {
@@ -2047,7 +2047,7 @@ static PHP_METHOD(HttpMessage, key)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(ai_HttpMessage_current, 0, 0, http\\Message, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(ai_HttpMessage_current, 0, 0, http\\Message, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, current)
 {
index 19eb75cb894276f3021452b330e413dbea2e7c61..c45ab1595aeee65c4e0dee3a16a2be9924310d39 100644 (file)
@@ -106,6 +106,10 @@ static inline const char *php_http_locate_bin_eol(const char *bin, size_t len, i
 # define php_http_mem_stream_open(type, zstr) php_stream_memory_open((type), (zstr))
 #else
 # define php_http_mem_stream_open(type, zstr) php_stream_memory_open((type), (zstr)->val, (zstr)->len)
+# define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
+                ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args)
+# define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
+                ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args)
 #endif
 
 #define HT_IS_RECURSIVE(ht) GC_IS_RECURSIVE(ht)
index 4a523cc6d1b723de13c55cbe88659c9b6575eb04..b04af042bf9a6f1b07a9577a0ca5b36b1d2c4165 100644 (file)
@@ -1181,7 +1181,7 @@ PHP_METHOD(HttpParams, toString)
        RETVAL_STR(php_http_cs2zs(buf.data, buf.used));
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetExists, 0, 1, _IS_BOOL, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetExists, 0, 1, _IS_BOOL, 0)
        ZEND_ARG_INFO(0, name)
 ZEND_END_ARG_INFO();
 PHP_METHOD(HttpParams, offsetExists)
@@ -1202,7 +1202,7 @@ PHP_METHOD(HttpParams, offsetExists)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetGet, 0, 1, IS_MIXED, 1)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetGet, 0, 1, IS_MIXED, 1)
        ZEND_ARG_INFO(0, name)
 ZEND_END_ARG_INFO();
 PHP_METHOD(HttpParams, offsetGet)
@@ -1221,7 +1221,7 @@ PHP_METHOD(HttpParams, offsetGet)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetUnset, 0, 1, IS_VOID, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetUnset, 0, 1, IS_VOID, 0)
        ZEND_ARG_INFO(0, name)
 ZEND_END_ARG_INFO();
 PHP_METHOD(HttpParams, offsetUnset)
@@ -1240,7 +1240,7 @@ PHP_METHOD(HttpParams, offsetUnset)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetSet, 0, 2, IS_VOID, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetSet, 0, 2, IS_VOID, 0)
        ZEND_ARG_INFO(0, name)
        ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO();
index 541937e3c64ecb0abad4d33b6fcadef83933cb9a..7ef5a2084a5f685d2aabed9e3007e44de31b5188 100644 (file)
@@ -617,7 +617,7 @@ PHP_METHOD(HttpQueryString, unserialize)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetGet, 0, 1, IS_MIXED, 1)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetGet, 0, 1, IS_MIXED, 1)
        ZEND_ARG_INFO(0, name)
 ZEND_END_ARG_INFO();
 PHP_METHOD(HttpQueryString, offsetGet)
@@ -639,7 +639,7 @@ PHP_METHOD(HttpQueryString, offsetGet)
        }
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetSet, 0, 2, IS_VOID, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetSet, 0, 2, IS_VOID, 0)
        ZEND_ARG_INFO(0, name)
        ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO();
@@ -664,7 +664,7 @@ PHP_METHOD(HttpQueryString, offsetSet)
        zval_ptr_dtor(&param);
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetExists, 0, 1, _IS_BOOL, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetExists, 0, 1, _IS_BOOL, 0)
        ZEND_ARG_INFO(0, name)
 ZEND_END_ARG_INFO();
 PHP_METHOD(HttpQueryString, offsetExists)
@@ -687,7 +687,7 @@ PHP_METHOD(HttpQueryString, offsetExists)
        RETURN_FALSE;
 }
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetUnset, 0, 1, IS_VOID, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetUnset, 0, 1, IS_VOID, 0)
        ZEND_ARG_INFO(0, name)
 ZEND_END_ARG_INFO();
 PHP_METHOD(HttpQueryString, offsetUnset)
index 6f01a444e97a20d72e95bb6edf1a84c26b659e5d..0da72d00ba9f0d2b2c683898314d61e03a746799 100644 (file)
@@ -14,6 +14,7 @@ echo "Test\n";
 
 class Observer implements SplObserver
 {
+       #[ReturnTypeWillChange]
        function update(SplSubject $client, http\Client\Request $request = null, StdClass $progress = null) {
                echo "P";
                if ($progress->info !== "prepare" && $client->getProgressInfo($request) != $progress) {
index 477edf7fa6d18122efbe919c5b8be69b61382ba3..962d448e5dd69a9327c6ab7a7ce7df2ec599d06c 100644 (file)
@@ -16,11 +16,13 @@ class Client extends http\Client {
        public $pi;
 }
 class ProgressObserver1 implements SplObserver {
+       #[ReturnTypeWillChange]
        function update(SplSubject $c, $r = null) {
                if ($c->getProgressInfo($r)) $c->pi .= "-";
        }
 }
 class ProgressObserver2 implements SplObserver {
+       #[ReturnTypeWillChange]
        function update(SplSubject $c, $r = null) {
                if ($c->getProgressInfo($r)) $c->pi .= ".";
        }
@@ -30,6 +32,7 @@ class CallbackObserver implements SplObserver {
        function __construct($callback) {
                $this->callback = $callback;
        }
+       #[ReturnTypeWillChange]
        function update(SplSubject $c, $r = null) {
                call_user_func($this->callback, $c, $r);
        }
index 8514b4e9e8b3d3ea3f3cb1f528a6f6758a283c3f..5a5155e1186f0620f5628eca45c7a8edd343822f 100644 (file)
@@ -12,6 +12,7 @@ echo "Test\n";
 include "helper/server.inc";
 
 class test implements SplObserver {
+       #[ReturnTypeWillChange]
        function update(SplSubject $client) {
                $client->once();
        }
index 8d48c9374276e812b3aa65eab3688aa0c76efe10..347621691e88269e4f27dd5df588b5bb6aa78e52 100644 (file)
@@ -10,7 +10,7 @@ include "skipif.inc";
 echo "Test\n";
 
 class closer extends php_user_filter {
-       function filter ($in, $out, &$consumed, $closing) {
+       function filter ($in, $out, &$consumed, $closing) : int {
                while ($bucket = stream_bucket_make_writeable($in)) {
                        stream_bucket_append($out, $bucket);
                }