You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ns...@apache.org on 2016/09/04 09:50:29 UTC
[02/10] thrift git commit: THRIFT-3046: Allow PSR4 class loading for
generated classes (PHP)
THRIFT-3046: Allow PSR4 class loading for generated classes (PHP)
Allow test to be used with psr4 autoloading
This closes #1010
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/d1ceba44
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/d1ceba44
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/d1ceba44
Branch: refs/heads/master
Commit: d1ceba449d3c6bb431386abc11495f21f9824238
Parents: 7b0cb9a
Author: Andreas Scheja <a....@gmail.com>
Authored: Sun May 15 21:49:04 2016 +0200
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sat Sep 3 15:58:37 2016 +0900
----------------------------------------------------------------------
test/php/Makefile.am | 4 +++-
test/php/TestClient.php | 6 +++++-
test/php/TestPsr4.php | 23 +++++++++++++++++++++++
3 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/d1ceba44/test/php/Makefile.am
----------------------------------------------------------------------
diff --git a/test/php/Makefile.am b/test/php/Makefile.am
index 11974da..7c4347f 100755
--- a/test/php/Makefile.am
+++ b/test/php/Makefile.am
@@ -22,13 +22,15 @@ THRIFT = $(top_builddir)/compiler/cpp/thrift
stubs: ../ThriftTest.thrift
$(THRIFT) --gen php ../ThriftTest.thrift
$(THRIFT) --gen php:inlined ../ThriftTest.thrift
+ $(MKDIR_P) gen-php-psr4
+ $(THRIFT) -out gen-php-psr4 --gen php:psr4 ../ThriftTest.thrift
precross: stubs
check: stubs
clean-local:
- $(RM) -r gen-php gen-phpi
+ $(RM) -r gen-php gen-phpi gen-php-psr4
client: stubs
php TestClient.php
http://git-wip-us.apache.org/repos/asf/thrift/blob/d1ceba44/test/php/TestClient.php
----------------------------------------------------------------------
diff --git a/test/php/TestClient.php b/test/php/TestClient.php
index 946334d..2443ee0 100755
--- a/test/php/TestClient.php
+++ b/test/php/TestClient.php
@@ -15,7 +15,11 @@ if (!isset($MODE)) {
$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift', __DIR__ . '/../../lib/php/lib');
-$loader->registerDefinition('ThriftTest', $GEN_DIR);
+if ($GEN_DIR === 'gen-php-psr4') {
+ $loader->registerNamespace('ThriftTest', $GEN_DIR);
+} else {
+ $loader->registerDefinition('ThriftTest', $GEN_DIR);
+}
$loader->register();
/*
http://git-wip-us.apache.org/repos/asf/thrift/blob/d1ceba44/test/php/TestPsr4.php
----------------------------------------------------------------------
diff --git a/test/php/TestPsr4.php b/test/php/TestPsr4.php
new file mode 100644
index 0000000..d30bf1c
--- /dev/null
+++ b/test/php/TestPsr4.php
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+<?php
+$GEN_DIR = 'gen-php-psr4';
+include_once('TestClient.php');
+?>