From 87022e135898ebb45b07ef6b5c25c401b6fab98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Thu, 27 May 2021 00:07:36 +0200 Subject: [PATCH] Declare tentative return types for ext/json --- Zend/tests/enum/json_encode.phpt | 2 +- ext/json/json.stub.php | 4 ++-- ext/json/json_arginfo.h | 4 ++-- ext/json/tests/bug61978.phpt | 2 +- ext/json/tests/bug66025.phpt | 2 +- ext/json/tests/bug68992.phpt | 2 +- ext/json/tests/bug71835.phpt | 4 ++-- ext/json/tests/bug72069.phpt | 2 +- ext/json/tests/bug73113.phpt | 2 +- ext/json/tests/bug77843.phpt | 2 +- ext/json/tests/serialize.phpt | 6 +++--- .../get_object_vars_variation_004.phpt | Bin 763 -> 791 bytes 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Zend/tests/enum/json_encode.phpt b/Zend/tests/enum/json_encode.phpt index 016ca6107fee1..12ed0d3d445ab 100644 --- a/Zend/tests/enum/json_encode.phpt +++ b/Zend/tests/enum/json_encode.phpt @@ -18,7 +18,7 @@ enum StringFoo: string { enum CustomFoo implements JsonSerializable { case Bar; - public function jsonSerialize() { + public function jsonSerialize(): mixed { return 'Custom ' . $this->name; } } diff --git a/ext/json/json.stub.php b/ext/json/json.stub.php index 5b0d72cef27e2..f819af71f9b54 100644 --- a/ext/json/json.stub.php +++ b/ext/json/json.stub.php @@ -12,8 +12,8 @@ function json_last_error_msg(): string {} interface JsonSerializable { - /** @return mixed */ - public function jsonSerialize(); + /** @tentative-return-type */ + public function jsonSerialize(): mixed; } class JsonException extends Exception diff --git a/ext/json/json_arginfo.h b/ext/json/json_arginfo.h index ee8954c3ed379..447ea568a4fd3 100644 --- a/ext/json/json_arginfo.h +++ b/ext/json/json_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 6dcef13e46c3dfc2546d3ccc38da07e6c009bbe5 */ + * Stub hash: d6577c7d27442643c86e51d462f51dd6e677d509 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_json_encode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) @@ -20,7 +20,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_json_last_error_msg, 0, 0, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_JsonSerializable_jsonSerialize, 0, 0, 0) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_JsonSerializable_jsonSerialize, 0, 0, IS_MIXED, 0) ZEND_END_ARG_INFO() diff --git a/ext/json/tests/bug61978.phpt b/ext/json/tests/bug61978.phpt index 8853bdbbd280f..283432f8773b6 100644 --- a/ext/json/tests/bug61978.phpt +++ b/ext/json/tests/bug61978.phpt @@ -17,7 +17,7 @@ class JsonTest2 implements JsonSerializable { public function __construct() { $this->test = '123'; } - public function jsonSerialize() { + public function jsonSerialize(): mixed { return array( 'test' => $this->test, 'me' => $this diff --git a/ext/json/tests/bug66025.phpt b/ext/json/tests/bug66025.phpt index 8f12fa40ca0fa..628adefc65115 100644 --- a/ext/json/tests/bug66025.phpt +++ b/ext/json/tests/bug66025.phpt @@ -4,7 +4,7 @@ Bug #66025 (Indent wrong when json_encode() called from jsonSerialize function) json_decode('', true)]; } diff --git a/ext/json/tests/bug73113.phpt b/ext/json/tests/bug73113.phpt index 36d78ffdd4d11..d22b0c23f71b5 100644 --- a/ext/json/tests/bug73113.phpt +++ b/ext/json/tests/bug73113.phpt @@ -6,7 +6,7 @@ Also test that the custom exception is not wrapped by ext/json class JsonSerializableObject implements \JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): mixed { throw new \Exception('This error is expected'); } diff --git a/ext/json/tests/bug77843.phpt b/ext/json/tests/bug77843.phpt index c525285bf5abd..2709612659c61 100644 --- a/ext/json/tests/bug77843.phpt +++ b/ext/json/tests/bug77843.phpt @@ -5,7 +5,7 @@ Bug #77843: Use after free with json serializer class X implements JsonSerializable { public $prop = "value"; - public function jsonSerialize() { + public function jsonSerialize(): mixed { global $arr; unset($arr[0]); var_dump($this); diff --git a/ext/json/tests/serialize.phpt b/ext/json/tests/serialize.phpt index 288e3f6733763..31b36221ef9e6 100644 --- a/ext/json/tests/serialize.phpt +++ b/ext/json/tests/serialize.phpt @@ -17,7 +17,7 @@ class NonSerializingTest class SerializingTest extends NonSerializingTest implements JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): mixed { return $this->data; } @@ -25,7 +25,7 @@ class SerializingTest extends NonSerializingTest implements JsonSerializable class ValueSerializingTest extends SerializingTest { - public function jsonSerialize() + public function jsonSerialize(): mixed { return array_values(is_array($this->data) ? $this->data : get_object_vars($this->data)); } @@ -33,7 +33,7 @@ class ValueSerializingTest extends SerializingTest class SelfSerializingTest extends SerializingTest { - public function jsonSerialize() + public function jsonSerialize(): mixed { return $this; } diff --git a/ext/standard/tests/class_object/get_object_vars_variation_004.phpt b/ext/standard/tests/class_object/get_object_vars_variation_004.phpt index 902149ea0ac4cf780798c9ae4ca6d1063ca31d89..7c21b903adfc021c13bdca9b8d03d58fb59c6fc5 100644 GIT binary patch delta 40 ucmey(I-PBU79+crLT+Y7YRY6SMr(crASg;LDJ{xV$Scjs*&NR}hY