summaryrefslogtreecommitdiff
path: root/lib/php
diff options
context:
space:
mode:
authorRobert Lu <robberphex@gmail.com>2018-01-29 22:49:12 +0800
committerJames E. King III <jking@apache.org>2018-01-30 07:49:20 -0500
commit2471efab00fbbb674f1aba321ea466f6a86e38b6 (patch)
treecee77a07e1361a423365cfaf0c00227905b75315 /lib/php
parent12f124c19a1a9f00c1979dbd2d5aac6f01c0e248 (diff)
downloadthrift-2471efab00fbbb674f1aba321ea466f6a86e38b6.tar.gz
THRIFT-4477: php TBufferedTransport must have underlying transport
Client: php This closes #1484
Diffstat (limited to 'lib/php')
-rw-r--r--lib/php/lib/Factory/TStringFuncFactory.php5
-rw-r--r--lib/php/lib/Transport/TBufferedTransport.php48
-rw-r--r--lib/php/lib/Transport/TTransport.php1
3 files changed, 41 insertions, 13 deletions
diff --git a/lib/php/lib/Factory/TStringFuncFactory.php b/lib/php/lib/Factory/TStringFuncFactory.php
index 7739d169a..30de4d780 100644
--- a/lib/php/lib/Factory/TStringFuncFactory.php
+++ b/lib/php/lib/Factory/TStringFuncFactory.php
@@ -21,8 +21,9 @@
namespace Thrift\Factory;
-use Thrift\StringFunc\Mbstring;
use Thrift\StringFunc\Core;
+use Thrift\StringFunc\Mbstring;
+use Thrift\StringFunc\TStringFunc;
class TStringFuncFactory
{
@@ -49,7 +50,7 @@ class TStringFuncFactory
* Cannot use str* functions for byte counting because multibyte
* characters will be read a single bytes.
*
- * See: http://us.php.net/manual/en/mbstring.overload.php
+ * See: http://php.net/manual/en/mbstring.overload.php
*/
if (ini_get('mbstring.func_overload') & 2) {
self::$_instance = new Mbstring();
diff --git a/lib/php/lib/Transport/TBufferedTransport.php b/lib/php/lib/Transport/TBufferedTransport.php
index a541cbb51..253c5acfb 100644
--- a/lib/php/lib/Transport/TBufferedTransport.php
+++ b/lib/php/lib/Transport/TBufferedTransport.php
@@ -22,6 +22,7 @@
namespace Thrift\Transport;
+use Thrift\Exception\TTransportException;
use Thrift\Factory\TStringFuncFactory;
/**
@@ -34,21 +35,11 @@ use Thrift\Factory\TStringFuncFactory;
class TBufferedTransport extends TTransport
{
/**
- * Constructor. Creates a buffered transport around an underlying transport
- */
- public function __construct($transport = null, $rBufSize = 512, $wBufSize = 512)
- {
- $this->transport_ = $transport;
- $this->rBufSize_ = $rBufSize;
- $this->wBufSize_ = $wBufSize;
- }
-
- /**
* The underlying transport
*
* @var TTransport
*/
- protected $transport_ = null;
+ protected $transport_;
/**
* The receive buffer size
@@ -78,11 +69,26 @@ class TBufferedTransport extends TTransport
*/
protected $rBuf_ = '';
+ /**
+ * Constructor. Creates a buffered transport around an underlying transport
+ */
+ public function __construct($transport, $rBufSize = 512, $wBufSize = 512)
+ {
+ $this->transport_ = $transport;
+ $this->rBufSize_ = $rBufSize;
+ $this->wBufSize_ = $wBufSize;
+ }
+
public function isOpen()
{
return $this->transport_->isOpen();
}
+ /**
+ * @inheritdoc
+ *
+ * @throws TTransportException
+ */
public function open()
{
$this->transport_->open();
@@ -110,6 +116,8 @@ class TBufferedTransport extends TTransport
*
* Therefore, use the readAll method of the wrapped transport inside
* the buffered readAll.
+ *
+ * @throws TTransportException
*/
public function readAll($len)
{
@@ -131,6 +139,13 @@ class TBufferedTransport extends TTransport
return $data;
}
+ /**
+ * @inheritdoc
+ *
+ * @param int $len
+ * @return string
+ * @throws TTransportException
+ */
public function read($len)
{
if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) {
@@ -150,6 +165,12 @@ class TBufferedTransport extends TTransport
return $ret;
}
+ /**
+ * @inheritdoc
+ *
+ * @param string $buf
+ * @throws TTransportException
+ */
public function write($buf)
{
$this->wBuf_ .= $buf;
@@ -164,6 +185,11 @@ class TBufferedTransport extends TTransport
}
}
+ /**
+ * @inheritdoc
+ *
+ * @throws TTransportException
+ */
public function flush()
{
if (TStringFuncFactory::create()->strlen($this->wBuf_) > 0) {
diff --git a/lib/php/lib/Transport/TTransport.php b/lib/php/lib/Transport/TTransport.php
index df248f2cc..35921c666 100644
--- a/lib/php/lib/Transport/TTransport.php
+++ b/lib/php/lib/Transport/TTransport.php
@@ -22,6 +22,7 @@
namespace Thrift\Transport;
+use Thrift\Exception\TTransportException;
use Thrift\Factory\TStringFuncFactory;
/**