Thrift: TNullTransport for PHP.
Summary:
We have this in C++. Adding an implementation for PHP.
Reviewed By: mcslee
Test Plan:
Used it while testing web code.
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665292 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/php/src/transport/TNullTransport.php b/lib/php/src/transport/TNullTransport.php
new file mode 100644
index 0000000..b24cee5
--- /dev/null
+++ b/lib/php/src/transport/TNullTransport.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Copyright (c) 2006- Facebook
+ * Distributed under the Thrift Software License
+ *
+ * See accompanying file LICENSE or visit the Thrift site at:
+ * http://developers.facebook.com/thrift/
+ *
+ * @package thrift.transport
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+
+/**
+ * Transport that only accepts writes and ignores them.
+ * This is useful for measuring the serialized size of structures.
+ *
+ * @package thrift.transport
+ * @author David Reiss <dreiss@facebook.com>
+ */
+class TNullTransport extends TTransport {
+
+ public function isOpen() {
+ return true;
+ }
+
+ public function open() {}
+
+ public function close() {}
+
+ public function read($len) {
+ throw new TTransportException("Can't read from TNullTransport.");
+ }
+
+ public function write($buf) {}
+
+}
+
+?>