From bf4066d772d39d1e5122c7684f6ce4071c186f97 Mon Sep 17 00:00:00 2001 From: Victor Bolshov Date: Mon, 17 Apr 2017 12:06:52 +0200 Subject: [PATCH] Fixed decoding of NULL values --- test/EncoderTest.php | 12 ++++++++++++ zhandlersocket/Encoder.zep | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/EncoderTest.php diff --git a/test/EncoderTest.php b/test/EncoderTest.php new file mode 100644 index 0000000..dfa5100 --- /dev/null +++ b/test/EncoderTest.php @@ -0,0 +1,12 @@ +assertEquals(0x00, \Zhandlersocket\Encoder::encode(null)); + } + function testDecodeNull() + { + $this->assertEquals(null, \Zhandlersocket\Encoder::decode(chr(0x00))); + } +} \ No newline at end of file diff --git a/zhandlersocket/Encoder.zep b/zhandlersocket/Encoder.zep index ba87465..8083445 100644 --- a/zhandlersocket/Encoder.zep +++ b/zhandlersocket/Encoder.zep @@ -34,7 +34,7 @@ class Encoder { } public static function decode(data) -> string|null { - if 0x00 === data { + if 0x00 === ord(data) { return null; }