mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-07 09:17:29 +00:00
Declare tentative return types for ext/json (#7051)
This commit is contained in:
1 parent
95d21f12e3
commit
5beba0b038
12 files changed
+16
-16
No files matched your search
@@ -18,7 +18,7 @@ enum StringFoo: string {
|
||||
enum CustomFoo implements JsonSerializable {
|
||||
case Bar;
|
||||
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): mixed {
|
||||
return 'Custom ' . $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,7 @@ Bug #66025 (Indent wrong when json_encode() called from jsonSerialize function)
|
||||
<?php
|
||||
|
||||
class Foo implements JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): mixed {
|
||||
return json_encode([1], JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ Bug #68992 (json_encode stacks exceptions thrown by JsonSerializable classes)
|
||||
<?php
|
||||
|
||||
class MyClass implements JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): mixed {
|
||||
throw new Exception('Not implemented!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ Bug #71835 (json_encode sometimes incorrectly detects recursion with JsonSeriali
|
||||
--FILE--
|
||||
<?php
|
||||
class SomeClass implements JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): mixed {
|
||||
return [get_object_vars($this)];
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ $arr = [$class];
|
||||
var_dump(json_encode($arr));
|
||||
|
||||
class SomeClass2 implements JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): mixed {
|
||||
return [(array)$this];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ var_dump($result);
|
||||
|
||||
class A implements \JsonSerializable
|
||||
{
|
||||
function jsonSerialize()
|
||||
function jsonSerialize(): mixed
|
||||
{
|
||||
return ['end' => json_decode('', true)];
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user