summaryrefslogtreecommitdiff
path: root/lib/php
diff options
context:
space:
mode:
authorRobert Lu <robberphex@gmail.com>2017-12-28 15:29:39 +0800
committerJames E. King, III <jking@apache.org>2018-01-11 09:37:37 -0500
commita15060acd81d72fa364a7aab327aa8c41d02958f (patch)
tree088e8e03c03a82477656ae99734535c7dd557019 /lib/php
parent19a6493ff03ee335cabe109ea6831366f3d7a701 (diff)
downloadthrift-a15060acd81d72fa364a7aab327aa8c41d02958f.tar.gz
THRIFT-4423: migrate to psr-4
Client: php This closes #1445
Diffstat (limited to 'lib/php')
-rw-r--r--lib/php/lib/Thrift/StoredMessageProtocol.php51
-rw-r--r--lib/php/lib/Thrift/TMultiplexedProcessor.php26
-rwxr-xr-xlib/php/test/Makefile.am21
-rw-r--r--lib/php/test/Test/Thrift/JsonSerialize/JsonSerializeTest.php4
-rw-r--r--lib/php/test/Test/Thrift/Protocol/TestBinarySerializer.php4
-rw-r--r--[-rwxr-xr-x]lib/php/test/Test/Thrift/Protocol/TestTJSONProtocol.php4
-rw-r--r--[-rwxr-xr-x]lib/php/test/Test/Thrift/Protocol/TestTSimpleJSONProtocol.php4
-rw-r--r--lib/php/test/Test/Thrift/TestValidators.php5
8 files changed, 68 insertions, 51 deletions
diff --git a/lib/php/lib/Thrift/StoredMessageProtocol.php b/lib/php/lib/Thrift/StoredMessageProtocol.php
new file mode 100644
index 000000000..476d9a685
--- /dev/null
+++ b/lib/php/lib/Thrift/StoredMessageProtocol.php
@@ -0,0 +1,51 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.processor
+ */
+
+namespace Thrift;
+
+use Thrift\Protocol\TProtocol;
+use Thrift\Protocol\TProtocolDecorator;
+
+/**
+ * Our goal was to work with any protocol. In order to do that, we needed
+ * to allow them to call readMessageBegin() and get the Message in exactly
+ * the standard format, without the service name prepended to the Message name.
+ */
+class StoredMessageProtocol extends TProtocolDecorator
+{
+ private $fname_, $mtype_, $rseqid_;
+
+ public function __construct(TProtocol $protocol, $fname, $mtype, $rseqid)
+ {
+ parent::__construct($protocol);
+ $this->fname_ = $fname;
+ $this->mtype_ = $mtype;
+ $this->rseqid_ = $rseqid;
+ }
+
+ public function readMessageBegin(&$name, &$type, &$seqid)
+ {
+ $name = $this->fname_;
+ $type = $this->mtype_;
+ $seqid = $this->rseqid_;
+ }
+}
diff --git a/lib/php/lib/Thrift/TMultiplexedProcessor.php b/lib/php/lib/Thrift/TMultiplexedProcessor.php
index 138f95bc4..0c2094d0c 100644
--- a/lib/php/lib/Thrift/TMultiplexedProcessor.php
+++ b/lib/php/lib/Thrift/TMultiplexedProcessor.php
@@ -25,7 +25,6 @@ namespace Thrift;
use Thrift\Exception\TException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TMultiplexedProtocol;
-use Thrift\Protocol\TProtocolDecorator;
use Thrift\Type\TMessageType;
/**
@@ -116,28 +115,3 @@ class TMultiplexedProcessor
);
}
}
-
-/**
- * Our goal was to work with any protocol. In order to do that, we needed
- * to allow them to call readMessageBegin() and get the Message in exactly
- * the standard format, without the service name prepended to the Message name.
- */
-class StoredMessageProtocol extends TProtocolDecorator
-{
- private $fname_, $mtype_, $rseqid_;
-
- public function __construct(TProtocol $protocol, $fname, $mtype, $rseqid)
- {
- parent::__construct($protocol);
- $this->fname_ = $fname;
- $this->mtype_ = $mtype;
- $this->rseqid_ = $rseqid;
- }
-
- public function readMessageBegin(&$name, &$type, &$seqid)
- {
- $name = $this->fname_;
- $type = $this->mtype_;
- $seqid = $this->rseqid_;
- }
-}
diff --git a/lib/php/test/Makefile.am b/lib/php/test/Makefile.am
index c872b1aa1..c4dcde342 100755
--- a/lib/php/test/Makefile.am
+++ b/lib/php/test/Makefile.am
@@ -17,6 +17,8 @@
# under the License.
#
+PHPUNIT=php $(top_srcdir)/vendor/bin/phpunit
+
stubs: ../../../test/ThriftTest.thrift TestValidators.thrift
mkdir -p ./packages
$(THRIFT) --gen php -r --out ./packages ../../../test/ThriftTest.thrift
@@ -27,23 +29,24 @@ stubs: ../../../test/ThriftTest.thrift TestValidators.thrift
$(THRIFT) --gen php:validate,oop -r --out ./packages/phpvo TestValidators.thrift
$(THRIFT) --gen php:json -r --out ./packages/phpjs TestValidators.thrift
-check-json-serializer: stubs
-if HAVE_PHPUNIT
+deps: $(top_srcdir)/composer.json
+ composer install --working-dir=$(top_srcdir)
+
+all-local: deps
+
+check-json-serializer: deps stubs
$(PHPUNIT) --log-junit=TEST-json-serializer.xml Test/Thrift/JsonSerialize/
-endif
-check-validator: stubs
+check-validator: deps stubs
php Test/Thrift/TestValidators.php
php Test/Thrift/TestValidators.php -oop
-check-protocol: stubs
-if HAVE_PHPUNIT
+check-protocol: deps stubs
$(PHPUNIT) --log-junit=TEST-log-json-protocol.xml Test/Thrift/Protocol/TestTJSONProtocol.php
$(PHPUNIT) --log-junit=TEST-binary-serializer.xml Test/Thrift/Protocol/TestBinarySerializer.php
$(PHPUNIT) --log-junit=TEST-log-simple-json-protocol.xml Test/Thrift/Protocol/TestTSimpleJSONProtocol.php
-endif
-check: stubs \
+check: deps stubs \
check-protocol \
check-validator \
check-json-serializer
@@ -55,5 +58,3 @@ clean-local:
EXTRA_DIST = \
Test \
TestValidators.thrift
-
-
diff --git a/lib/php/test/Test/Thrift/JsonSerialize/JsonSerializeTest.php b/lib/php/test/Test/Thrift/JsonSerialize/JsonSerializeTest.php
index 2471b520b..a6b0e7b81 100644
--- a/lib/php/test/Test/Thrift/JsonSerialize/JsonSerializeTest.php
+++ b/lib/php/test/Test/Thrift/JsonSerialize/JsonSerializeTest.php
@@ -23,11 +23,9 @@ namespace Test\Thrift\JsonSerialize;
use stdClass;
use Thrift\ClassLoader\ThriftClassLoader;
-require_once __DIR__.'/../../../../lib/Thrift/ClassLoader/ThriftClassLoader.php';
+require_once __DIR__.'/../../../../../../vendor/autoload.php';
$loader = new ThriftClassLoader();
-$loader->registerNamespace('Thrift', __DIR__ . '/../../../../lib');
-$loader->registerNamespace('Test', __DIR__ . '/../../..');
$loader->registerDefinition('ThriftTest', __DIR__ . '/../../../packages/phpjs');
$loader->register();
diff --git a/lib/php/test/Test/Thrift/Protocol/TestBinarySerializer.php b/lib/php/test/Test/Thrift/Protocol/TestBinarySerializer.php
index a9832162b..b30cf3d85 100644
--- a/lib/php/test/Test/Thrift/Protocol/TestBinarySerializer.php
+++ b/lib/php/test/Test/Thrift/Protocol/TestBinarySerializer.php
@@ -26,11 +26,9 @@ namespace Test\Thrift\Protocol;
use Thrift\ClassLoader\ThriftClassLoader;
use Thrift\Serializer\TBinarySerializer;
-require_once __DIR__.'/../../../../lib/Thrift/ClassLoader/ThriftClassLoader.php';
+require_once __DIR__.'/../../../../../../vendor/autoload.php';
$loader = new ThriftClassLoader();
-$loader->registerNamespace('Thrift', __DIR__ . '/../../../../lib');
-$loader->registerNamespace('Test', __DIR__ . '/../../..');
$loader->registerDefinition('ThriftTest', __DIR__ . '/../../../packages');
$loader->register();
diff --git a/lib/php/test/Test/Thrift/Protocol/TestTJSONProtocol.php b/lib/php/test/Test/Thrift/Protocol/TestTJSONProtocol.php
index a4ca9d573..a41b0814c 100755..100644
--- a/lib/php/test/Test/Thrift/Protocol/TestTJSONProtocol.php
+++ b/lib/php/test/Test/Thrift/Protocol/TestTJSONProtocol.php
@@ -30,11 +30,9 @@ use Thrift\Protocol\TJSONProtocol;
define( 'BUFSIZ', 8192 ); //big enough to read biggest serialized Fixture arg.
-require_once __DIR__.'/../../../../lib/Thrift/ClassLoader/ThriftClassLoader.php';
+require_once __DIR__.'/../../../../../../vendor/autoload.php';
$loader = new ThriftClassLoader();
-$loader->registerNamespace('Thrift', __DIR__ . '/../../../../lib');
-$loader->registerNamespace('Test', __DIR__ . '/../../..');
$loader->registerDefinition('ThriftTest', __DIR__ . '/../../../packages');
$loader->register();
diff --git a/lib/php/test/Test/Thrift/Protocol/TestTSimpleJSONProtocol.php b/lib/php/test/Test/Thrift/Protocol/TestTSimpleJSONProtocol.php
index 973f55cde..5a8e9e69a 100755..100644
--- a/lib/php/test/Test/Thrift/Protocol/TestTSimpleJSONProtocol.php
+++ b/lib/php/test/Test/Thrift/Protocol/TestTSimpleJSONProtocol.php
@@ -30,11 +30,9 @@ use Thrift\Protocol\TSimpleJSONProtocol;
define( 'BUFSIZ', 8192 ); //big enough to read biggest serialized Fixture arg.
-require_once __DIR__.'/../../../../lib/Thrift/ClassLoader/ThriftClassLoader.php';
+require_once __DIR__.'/../../../../../../vendor/autoload.php';
$loader = new ThriftClassLoader();
-$loader->registerNamespace('Thrift', __DIR__ . '/../../../../lib');
-$loader->registerNamespace('Test', __DIR__ . '/../../..');
$loader->registerDefinition('ThriftTest', __DIR__ . '/../../../packages');
$loader->register();
diff --git a/lib/php/test/Test/Thrift/TestValidators.php b/lib/php/test/Test/Thrift/TestValidators.php
index 36cf00099..a6c13c59f 100644
--- a/lib/php/test/Test/Thrift/TestValidators.php
+++ b/lib/php/test/Test/Thrift/TestValidators.php
@@ -18,9 +18,9 @@
* under the License.
*/
-namespace test\php;
+namespace Test\Thrift;
-require_once __DIR__.'/../../../lib/Thrift/ClassLoader/ThriftClassLoader.php';
+require_once __DIR__.'/../../../../../vendor/autoload.php';
use Thrift\ClassLoader\ThriftClassLoader;
use Thrift\Exception\TProtocolException;
@@ -31,7 +31,6 @@ $oop_mode = (isset($argv[1]) && $argv[1] === '-oop');
$GEN_DIR = $oop_mode ? 'phpvo' : 'phpv';
$loader = new ThriftClassLoader();
-$loader->registerNamespace('Thrift', __DIR__ . '/../../../lib');
$loader->registerDefinition('ThriftTest', __DIR__ . '/../../packages/' . $GEN_DIR);
$loader->registerDefinition('TestValidators', __DIR__ . '/../../packages/' . $GEN_DIR);
$loader->register();