From b43902dbc2b9022322915232b4b7ff3921aaf091 Mon Sep 17 00:00:00 2001 From: gaobinzhan Date: Wed, 17 Mar 2021 10:29:35 +0800 Subject: [PATCH] fix: param type[json] --- src/AnnotationTag/Param.php | 2 +- tests/ParamTest.php | 2 +- tests/TestController/Param.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AnnotationTag/Param.php b/src/AnnotationTag/Param.php index 2db3925..89e63a2 100644 --- a/src/AnnotationTag/Param.php +++ b/src/AnnotationTag/Param.php @@ -277,7 +277,7 @@ public function typeCast($val) { return (bool)$val; } - case 'object': + case 'json': { return json_decode($val); } diff --git a/tests/ParamTest.php b/tests/ParamTest.php index 56a2ace..121591d 100644 --- a/tests/ParamTest.php +++ b/tests/ParamTest.php @@ -161,7 +161,7 @@ public function testParamType() 'int' => '1', 'float' => '1', 'bool' => 1, - 'object' => json_encode(['a' => 1, 'b' => 2]), + 'json' => json_encode(['a' => 1, 'b' => 2]), 'array' => [] ] ), $response); diff --git a/tests/TestController/Param.php b/tests/TestController/Param.php index 5d2eb96..a171497 100644 --- a/tests/TestController/Param.php +++ b/tests/TestController/Param.php @@ -71,16 +71,16 @@ public function notDeprecated() * @\EasySwoole\HttpAnnotation\AnnotationTag\Param(name="int",type="int") * @\EasySwoole\HttpAnnotation\AnnotationTag\Param(name="float",type="float") * @\EasySwoole\HttpAnnotation\AnnotationTag\Param(name="bool",type="bool") - * @\EasySwoole\HttpAnnotation\AnnotationTag\Param(name="object",type="object") + * @\EasySwoole\HttpAnnotation\AnnotationTag\Param(name="json",type="json") * @\EasySwoole\HttpAnnotation\AnnotationTag\Param(name="array",type="array") */ - public function paramType(string $string, int $int, float $float, bool $bool, \stdClass $object, array $array) + public function paramType(string $string, int $int, float $float, bool $bool, \stdClass $json, array $array) { if (gettype($string) !== 'string' || gettype($int) !== 'integer' || gettype($float) !== 'double' || gettype($bool) !== 'boolean' || - gettype($object) !== 'object' || + gettype($json) !== 'object' || gettype($array) !== 'array' ) {