Skip to content

Commit

Permalink
Fixed decoding of NULL values
Browse files Browse the repository at this point in the history
  • Loading branch information
crocodile2u committed Apr 17, 2017
1 parent 262bc68 commit bf4066d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions test/EncoderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

class EncoderTest extends \PHPUnit_Framework_TestCase {
function testEncodeNull()
{
$this->assertEquals(0x00, \Zhandlersocket\Encoder::encode(null));
}
function testDecodeNull()
{
$this->assertEquals(null, \Zhandlersocket\Encoder::decode(chr(0x00)));
}
}
2 changes: 1 addition & 1 deletion zhandlersocket/Encoder.zep
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Encoder {
}

public static function decode(data) -> string|null {
if 0x00 === data {
if 0x00 === ord(data) {
return null;
}

Expand Down

0 comments on commit bf4066d

Please sign in to comment.