Skip to content

Commit fb14a2d

Browse files
committed
Set class variables to null rather than unsetting them.
1 parent 1ace1b8 commit fb14a2d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/EdgeTelemetrics/JSON_RPC/Response.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace EdgeTelemetrics\JSON_RPC;
44

5-
class Response implements \JsonSerializable {
5+
use \JsonSerializable;
6+
use \RuntimeException;
7+
8+
class Response implements JsonSerializable {
69

710
const JSONRPC_VERSION = '2.0';
811

@@ -11,7 +14,7 @@ class Response implements \JsonSerializable {
1114
*/
1215
protected $id;
1316

14-
protected $result;
17+
protected $result = null;
1518

1619
/**
1720
* @var Error
@@ -31,7 +34,7 @@ public function getId()
3134
public function setResult($result)
3235
{
3336
$this->result = $result;
34-
unset($this->error); //Error must not exist if call is successful
37+
$this->error = null; //Error must not exist if call is successful
3538
}
3639

3740
public function getResult()
@@ -47,7 +50,7 @@ public function isSuccess()
4750
public function setError(Error $error)
4851
{
4952
$this->error = $error;
50-
unset($this->result); //Result must not exist if an error is set
53+
$this->result = null; //Result must not exist if an error is set
5154
}
5255

5356
public function getError()
@@ -77,7 +80,7 @@ public function jsonSerialize()
7780
}
7881
else
7982
{
80-
throw new \RuntimeException('Response must be successful or error state');
83+
throw new RuntimeException('Response must be successful or error state');
8184
}
8285
return $record;
8386
}

0 commit comments

Comments
 (0)