Skip to content

Commit

Permalink
Handle null
Browse files Browse the repository at this point in the history
  • Loading branch information
arokettu committed Jun 30, 2020
1 parent 9d63110 commit 5ede081
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Engine/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private function encodeValue($value): string

// process strings
// floats become strings
if (is_string($value) || is_float($value)) {
if (is_string($value) || is_float($value) || is_null($value)) {
return $this->encodeString(strval($value));
}

Expand Down
3 changes: 3 additions & 0 deletions tests/EncodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public function __toString()
return 'string';
}
}));

// null
$this->assertEquals('0:', Bencode::encode(null));
}

public function testList()
Expand Down

0 comments on commit 5ede081

Please sign in to comment.