168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
--------------------------------------------------------------------------------
/GPBMetadata/User.php:
--------------------------------------------------------------------------------
1 | internalAddGeneratedFile(hex2bin(
18 | "0a8f030a0a757365722e70726f746f120673696d706c6522200a0e476574" .
19 | "5573657252657175657374120e0a0675736572696418012001280322510a" .
20 | "0f47657455736572526573706f6e7365120e0a0675736572696418012001" .
21 | "280312100a08757365726e616d65180220012809121c0a03736578180320" .
22 | "01280e320f2e73696d706c652e5573657253657822140a12476574557365" .
23 | "724c6973745265717565737422390a10557365724c697374526573706f6e" .
24 | "736512250a046c69737418012003280b32172e73696d706c652e47657455" .
25 | "736572526573706f6e73652a1d0a075573657253657812070a034d454e10" .
26 | "0012090a05574f4d454e1001328b010a0455736572123c0a074765745573" .
27 | "657212162e73696d706c652e47657455736572526571756573741a172e73" .
28 | "696d706c652e47657455736572526573706f6e7365220012450a0b476574" .
29 | "557365724c697374121a2e73696d706c652e476574557365724c69737452" .
30 | "6571756573741a182e73696d706c652e557365724c697374526573706f6e" .
31 | "73652200620670726f746f33"
32 | ), true);
33 |
34 | static::$is_initialized = true;
35 | }
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | > 以前的实例请到 v0.1 版本: https://github.com/laixhe/php_grpc/tree/v0.1
3 |
4 | ## 让 PHP 搞定 gRPC 不是难事
5 | > https://gitbook.cn/gitchat/activity/5dc9559d0b93ef713b21928c
6 |
7 | #### server 是服务端 127.0.0.1:50051
8 | #### grpc_php_plugin 是 php 的 grpc 生成插件 (下载和编译比较长这里提拱了)
9 | #### 这两个文件 必须赋于执行权限,可使用命令 chmod 0755 server 和 chmod 0755 grpc_php_plugin
10 |
11 | #### 相关:
12 | ```
13 | protoc --php_out=. --grpc_out=. --plugin=protoc-gen-grpc=/xxx/xxx/grpc_php_plugin *.proto
14 | ```
--------------------------------------------------------------------------------
/Simple/GetUserListRequest.php:
--------------------------------------------------------------------------------
1 | simple.GetUserListRequest
15 | */
16 | class GetUserListRequest extends \Google\Protobuf\Internal\Message
17 | {
18 |
19 | /**
20 | * Constructor.
21 | *
22 | * @param array $data {
23 | * Optional. Data for populating the Message object.
24 | *
25 | * }
26 | */
27 | public function __construct($data = NULL) {
28 | \GPBMetadata\User::initOnce();
29 | parent::__construct($data);
30 | }
31 |
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/Simple/GetUserRequest.php:
--------------------------------------------------------------------------------
1 | simple.GetUserRequest
15 | */
16 | class GetUserRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Generated from protobuf field int64 userid = 1;
20 | */
21 | private $userid = 0;
22 |
23 | /**
24 | * Constructor.
25 | *
26 | * @param array $data {
27 | * Optional. Data for populating the Message object.
28 | *
29 | * @type int|string $userid
30 | * }
31 | */
32 | public function __construct($data = NULL) {
33 | \GPBMetadata\User::initOnce();
34 | parent::__construct($data);
35 | }
36 |
37 | /**
38 | * Generated from protobuf field int64 userid = 1;
39 | * @return int|string
40 | */
41 | public function getUserid()
42 | {
43 | return $this->userid;
44 | }
45 |
46 | /**
47 | * Generated from protobuf field int64 userid = 1;
48 | * @param int|string $var
49 | * @return $this
50 | */
51 | public function setUserid($var)
52 | {
53 | GPBUtil::checkInt64($var);
54 | $this->userid = $var;
55 |
56 | return $this;
57 | }
58 |
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/Simple/GetUserResponse.php:
--------------------------------------------------------------------------------
1 | simple.GetUserResponse
15 | */
16 | class GetUserResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Generated from protobuf field int64 userid = 1;
20 | */
21 | private $userid = 0;
22 | /**
23 | * Generated from protobuf field string username = 2;
24 | */
25 | private $username = '';
26 | /**
27 | * Generated from protobuf field .simple.UserSex sex = 3;
28 | */
29 | private $sex = 0;
30 |
31 | /**
32 | * Constructor.
33 | *
34 | * @param array $data {
35 | * Optional. Data for populating the Message object.
36 | *
37 | * @type int|string $userid
38 | * @type string $username
39 | * @type int $sex
40 | * }
41 | */
42 | public function __construct($data = NULL) {
43 | \GPBMetadata\User::initOnce();
44 | parent::__construct($data);
45 | }
46 |
47 | /**
48 | * Generated from protobuf field int64 userid = 1;
49 | * @return int|string
50 | */
51 | public function getUserid()
52 | {
53 | return $this->userid;
54 | }
55 |
56 | /**
57 | * Generated from protobuf field int64 userid = 1;
58 | * @param int|string $var
59 | * @return $this
60 | */
61 | public function setUserid($var)
62 | {
63 | GPBUtil::checkInt64($var);
64 | $this->userid = $var;
65 |
66 | return $this;
67 | }
68 |
69 | /**
70 | * Generated from protobuf field string username = 2;
71 | * @return string
72 | */
73 | public function getUsername()
74 | {
75 | return $this->username;
76 | }
77 |
78 | /**
79 | * Generated from protobuf field string username = 2;
80 | * @param string $var
81 | * @return $this
82 | */
83 | public function setUsername($var)
84 | {
85 | GPBUtil::checkString($var, True);
86 | $this->username = $var;
87 |
88 | return $this;
89 | }
90 |
91 | /**
92 | * Generated from protobuf field .simple.UserSex sex = 3;
93 | * @return int
94 | */
95 | public function getSex()
96 | {
97 | return $this->sex;
98 | }
99 |
100 | /**
101 | * Generated from protobuf field .simple.UserSex sex = 3;
102 | * @param int $var
103 | * @return $this
104 | */
105 | public function setSex($var)
106 | {
107 | GPBUtil::checkEnum($var, \Simple\UserSex::class);
108 | $this->sex = $var;
109 |
110 | return $this;
111 | }
112 |
113 | }
114 |
115 |
--------------------------------------------------------------------------------
/Simple/UserClient.php:
--------------------------------------------------------------------------------
1 | _simpleRequest('/simple.User/GetUser',
29 | $argument,
30 | ['\Simple\GetUserResponse', 'decode'],
31 | $metadata, $options);
32 | }
33 |
34 | /**
35 | * 定义 GetUserList 方法 - 获取 user 所有数据
36 | * @param \Simple\GetUserListRequest $argument input argument
37 | * @param array $metadata metadata
38 | * @param array $options call options
39 | */
40 | public function GetUserList(\Simple\GetUserListRequest $argument,
41 | $metadata = [], $options = []) {
42 | return $this->_simpleRequest('/simple.User/GetUserList',
43 | $argument,
44 | ['\Simple\UserListResponse', 'decode'],
45 | $metadata, $options);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/Simple/UserListResponse.php:
--------------------------------------------------------------------------------
1 | simple.UserListResponse
15 | */
16 | class UserListResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * repeated 重复(数组)
20 | *
21 | * Generated from protobuf field repeated .simple.GetUserResponse list = 1;
22 | */
23 | private $list;
24 |
25 | /**
26 | * Constructor.
27 | *
28 | * @param array $data {
29 | * Optional. Data for populating the Message object.
30 | *
31 | * @type \Simple\GetUserResponse[]|\Google\Protobuf\Internal\RepeatedField $list
32 | * repeated 重复(数组)
33 | * }
34 | */
35 | public function __construct($data = NULL) {
36 | \GPBMetadata\User::initOnce();
37 | parent::__construct($data);
38 | }
39 |
40 | /**
41 | * repeated 重复(数组)
42 | *
43 | * Generated from protobuf field repeated .simple.GetUserResponse list = 1;
44 | * @return \Google\Protobuf\Internal\RepeatedField
45 | */
46 | public function getList()
47 | {
48 | return $this->list;
49 | }
50 |
51 | /**
52 | * repeated 重复(数组)
53 | *
54 | * Generated from protobuf field repeated .simple.GetUserResponse list = 1;
55 | * @param \Simple\GetUserResponse[]|\Google\Protobuf\Internal\RepeatedField $var
56 | * @return $this
57 | */
58 | public function setList($var)
59 | {
60 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Simple\GetUserResponse::class);
61 | $this->list = $arr;
62 |
63 | return $this;
64 | }
65 |
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/Simple/UserSex.php:
--------------------------------------------------------------------------------
1 | simple.UserSex
13 | */
14 | class UserSex
15 | {
16 | /**
17 | * Generated from protobuf enum MEN = 0;
18 | */
19 | const MEN = 0;
20 | /**
21 | * Generated from protobuf enum WOMEN = 1;
22 | */
23 | const WOMEN = 1;
24 |
25 | private static $valueToName = [
26 | self::MEN => 'MEN',
27 | self::WOMEN => 'WOMEN',
28 | ];
29 |
30 | public static function name($value)
31 | {
32 | if (!isset(self::$valueToName[$value])) {
33 | throw new UnexpectedValueException(sprintf(
34 | 'Enum %s has no name defined for value %s', __CLASS__, $value));
35 | }
36 | return self::$valueToName[$value];
37 | }
38 |
39 |
40 | public static function value($name)
41 | {
42 | $const = __CLASS__ . '::' . strtoupper($name);
43 | if (!defined($const)) {
44 | throw new UnexpectedValueException(sprintf(
45 | 'Enum %s has no value defined for name %s', __CLASS__, $name));
46 | }
47 | return constant($const);
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "grpc/grpc": "^1.25"
4 | },
5 | "autoload":{
6 | "psr-4":{
7 | "GPBMetadata\\":"GPBMetadata/",
8 | "Simple\\":"Simple/"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 | "This file is @generated automatically"
6 | ],
7 | "hash": "3315ca46ba25869fd945f196ab65578c",
8 | "content-hash": "1bdc07046c34467d70369ab3ab36dc8d",
9 | "packages": [
10 | {
11 | "name": "grpc/grpc",
12 | "version": "1.25.0",
13 | "source": {
14 | "type": "git",
15 | "url": "https://github.com/grpc/grpc-php.git",
16 | "reference": "bdb165d6712db0cfcc35edae2d14fb2b00cabc88"
17 | },
18 | "dist": {
19 | "type": "zip",
20 | "url": "https://api.github.com/repos/grpc/grpc-php/zipball/bdb165d6712db0cfcc35edae2d14fb2b00cabc88",
21 | "reference": "bdb165d6712db0cfcc35edae2d14fb2b00cabc88",
22 | "shasum": ""
23 | },
24 | "require": {
25 | "php": ">=5.5.0"
26 | },
27 | "require-dev": {
28 | "google/auth": "^v1.3.0"
29 | },
30 | "suggest": {
31 | "ext-protobuf": "For better performance, install the protobuf C extension.",
32 | "google/protobuf": "To get started using grpc quickly, install the native protobuf library."
33 | },
34 | "type": "library",
35 | "autoload": {
36 | "psr-4": {
37 | "Grpc\\": "src/lib/"
38 | }
39 | },
40 | "notification-url": "https://packagist.org/downloads/",
41 | "license": [
42 | "Apache-2.0"
43 | ],
44 | "description": "gRPC library for PHP",
45 | "homepage": "https://grpc.io",
46 | "keywords": [
47 | "rpc"
48 | ],
49 | "time": "2019-11-07 00:47:40"
50 | }
51 | ],
52 | "packages-dev": [],
53 | "aliases": [],
54 | "minimum-stability": "stable",
55 | "stability-flags": [],
56 | "prefer-stable": false,
57 | "prefer-lowest": false,
58 | "platform": [],
59 | "platform-dev": []
60 | }
61 |
--------------------------------------------------------------------------------
/grpc_php_plugin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/laixhe/php_grpc/a95ad7ebe66865015ca80aaa2619ee67c10c9015/grpc_php_plugin
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 | Grpc\ChannelCredentials::createInsecure()
8 | ]);
9 |
10 |
11 | // 实例化 GetUserRequest 请求类
12 | $request = new Simple\GetUserRequest();
13 | $request->setUserid(1);
14 |
15 | // 调用远程服务
16 | // 获取某个 user 数据 - 返回数组
17 | $get = $client->GetUser($request)->wait();
18 |
19 | // $user 是 GetUserResponse 对象
20 | // $status 是 记录 grpc 错误信息 对象
21 | list($user, $status) = $get;
22 |
23 | if($status->code == 0){
24 | echo 'user_id=', $user->getUserid(), "\n";
25 | echo 'user_name=', $user->getUsername(), "\n";
26 | echo 'sex=', $user->getSex(), "\n";
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/server:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/laixhe/php_grpc/a95ad7ebe66865015ca80aaa2619ee67c10c9015/server
--------------------------------------------------------------------------------
/user.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3"; // 指定proto版本
2 |
3 | package simple; // 指定包名
4 |
5 |
6 | // 定义 User 服务
7 | service User {
8 | // 定义 GetUser 方法 - 获取某个 user 数据
9 | rpc GetUser(GetUserRequest) returns (GetUserResponse) {}
10 | // 定义 GetUserList 方法 - 获取 user 所有数据
11 | rpc GetUserList(GetUserListRequest) returns (UserListResponse) {}
12 | }
13 |
14 | // 枚举类型第一个字段必须为 0
15 | enum UserSex {
16 | MEN = 0;
17 | WOMEN = 1;
18 | }
19 |
20 | // GetUser 请求结构
21 | message GetUserRequest {
22 | int64 userid = 1;
23 | }
24 |
25 | // GetUser 响应结构
26 | message GetUserResponse {
27 | int64 userid = 1;
28 | string username = 2;
29 | UserSex sex = 3;
30 | }
31 |
32 | // GetUserList 请求结构
33 | message GetUserListRequest {}
34 |
35 | // 响应结构
36 | message UserListResponse {
37 | // repeated 重复(数组)
38 | repeated GetUserResponse list = 1;
39 | }
40 |
--------------------------------------------------------------------------------
/vendor/autoload.php:
--------------------------------------------------------------------------------
1 |
7 | * Jordi Boggiano
8 | *
9 | * For the full copyright and license information, please view the LICENSE
10 | * file that was distributed with this source code.
11 | */
12 |
13 | namespace Composer\Autoload;
14 |
15 | /**
16 | * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17 | *
18 | * $loader = new \Composer\Autoload\ClassLoader();
19 | *
20 | * // register classes with namespaces
21 | * $loader->add('Symfony\Component', __DIR__.'/component');
22 | * $loader->add('Symfony', __DIR__.'/framework');
23 | *
24 | * // activate the autoloader
25 | * $loader->register();
26 | *
27 | * // to enable searching the include path (eg. for PEAR packages)
28 | * $loader->setUseIncludePath(true);
29 | *
30 | * In this example, if you try to use a class in the Symfony\Component
31 | * namespace or one of its children (Symfony\Component\Console for instance),
32 | * the autoloader will first look for the class under the component/
33 | * directory, and it will then fallback to the framework/ directory if not
34 | * found before giving up.
35 | *
36 | * This class is loosely based on the Symfony UniversalClassLoader.
37 | *
38 | * @author Fabien Potencier
39 | * @author Jordi Boggiano
40 | * @see http://www.php-fig.org/psr/psr-0/
41 | * @see http://www.php-fig.org/psr/psr-4/
42 | */
43 | class ClassLoader
44 | {
45 | // PSR-4
46 | private $prefixLengthsPsr4 = array();
47 | private $prefixDirsPsr4 = array();
48 | private $fallbackDirsPsr4 = array();
49 |
50 | // PSR-0
51 | private $prefixesPsr0 = array();
52 | private $fallbackDirsPsr0 = array();
53 |
54 | private $useIncludePath = false;
55 | private $classMap = array();
56 |
57 | private $classMapAuthoritative = false;
58 |
59 | public function getPrefixes()
60 | {
61 | if (!empty($this->prefixesPsr0)) {
62 | return call_user_func_array('array_merge', $this->prefixesPsr0);
63 | }
64 |
65 | return array();
66 | }
67 |
68 | public function getPrefixesPsr4()
69 | {
70 | return $this->prefixDirsPsr4;
71 | }
72 |
73 | public function getFallbackDirs()
74 | {
75 | return $this->fallbackDirsPsr0;
76 | }
77 |
78 | public function getFallbackDirsPsr4()
79 | {
80 | return $this->fallbackDirsPsr4;
81 | }
82 |
83 | public function getClassMap()
84 | {
85 | return $this->classMap;
86 | }
87 |
88 | /**
89 | * @param array $classMap Class to filename map
90 | */
91 | public function addClassMap(array $classMap)
92 | {
93 | if ($this->classMap) {
94 | $this->classMap = array_merge($this->classMap, $classMap);
95 | } else {
96 | $this->classMap = $classMap;
97 | }
98 | }
99 |
100 | /**
101 | * Registers a set of PSR-0 directories for a given prefix, either
102 | * appending or prepending to the ones previously set for this prefix.
103 | *
104 | * @param string $prefix The prefix
105 | * @param array|string $paths The PSR-0 root directories
106 | * @param bool $prepend Whether to prepend the directories
107 | */
108 | public function add($prefix, $paths, $prepend = false)
109 | {
110 | if (!$prefix) {
111 | if ($prepend) {
112 | $this->fallbackDirsPsr0 = array_merge(
113 | (array) $paths,
114 | $this->fallbackDirsPsr0
115 | );
116 | } else {
117 | $this->fallbackDirsPsr0 = array_merge(
118 | $this->fallbackDirsPsr0,
119 | (array) $paths
120 | );
121 | }
122 |
123 | return;
124 | }
125 |
126 | $first = $prefix[0];
127 | if (!isset($this->prefixesPsr0[$first][$prefix])) {
128 | $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129 |
130 | return;
131 | }
132 | if ($prepend) {
133 | $this->prefixesPsr0[$first][$prefix] = array_merge(
134 | (array) $paths,
135 | $this->prefixesPsr0[$first][$prefix]
136 | );
137 | } else {
138 | $this->prefixesPsr0[$first][$prefix] = array_merge(
139 | $this->prefixesPsr0[$first][$prefix],
140 | (array) $paths
141 | );
142 | }
143 | }
144 |
145 | /**
146 | * Registers a set of PSR-4 directories for a given namespace, either
147 | * appending or prepending to the ones previously set for this namespace.
148 | *
149 | * @param string $prefix The prefix/namespace, with trailing '\\'
150 | * @param array|string $paths The PSR-4 base directories
151 | * @param bool $prepend Whether to prepend the directories
152 | *
153 | * @throws \InvalidArgumentException
154 | */
155 | public function addPsr4($prefix, $paths, $prepend = false)
156 | {
157 | if (!$prefix) {
158 | // Register directories for the root namespace.
159 | if ($prepend) {
160 | $this->fallbackDirsPsr4 = array_merge(
161 | (array) $paths,
162 | $this->fallbackDirsPsr4
163 | );
164 | } else {
165 | $this->fallbackDirsPsr4 = array_merge(
166 | $this->fallbackDirsPsr4,
167 | (array) $paths
168 | );
169 | }
170 | } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
171 | // Register directories for a new namespace.
172 | $length = strlen($prefix);
173 | if ('\\' !== $prefix[$length - 1]) {
174 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
175 | }
176 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
177 | $this->prefixDirsPsr4[$prefix] = (array) $paths;
178 | } elseif ($prepend) {
179 | // Prepend directories for an already registered namespace.
180 | $this->prefixDirsPsr4[$prefix] = array_merge(
181 | (array) $paths,
182 | $this->prefixDirsPsr4[$prefix]
183 | );
184 | } else {
185 | // Append directories for an already registered namespace.
186 | $this->prefixDirsPsr4[$prefix] = array_merge(
187 | $this->prefixDirsPsr4[$prefix],
188 | (array) $paths
189 | );
190 | }
191 | }
192 |
193 | /**
194 | * Registers a set of PSR-0 directories for a given prefix,
195 | * replacing any others previously set for this prefix.
196 | *
197 | * @param string $prefix The prefix
198 | * @param array|string $paths The PSR-0 base directories
199 | */
200 | public function set($prefix, $paths)
201 | {
202 | if (!$prefix) {
203 | $this->fallbackDirsPsr0 = (array) $paths;
204 | } else {
205 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206 | }
207 | }
208 |
209 | /**
210 | * Registers a set of PSR-4 directories for a given namespace,
211 | * replacing any others previously set for this namespace.
212 | *
213 | * @param string $prefix The prefix/namespace, with trailing '\\'
214 | * @param array|string $paths The PSR-4 base directories
215 | *
216 | * @throws \InvalidArgumentException
217 | */
218 | public function setPsr4($prefix, $paths)
219 | {
220 | if (!$prefix) {
221 | $this->fallbackDirsPsr4 = (array) $paths;
222 | } else {
223 | $length = strlen($prefix);
224 | if ('\\' !== $prefix[$length - 1]) {
225 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
226 | }
227 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
228 | $this->prefixDirsPsr4[$prefix] = (array) $paths;
229 | }
230 | }
231 |
232 | /**
233 | * Turns on searching the include path for class files.
234 | *
235 | * @param bool $useIncludePath
236 | */
237 | public function setUseIncludePath($useIncludePath)
238 | {
239 | $this->useIncludePath = $useIncludePath;
240 | }
241 |
242 | /**
243 | * Can be used to check if the autoloader uses the include path to check
244 | * for classes.
245 | *
246 | * @return bool
247 | */
248 | public function getUseIncludePath()
249 | {
250 | return $this->useIncludePath;
251 | }
252 |
253 | /**
254 | * Turns off searching the prefix and fallback directories for classes
255 | * that have not been registered with the class map.
256 | *
257 | * @param bool $classMapAuthoritative
258 | */
259 | public function setClassMapAuthoritative($classMapAuthoritative)
260 | {
261 | $this->classMapAuthoritative = $classMapAuthoritative;
262 | }
263 |
264 | /**
265 | * Should class lookup fail if not found in the current class map?
266 | *
267 | * @return bool
268 | */
269 | public function isClassMapAuthoritative()
270 | {
271 | return $this->classMapAuthoritative;
272 | }
273 |
274 | /**
275 | * Registers this instance as an autoloader.
276 | *
277 | * @param bool $prepend Whether to prepend the autoloader or not
278 | */
279 | public function register($prepend = false)
280 | {
281 | spl_autoload_register(array($this, 'loadClass'), true, $prepend);
282 | }
283 |
284 | /**
285 | * Unregisters this instance as an autoloader.
286 | */
287 | public function unregister()
288 | {
289 | spl_autoload_unregister(array($this, 'loadClass'));
290 | }
291 |
292 | /**
293 | * Loads the given class or interface.
294 | *
295 | * @param string $class The name of the class
296 | * @return bool|null True if loaded, null otherwise
297 | */
298 | public function loadClass($class)
299 | {
300 | if ($file = $this->findFile($class)) {
301 | includeFile($file);
302 |
303 | return true;
304 | }
305 | }
306 |
307 | /**
308 | * Finds the path to the file where the class is defined.
309 | *
310 | * @param string $class The name of the class
311 | *
312 | * @return string|false The path if found, false otherwise
313 | */
314 | public function findFile($class)
315 | {
316 | // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317 | if ('\\' == $class[0]) {
318 | $class = substr($class, 1);
319 | }
320 |
321 | // class map lookup
322 | if (isset($this->classMap[$class])) {
323 | return $this->classMap[$class];
324 | }
325 | if ($this->classMapAuthoritative) {
326 | return false;
327 | }
328 |
329 | $file = $this->findFileWithExtension($class, '.php');
330 |
331 | // Search for Hack files if we are running on HHVM
332 | if ($file === null && defined('HHVM_VERSION')) {
333 | $file = $this->findFileWithExtension($class, '.hh');
334 | }
335 |
336 | if ($file === null) {
337 | // Remember that this class does not exist.
338 | return $this->classMap[$class] = false;
339 | }
340 |
341 | return $file;
342 | }
343 |
344 | private function findFileWithExtension($class, $ext)
345 | {
346 | // PSR-4 lookup
347 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
348 |
349 | $first = $class[0];
350 | if (isset($this->prefixLengthsPsr4[$first])) {
351 | foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
352 | if (0 === strpos($class, $prefix)) {
353 | foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
354 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
355 | return $file;
356 | }
357 | }
358 | }
359 | }
360 | }
361 |
362 | // PSR-4 fallback dirs
363 | foreach ($this->fallbackDirsPsr4 as $dir) {
364 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
365 | return $file;
366 | }
367 | }
368 |
369 | // PSR-0 lookup
370 | if (false !== $pos = strrpos($class, '\\')) {
371 | // namespaced class name
372 | $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
373 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
374 | } else {
375 | // PEAR-like class name
376 | $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
377 | }
378 |
379 | if (isset($this->prefixesPsr0[$first])) {
380 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
381 | if (0 === strpos($class, $prefix)) {
382 | foreach ($dirs as $dir) {
383 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
384 | return $file;
385 | }
386 | }
387 | }
388 | }
389 | }
390 |
391 | // PSR-0 fallback dirs
392 | foreach ($this->fallbackDirsPsr0 as $dir) {
393 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
394 | return $file;
395 | }
396 | }
397 |
398 | // PSR-0 include paths.
399 | if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400 | return $file;
401 | }
402 | }
403 | }
404 |
405 | /**
406 | * Scope isolated include.
407 | *
408 | * Prevents access to $this/self from included files.
409 | */
410 | function includeFile($file)
411 | {
412 | include $file;
413 | }
414 |
--------------------------------------------------------------------------------
/vendor/composer/LICENSE:
--------------------------------------------------------------------------------
1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2 | Upstream-Name: Composer
3 | Upstream-Contact: Jordi Boggiano
4 | Source: https://github.com/composer/composer
5 |
6 | Files: *
7 | Copyright: 2016, Nils Adermann
8 | 2016, Jordi Boggiano
9 | License: Expat
10 |
11 | Files: res/cacert.pem
12 | Copyright: 2015, Mozilla Foundation
13 | License: MPL-2.0
14 |
15 | Files: src/Composer/Util/RemoteFilesystem.php
16 | src/Composer/Util/TlsHelper.php
17 | Copyright: 2016, Nils Adermann
18 | 2016, Jordi Boggiano
19 | 2013, Evan Coury
20 | License: Expat and BSD-2-Clause
21 |
22 | License: BSD-2-Clause
23 | Redistribution and use in source and binary forms, with or without modification,
24 | are permitted provided that the following conditions are met:
25 | .
26 | * Redistributions of source code must retain the above copyright notice,
27 | this list of conditions and the following disclaimer.
28 | .
29 | * Redistributions in binary form must reproduce the above copyright notice,
30 | this list of conditions and the following disclaimer in the documentation
31 | and/or other materials provided with the distribution.
32 | .
33 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
37 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
40 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 |
44 | License: Expat
45 | Permission is hereby granted, free of charge, to any person obtaining a copy
46 | of this software and associated documentation files (the "Software"), to deal
47 | in the Software without restriction, including without limitation the rights
48 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49 | copies of the Software, and to permit persons to whom the Software is furnished
50 | to do so, subject to the following conditions:
51 | .
52 | The above copyright notice and this permission notice shall be included in all
53 | copies or substantial portions of the Software.
54 | .
55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
61 | THE SOFTWARE.
62 |
63 | License: MPL-2.0
64 | 1. Definitions
65 | --------------
66 | .
67 | 1.1. "Contributor"
68 | means each individual or legal entity that creates, contributes to
69 | the creation of, or owns Covered Software.
70 | .
71 | 1.2. "Contributor Version"
72 | means the combination of the Contributions of others (if any) used
73 | by a Contributor and that particular Contributor's Contribution.
74 | .
75 | 1.3. "Contribution"
76 | means Covered Software of a particular Contributor.
77 | .
78 | 1.4. "Covered Software"
79 | means Source Code Form to which the initial Contributor has attached
80 | the notice in Exhibit A, the Executable Form of such Source Code
81 | Form, and Modifications of such Source Code Form, in each case
82 | including portions thereof.
83 | .
84 | 1.5. "Incompatible With Secondary Licenses"
85 | means
86 | .
87 | (a) that the initial Contributor has attached the notice described
88 | in Exhibit B to the Covered Software; or
89 | .
90 | (b) that the Covered Software was made available under the terms of
91 | version 1.1 or earlier of the License, but not also under the
92 | terms of a Secondary License.
93 | .
94 | 1.6. "Executable Form"
95 | means any form of the work other than Source Code Form.
96 | .
97 | 1.7. "Larger Work"
98 | means a work that combines Covered Software with other material, in
99 | a separate file or files, that is not Covered Software.
100 | .
101 | 1.8. "License"
102 | means this document.
103 | .
104 | 1.9. "Licensable"
105 | means having the right to grant, to the maximum extent possible,
106 | whether at the time of the initial grant or subsequently, any and
107 | all of the rights conveyed by this License.
108 | .
109 | 1.10. "Modifications"
110 | means any of the following:
111 | .
112 | (a) any file in Source Code Form that results from an addition to,
113 | deletion from, or modification of the contents of Covered
114 | Software; or
115 | .
116 | (b) any new file in Source Code Form that contains any Covered
117 | Software.
118 | .
119 | 1.11. "Patent Claims" of a Contributor
120 | means any patent claim(s), including without limitation, method,
121 | process, and apparatus claims, in any patent Licensable by such
122 | Contributor that would be infringed, but for the grant of the
123 | License, by the making, using, selling, offering for sale, having
124 | made, import, or transfer of either its Contributions or its
125 | Contributor Version.
126 | .
127 | 1.12. "Secondary License"
128 | means either the GNU General Public License, Version 2.0, the GNU
129 | Lesser General Public License, Version 2.1, the GNU Affero General
130 | Public License, Version 3.0, or any later versions of those
131 | licenses.
132 | .
133 | 1.13. "Source Code Form"
134 | means the form of the work preferred for making modifications.
135 | .
136 | 1.14. "You" (or "Your")
137 | means an individual or a legal entity exercising rights under this
138 | License. For legal entities, "You" includes any entity that
139 | controls, is controlled by, or is under common control with You. For
140 | purposes of this definition, "control" means (a) the power, direct
141 | or indirect, to cause the direction or management of such entity,
142 | whether by contract or otherwise, or (b) ownership of more than
143 | fifty percent (50%) of the outstanding shares or beneficial
144 | ownership of such entity.
145 | .
146 | 2. License Grants and Conditions
147 | --------------------------------
148 | .
149 | 2.1. Grants
150 | .
151 | Each Contributor hereby grants You a world-wide, royalty-free,
152 | non-exclusive license:
153 | .
154 | (a) under intellectual property rights (other than patent or trademark)
155 | Licensable by such Contributor to use, reproduce, make available,
156 | modify, display, perform, distribute, and otherwise exploit its
157 | Contributions, either on an unmodified basis, with Modifications, or
158 | as part of a Larger Work; and
159 | .
160 | (b) under Patent Claims of such Contributor to make, use, sell, offer
161 | for sale, have made, import, and otherwise transfer either its
162 | Contributions or its Contributor Version.
163 | .
164 | 2.2. Effective Date
165 | .
166 | The licenses granted in Section 2.1 with respect to any Contribution
167 | become effective for each Contribution on the date the Contributor first
168 | distributes such Contribution.
169 | .
170 | 2.3. Limitations on Grant Scope
171 | .
172 | The licenses granted in this Section 2 are the only rights granted under
173 | this License. No additional rights or licenses will be implied from the
174 | distribution or licensing of Covered Software under this License.
175 | Notwithstanding Section 2.1(b) above, no patent license is granted by a
176 | Contributor:
177 | .
178 | (a) for any code that a Contributor has removed from Covered Software;
179 | or
180 | .
181 | (b) for infringements caused by: (i) Your and any other third party's
182 | modifications of Covered Software, or (ii) the combination of its
183 | Contributions with other software (except as part of its Contributor
184 | Version); or
185 | .
186 | (c) under Patent Claims infringed by Covered Software in the absence of
187 | its Contributions.
188 | .
189 | This License does not grant any rights in the trademarks, service marks,
190 | or logos of any Contributor (except as may be necessary to comply with
191 | the notice requirements in Section 3.4).
192 | .
193 | 2.4. Subsequent Licenses
194 | .
195 | No Contributor makes additional grants as a result of Your choice to
196 | distribute the Covered Software under a subsequent version of this
197 | License (see Section 10.2) or under the terms of a Secondary License (if
198 | permitted under the terms of Section 3.3).
199 | .
200 | 2.5. Representation
201 | .
202 | Each Contributor represents that the Contributor believes its
203 | Contributions are its original creation(s) or it has sufficient rights
204 | to grant the rights to its Contributions conveyed by this License.
205 | .
206 | 2.6. Fair Use
207 | .
208 | This License is not intended to limit any rights You have under
209 | applicable copyright doctrines of fair use, fair dealing, or other
210 | equivalents.
211 | .
212 | 2.7. Conditions
213 | .
214 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
215 | in Section 2.1.
216 | .
217 | 3. Responsibilities
218 | -------------------
219 | .
220 | 3.1. Distribution of Source Form
221 | .
222 | All distribution of Covered Software in Source Code Form, including any
223 | Modifications that You create or to which You contribute, must be under
224 | the terms of this License. You must inform recipients that the Source
225 | Code Form of the Covered Software is governed by the terms of this
226 | License, and how they can obtain a copy of this License. You may not
227 | attempt to alter or restrict the recipients' rights in the Source Code
228 | Form.
229 | .
230 | 3.2. Distribution of Executable Form
231 | .
232 | If You distribute Covered Software in Executable Form then:
233 | .
234 | (a) such Covered Software must also be made available in Source Code
235 | Form, as described in Section 3.1, and You must inform recipients of
236 | the Executable Form how they can obtain a copy of such Source Code
237 | Form by reasonable means in a timely manner, at a charge no more
238 | than the cost of distribution to the recipient; and
239 | .
240 | (b) You may distribute such Executable Form under the terms of this
241 | License, or sublicense it under different terms, provided that the
242 | license for the Executable Form does not attempt to limit or alter
243 | the recipients' rights in the Source Code Form under this License.
244 | .
245 | 3.3. Distribution of a Larger Work
246 | .
247 | You may create and distribute a Larger Work under terms of Your choice,
248 | provided that You also comply with the requirements of this License for
249 | the Covered Software. If the Larger Work is a combination of Covered
250 | Software with a work governed by one or more Secondary Licenses, and the
251 | Covered Software is not Incompatible With Secondary Licenses, this
252 | License permits You to additionally distribute such Covered Software
253 | under the terms of such Secondary License(s), so that the recipient of
254 | the Larger Work may, at their option, further distribute the Covered
255 | Software under the terms of either this License or such Secondary
256 | License(s).
257 | .
258 | 3.4. Notices
259 | .
260 | You may not remove or alter the substance of any license notices
261 | (including copyright notices, patent notices, disclaimers of warranty,
262 | or limitations of liability) contained within the Source Code Form of
263 | the Covered Software, except that You may alter any license notices to
264 | the extent required to remedy known factual inaccuracies.
265 | .
266 | 3.5. Application of Additional Terms
267 | .
268 | You may choose to offer, and to charge a fee for, warranty, support,
269 | indemnity or liability obligations to one or more recipients of Covered
270 | Software. However, You may do so only on Your own behalf, and not on
271 | behalf of any Contributor. You must make it absolutely clear that any
272 | such warranty, support, indemnity, or liability obligation is offered by
273 | You alone, and You hereby agree to indemnify every Contributor for any
274 | liability incurred by such Contributor as a result of warranty, support,
275 | indemnity or liability terms You offer. You may include additional
276 | disclaimers of warranty and limitations of liability specific to any
277 | jurisdiction.
278 | .
279 | 4. Inability to Comply Due to Statute or Regulation
280 | ---------------------------------------------------
281 | .
282 | If it is impossible for You to comply with any of the terms of this
283 | License with respect to some or all of the Covered Software due to
284 | statute, judicial order, or regulation then You must: (a) comply with
285 | the terms of this License to the maximum extent possible; and (b)
286 | describe the limitations and the code they affect. Such description must
287 | be placed in a text file included with all distributions of the Covered
288 | Software under this License. Except to the extent prohibited by statute
289 | or regulation, such description must be sufficiently detailed for a
290 | recipient of ordinary skill to be able to understand it.
291 | .
292 | 5. Termination
293 | --------------
294 | .
295 | 5.1. The rights granted under this License will terminate automatically
296 | if You fail to comply with any of its terms. However, if You become
297 | compliant, then the rights granted under this License from a particular
298 | Contributor are reinstated (a) provisionally, unless and until such
299 | Contributor explicitly and finally terminates Your grants, and (b) on an
300 | ongoing basis, if such Contributor fails to notify You of the
301 | non-compliance by some reasonable means prior to 60 days after You have
302 | come back into compliance. Moreover, Your grants from a particular
303 | Contributor are reinstated on an ongoing basis if such Contributor
304 | notifies You of the non-compliance by some reasonable means, this is the
305 | first time You have received notice of non-compliance with this License
306 | from such Contributor, and You become compliant prior to 30 days after
307 | Your receipt of the notice.
308 | .
309 | 5.2. If You initiate litigation against any entity by asserting a patent
310 | infringement claim (excluding declaratory judgment actions,
311 | counter-claims, and cross-claims) alleging that a Contributor Version
312 | directly or indirectly infringes any patent, then the rights granted to
313 | You by any and all Contributors for the Covered Software under Section
314 | 2.1 of this License shall terminate.
315 | .
316 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
317 | end user license agreements (excluding distributors and resellers) which
318 | have been validly granted by You or Your distributors under this License
319 | prior to termination shall survive termination.
320 | .
321 | ************************************************************************
322 | * *
323 | * 6. Disclaimer of Warranty *
324 | * ------------------------- *
325 | * *
326 | * Covered Software is provided under this License on an "as is" *
327 | * basis, without warranty of any kind, either expressed, implied, or *
328 | * statutory, including, without limitation, warranties that the *
329 | * Covered Software is free of defects, merchantable, fit for a *
330 | * particular purpose or non-infringing. The entire risk as to the *
331 | * quality and performance of the Covered Software is with You. *
332 | * Should any Covered Software prove defective in any respect, You *
333 | * (not any Contributor) assume the cost of any necessary servicing, *
334 | * repair, or correction. This disclaimer of warranty constitutes an *
335 | * essential part of this License. No use of any Covered Software is *
336 | * authorized under this License except under this disclaimer. *
337 | * *
338 | ************************************************************************
339 | .
340 | ************************************************************************
341 | * *
342 | * 7. Limitation of Liability *
343 | * -------------------------- *
344 | * *
345 | * Under no circumstances and under no legal theory, whether tort *
346 | * (including negligence), contract, or otherwise, shall any *
347 | * Contributor, or anyone who distributes Covered Software as *
348 | * permitted above, be liable to You for any direct, indirect, *
349 | * special, incidental, or consequential damages of any character *
350 | * including, without limitation, damages for lost profits, loss of *
351 | * goodwill, work stoppage, computer failure or malfunction, or any *
352 | * and all other commercial damages or losses, even if such party *
353 | * shall have been informed of the possibility of such damages. This *
354 | * limitation of liability shall not apply to liability for death or *
355 | * personal injury resulting from such party's negligence to the *
356 | * extent applicable law prohibits such limitation. Some *
357 | * jurisdictions do not allow the exclusion or limitation of *
358 | * incidental or consequential damages, so this exclusion and *
359 | * limitation may not apply to You. *
360 | * *
361 | ************************************************************************
362 | .
363 | 8. Litigation
364 | -------------
365 | .
366 | Any litigation relating to this License may be brought only in the
367 | courts of a jurisdiction where the defendant maintains its principal
368 | place of business and such litigation shall be governed by laws of that
369 | jurisdiction, without reference to its conflict-of-law provisions.
370 | Nothing in this Section shall prevent a party's ability to bring
371 | cross-claims or counter-claims.
372 | .
373 | 9. Miscellaneous
374 | ----------------
375 | .
376 | This License represents the complete agreement concerning the subject
377 | matter hereof. If any provision of this License is held to be
378 | unenforceable, such provision shall be reformed only to the extent
379 | necessary to make it enforceable. Any law or regulation which provides
380 | that the language of a contract shall be construed against the drafter
381 | shall not be used to construe this License against a Contributor.
382 | .
383 | 10. Versions of the License
384 | ---------------------------
385 | .
386 | 10.1. New Versions
387 | .
388 | Mozilla Foundation is the license steward. Except as provided in Section
389 | 10.3, no one other than the license steward has the right to modify or
390 | publish new versions of this License. Each version will be given a
391 | distinguishing version number.
392 | .
393 | 10.2. Effect of New Versions
394 | .
395 | You may distribute the Covered Software under the terms of the version
396 | of the License under which You originally received the Covered Software,
397 | or under the terms of any subsequent version published by the license
398 | steward.
399 | .
400 | 10.3. Modified Versions
401 | .
402 | If you create software not governed by this License, and you want to
403 | create a new license for such software, you may create and use a
404 | modified version of this License if you rename the license and remove
405 | any references to the name of the license steward (except to note that
406 | such modified license differs from this License).
407 | .
408 | 10.4. Distributing Source Code Form that is Incompatible With Secondary
409 | Licenses
410 | .
411 | If You choose to distribute Source Code Form that is Incompatible With
412 | Secondary Licenses under the terms of this version of the License, the
413 | notice described in Exhibit B of this License must be attached.
414 | .
415 | Exhibit A - Source Code Form License Notice
416 | -------------------------------------------
417 | .
418 | This Source Code Form is subject to the terms of the Mozilla Public
419 | License, v. 2.0. If a copy of the MPL was not distributed with this
420 | file, You can obtain one at http://mozilla.org/MPL/2.0/.
421 | .
422 | If it is not possible or desirable to put the notice in a particular
423 | file, then You may include the notice in a location (such as a LICENSE
424 | file in a relevant directory) where a recipient would be likely to look
425 | for such a notice.
426 | .
427 | You may add additional accurate notices of copyright ownership.
428 | .
429 | Exhibit B - "Incompatible With Secondary Licenses" Notice
430 | ---------------------------------------------------------
431 | .
432 | This Source Code Form is "Incompatible With Secondary Licenses", as
433 | defined by the Mozilla Public License, v. 2.0.
434 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_classmap.php:
--------------------------------------------------------------------------------
1 | array($vendorDir . '/grpc/grpc/src/lib'),
10 | );
11 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_real.php:
--------------------------------------------------------------------------------
1 | $path) {
28 | $loader->set($namespace, $path);
29 | }
30 |
31 | $map = require __DIR__ . '/autoload_psr4.php';
32 | foreach ($map as $namespace => $path) {
33 | $loader->setPsr4($namespace, $path);
34 | }
35 |
36 | $classMap = require __DIR__ . '/autoload_classmap.php';
37 | if ($classMap) {
38 | $loader->addClassMap($classMap);
39 | }
40 |
41 | $loader->register(true);
42 |
43 | return $loader;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/composer/installed.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "grpc/grpc",
4 | "version": "1.25.0",
5 | "version_normalized": "1.25.0.0",
6 | "source": {
7 | "type": "git",
8 | "url": "https://github.com/grpc/grpc-php.git",
9 | "reference": "bdb165d6712db0cfcc35edae2d14fb2b00cabc88"
10 | },
11 | "dist": {
12 | "type": "zip",
13 | "url": "https://api.github.com/repos/grpc/grpc-php/zipball/bdb165d6712db0cfcc35edae2d14fb2b00cabc88",
14 | "reference": "bdb165d6712db0cfcc35edae2d14fb2b00cabc88",
15 | "shasum": ""
16 | },
17 | "require": {
18 | "php": ">=5.5.0"
19 | },
20 | "require-dev": {
21 | "google/auth": "^v1.3.0"
22 | },
23 | "suggest": {
24 | "ext-protobuf": "For better performance, install the protobuf C extension.",
25 | "google/protobuf": "To get started using grpc quickly, install the native protobuf library."
26 | },
27 | "time": "2019-11-07 00:47:40",
28 | "type": "library",
29 | "installation-source": "dist",
30 | "autoload": {
31 | "psr-4": {
32 | "Grpc\\": "src/lib/"
33 | }
34 | },
35 | "notification-url": "https://packagist.org/downloads/",
36 | "license": [
37 | "Apache-2.0"
38 | ],
39 | "description": "gRPC library for PHP",
40 | "homepage": "https://grpc.io",
41 | "keywords": [
42 | "rpc"
43 | ]
44 | }
45 | ]
46 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/MAINTAINERS.md:
--------------------------------------------------------------------------------
1 | This page lists all active maintainers of this repository. If you were a
2 | maintainer and would like to add your name to the Emeritus list, please send us a
3 | PR.
4 |
5 | See [GOVERNANCE.md](https://github.com/grpc/grpc-community/blob/master/governance.md)
6 | for governance guidelines and how to become a maintainer.
7 | See [CONTRIBUTING.md](https://github.com/grpc/grpc-community/blob/master/CONTRIBUTING.md)
8 | for general contribution guidelines.
9 |
10 | ## Maintainers (in alphabetical order)
11 | - [stanley-cheung](https://github.com/stanley-cheung), Google Inc.
12 | - [wenbozhu](https://github.com/wenbozhu), Google Inc.
13 | - [zhouyihaiding](https://github.com/zhouyihaiding), Google Inc.
14 |
15 | ## Emeritus Maintainers (in alphabetical order)
16 | - [murgatroid99](https://github.com/murgatroid99), Google Inc.
17 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/README.md:
--------------------------------------------------------------------------------
1 | # gRPC PHP Client Library
2 |
3 | This repository contains only PHP files to support Composer installation.
4 |
5 | This repository is a mirror of [gRPC](https://github.com/grpc/grpc). Any support
6 | requests, bug reports, or development contributions should be directed to
7 | that project.
8 |
9 | To install gRPC for PHP, please see https://github.com/grpc/grpc/tree/master/src/php
10 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "grpc/grpc",
3 | "type": "library",
4 | "description": "gRPC library for PHP",
5 | "keywords": ["rpc"],
6 | "homepage": "https://grpc.io",
7 | "license": "Apache-2.0",
8 | "version": "1.25.0",
9 | "require": {
10 | "php": ">=5.5.0"
11 | },
12 | "require-dev": {
13 | "google/auth": "^v1.3.0"
14 | },
15 | "suggest": {
16 | "ext-protobuf": "For better performance, install the protobuf C extension.",
17 | "google/protobuf": "To get started using grpc quickly, install the native protobuf library."
18 | },
19 | "autoload": {
20 | "psr-4": {
21 | "Grpc\\": "src/lib/"
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/src/lib/AbstractCall.php:
--------------------------------------------------------------------------------
1 | add($delta);
57 | } else {
58 | $deadline = Timeval::infFuture();
59 | }
60 | $this->call = new Call($channel, $method, $deadline);
61 | $this->deserialize = $deserialize;
62 | $this->metadata = null;
63 | $this->trailing_metadata = null;
64 | if (array_key_exists('call_credentials_callback', $options) &&
65 | is_callable($call_credentials_callback =
66 | $options['call_credentials_callback'])
67 | ) {
68 | $call_credentials = CallCredentials::createFromPlugin(
69 | $call_credentials_callback
70 | );
71 | $this->call->setCredentials($call_credentials);
72 | }
73 | }
74 |
75 | /**
76 | * @return mixed The metadata sent by the server
77 | */
78 | public function getMetadata()
79 | {
80 | return $this->metadata;
81 | }
82 |
83 | /**
84 | * @return mixed The trailing metadata sent by the server
85 | */
86 | public function getTrailingMetadata()
87 | {
88 | return $this->trailing_metadata;
89 | }
90 |
91 | /**
92 | * @return string The URI of the endpoint
93 | */
94 | public function getPeer()
95 | {
96 | return $this->call->getPeer();
97 | }
98 |
99 | /**
100 | * Cancels the call.
101 | */
102 | public function cancel()
103 | {
104 | $this->call->cancel();
105 | }
106 |
107 | /**
108 | * Serialize a message to the protobuf binary format.
109 | *
110 | * @param mixed $data The Protobuf message
111 | *
112 | * @return string The protobuf binary format
113 | */
114 | protected function _serializeMessage($data)
115 | {
116 | // Proto3 implementation
117 | if (method_exists($data, 'encode')) {
118 | return $data->encode();
119 | } elseif (method_exists($data, 'serializeToString')) {
120 | return $data->serializeToString();
121 | }
122 |
123 | // Protobuf-PHP implementation
124 | return $data->serialize();
125 | }
126 |
127 | /**
128 | * Deserialize a response value to an object.
129 | *
130 | * @param string $value The binary value to deserialize
131 | *
132 | * @return mixed The deserialized value
133 | */
134 | protected function _deserializeResponse($value)
135 | {
136 | if ($value === null) {
137 | return;
138 | }
139 |
140 | // Proto3 implementation
141 | if (is_array($this->deserialize)) {
142 | list($className, $deserializeFunc) = $this->deserialize;
143 | $obj = new $className();
144 | if (method_exists($obj, $deserializeFunc)) {
145 | $obj->$deserializeFunc($value);
146 | } else {
147 | $obj->mergeFromString($value);
148 | }
149 |
150 | return $obj;
151 | }
152 |
153 | // Protobuf-PHP implementation
154 | return call_user_func($this->deserialize, $value);
155 | }
156 |
157 | /**
158 | * Set the CallCredentials for the underlying Call.
159 | *
160 | * @param CallCredentials $call_credentials The CallCredentials object
161 | */
162 | public function setCallCredentials($call_credentials)
163 | {
164 | $this->call->setCredentials($call_credentials);
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/src/lib/BaseStub.php:
--------------------------------------------------------------------------------
1 | hostname = $hostname;
52 | $this->update_metadata = null;
53 | if (isset($opts['update_metadata'])) {
54 | if (is_callable($opts['update_metadata'])) {
55 | $this->update_metadata = $opts['update_metadata'];
56 | }
57 | unset($opts['update_metadata']);
58 | }
59 | if (!empty($opts['grpc.ssl_target_name_override'])) {
60 | $this->hostname_override = $opts['grpc.ssl_target_name_override'];
61 | }
62 | if (isset($opts['grpc_call_invoker'])) {
63 | $this->call_invoker = $opts['grpc_call_invoker'];
64 | unset($opts['grpc_call_invoker']);
65 | $channel_opts = $this->updateOpts($opts);
66 | // If the grpc_call_invoker is defined, use the channel created by the call invoker.
67 | $this->channel = $this->call_invoker->createChannelFactory($hostname, $channel_opts);
68 | return;
69 | }
70 | $this->call_invoker = new DefaultCallInvoker();
71 | if ($channel) {
72 | if (!is_a($channel, 'Grpc\Channel') &&
73 | !is_a($channel, 'Grpc\Internal\InterceptorChannel')) {
74 | throw new \Exception('The channel argument is not a Channel object '.
75 | 'or an InterceptorChannel object created by '.
76 | 'Interceptor::intercept($channel, Interceptor|Interceptor[] $interceptors)');
77 | }
78 | $this->channel = $channel;
79 | return;
80 | }
81 |
82 | $this->channel = static::getDefaultChannel($hostname, $opts);
83 | }
84 |
85 | private static function updateOpts($opts) {
86 | if (!file_exists($composerFile = __DIR__.'/../../composer.json')) {
87 | // for grpc/grpc-php subpackage
88 | $composerFile = __DIR__.'/../composer.json';
89 | }
90 | $package_config = json_decode(file_get_contents($composerFile), true);
91 | if (!empty($opts['grpc.primary_user_agent'])) {
92 | $opts['grpc.primary_user_agent'] .= ' ';
93 | } else {
94 | $opts['grpc.primary_user_agent'] = '';
95 | }
96 | $opts['grpc.primary_user_agent'] .=
97 | 'grpc-php/'.$package_config['version'];
98 | if (!array_key_exists('credentials', $opts)) {
99 | throw new \Exception("The opts['credentials'] key is now ".
100 | 'required. Please see one of the '.
101 | 'ChannelCredentials::create methods');
102 | }
103 | return $opts;
104 | }
105 |
106 | /**
107 | * Creates and returns the default Channel
108 | *
109 | * @param array $opts Channel constructor options
110 | *
111 | * @return Channel The channel
112 | */
113 | public static function getDefaultChannel($hostname, array $opts)
114 | {
115 | $channel_opts = self::updateOpts($opts);
116 | return new Channel($hostname, $opts);
117 | }
118 |
119 | /**
120 | * @return string The URI of the endpoint
121 | */
122 | public function getTarget()
123 | {
124 | return $this->channel->getTarget();
125 | }
126 |
127 | /**
128 | * @param bool $try_to_connect (optional)
129 | *
130 | * @return int The grpc connectivity state
131 | */
132 | public function getConnectivityState($try_to_connect = false)
133 | {
134 | return $this->channel->getConnectivityState($try_to_connect);
135 | }
136 |
137 | /**
138 | * @param int $timeout in microseconds
139 | *
140 | * @return bool true if channel is ready
141 | * @throw Exception if channel is in FATAL_ERROR state
142 | */
143 | public function waitForReady($timeout)
144 | {
145 | $new_state = $this->getConnectivityState(true);
146 | if ($this->_checkConnectivityState($new_state)) {
147 | return true;
148 | }
149 |
150 | $now = Timeval::now();
151 | $delta = new Timeval($timeout);
152 | $deadline = $now->add($delta);
153 |
154 | while ($this->channel->watchConnectivityState($new_state, $deadline)) {
155 | // state has changed before deadline
156 | $new_state = $this->getConnectivityState();
157 | if ($this->_checkConnectivityState($new_state)) {
158 | return true;
159 | }
160 | }
161 | // deadline has passed
162 | $new_state = $this->getConnectivityState();
163 |
164 | return $this->_checkConnectivityState($new_state);
165 | }
166 |
167 | /**
168 | * Close the communication channel associated with this stub.
169 | */
170 | public function close()
171 | {
172 | $this->channel->close();
173 | }
174 |
175 | /**
176 | * @param $new_state Connect state
177 | *
178 | * @return bool true if state is CHANNEL_READY
179 | * @throw Exception if state is CHANNEL_FATAL_FAILURE
180 | */
181 | private function _checkConnectivityState($new_state)
182 | {
183 | if ($new_state == \Grpc\CHANNEL_READY) {
184 | return true;
185 | }
186 | if ($new_state == \Grpc\CHANNEL_FATAL_FAILURE) {
187 | throw new \Exception('Failed to connect to server');
188 | }
189 |
190 | return false;
191 | }
192 |
193 | /**
194 | * constructs the auth uri for the jwt.
195 | *
196 | * @param string $method The method string
197 | *
198 | * @return string The URL string
199 | */
200 | private function _get_jwt_aud_uri($method)
201 | {
202 | // TODO(jtattermusch): This is not the correct implementation
203 | // of extracting JWT "aud" claim. We should rely on
204 | // grpc_metadata_credentials_plugin which
205 | // also provides the correct value of "aud" claim
206 | // in the grpc_auth_metadata_context.service_url field.
207 | // Trying to do the construction of "aud" field ourselves
208 | // is bad.
209 | $last_slash_idx = strrpos($method, '/');
210 | if ($last_slash_idx === false) {
211 | throw new \InvalidArgumentException(
212 | 'service name must have a slash'
213 | );
214 | }
215 | $service_name = substr($method, 0, $last_slash_idx);
216 |
217 | if ($this->hostname_override) {
218 | $hostname = $this->hostname_override;
219 | } else {
220 | $hostname = $this->hostname;
221 | }
222 |
223 | // Remove the port if it is 443
224 | // See https://github.com/grpc/grpc/blob/07c9f7a36b2a0d34fcffebc85649cf3b8c339b5d/src/core/lib/security/transport/client_auth_filter.cc#L205
225 | if ((strlen($hostname) > 4) && (substr($hostname, -4) === ":443")) {
226 | $hostname = substr($hostname, 0, -4);
227 | }
228 |
229 | return 'https://'.$hostname.$service_name;
230 | }
231 |
232 | /**
233 | * validate and normalize the metadata array.
234 | *
235 | * @param array $metadata The metadata map
236 | *
237 | * @return array $metadata Validated and key-normalized metadata map
238 | * @throw InvalidArgumentException if key contains invalid characters
239 | */
240 | private function _validate_and_normalize_metadata($metadata)
241 | {
242 | $metadata_copy = [];
243 | foreach ($metadata as $key => $value) {
244 | if (!preg_match('/^[.A-Za-z\d_-]+$/', $key)) {
245 | throw new \InvalidArgumentException(
246 | 'Metadata keys must be nonempty strings containing only '.
247 | 'alphanumeric characters, hyphens, underscores and dots'
248 | );
249 | }
250 | $metadata_copy[strtolower($key)] = $value;
251 | }
252 |
253 | return $metadata_copy;
254 | }
255 |
256 | /**
257 | * Create a function which can be used to create UnaryCall
258 | *
259 | * @param Channel|InterceptorChannel $channel
260 | * @param callable $deserialize A function that deserializes the response
261 | *
262 | * @return \Closure
263 | */
264 | private function _GrpcUnaryUnary($channel)
265 | {
266 | return function ($method,
267 | $argument,
268 | $deserialize,
269 | array $metadata = [],
270 | array $options = []) use ($channel) {
271 | $call = $this->call_invoker->UnaryCall(
272 | $channel,
273 | $method,
274 | $deserialize,
275 | $options
276 | );
277 | $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
278 | if (is_callable($this->update_metadata)) {
279 | $metadata = call_user_func(
280 | $this->update_metadata,
281 | $metadata,
282 | $jwt_aud_uri
283 | );
284 | }
285 | $metadata = $this->_validate_and_normalize_metadata(
286 | $metadata
287 | );
288 | $call->start($argument, $metadata, $options);
289 | return $call;
290 | };
291 | }
292 |
293 | /**
294 | * Create a function which can be used to create ServerStreamingCall
295 | *
296 | * @param Channel|InterceptorChannel $channel
297 | * @param callable $deserialize A function that deserializes the response
298 | *
299 | * @return \Closure
300 | */
301 | private function _GrpcStreamUnary($channel)
302 | {
303 | return function ($method,
304 | $deserialize,
305 | array $metadata = [],
306 | array $options = []) use ($channel) {
307 | $call = $this->call_invoker->ClientStreamingCall(
308 | $channel,
309 | $method,
310 | $deserialize,
311 | $options
312 | );
313 | $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
314 | if (is_callable($this->update_metadata)) {
315 | $metadata = call_user_func(
316 | $this->update_metadata,
317 | $metadata,
318 | $jwt_aud_uri
319 | );
320 | }
321 | $metadata = $this->_validate_and_normalize_metadata(
322 | $metadata
323 | );
324 | $call->start($metadata);
325 | return $call;
326 | };
327 | }
328 |
329 | /**
330 | * Create a function which can be used to create ClientStreamingCall
331 | *
332 | * @param Channel|InterceptorChannel $channel
333 | * @param callable $deserialize A function that deserializes the response
334 | *
335 | * @return \Closure
336 | */
337 | private function _GrpcUnaryStream($channel)
338 | {
339 | return function ($method,
340 | $argument,
341 | $deserialize,
342 | array $metadata = [],
343 | array $options = []) use ($channel) {
344 | $call = $this->call_invoker->ServerStreamingCall(
345 | $channel,
346 | $method,
347 | $deserialize,
348 | $options
349 | );
350 | $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
351 | if (is_callable($this->update_metadata)) {
352 | $metadata = call_user_func(
353 | $this->update_metadata,
354 | $metadata,
355 | $jwt_aud_uri
356 | );
357 | }
358 | $metadata = $this->_validate_and_normalize_metadata(
359 | $metadata
360 | );
361 | $call->start($argument, $metadata, $options);
362 | return $call;
363 | };
364 | }
365 |
366 | /**
367 | * Create a function which can be used to create BidiStreamingCall
368 | *
369 | * @param Channel|InterceptorChannel $channel
370 | * @param callable $deserialize A function that deserializes the response
371 | *
372 | * @return \Closure
373 | */
374 | private function _GrpcStreamStream($channel)
375 | {
376 | return function ($method,
377 | $deserialize,
378 | array $metadata = [],
379 | array $options = []) use ($channel) {
380 | $call = $this->call_invoker->BidiStreamingCall(
381 | $channel,
382 | $method,
383 | $deserialize,
384 | $options
385 | );
386 | $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
387 | if (is_callable($this->update_metadata)) {
388 | $metadata = call_user_func(
389 | $this->update_metadata,
390 | $metadata,
391 | $jwt_aud_uri
392 | );
393 | }
394 | $metadata = $this->_validate_and_normalize_metadata(
395 | $metadata
396 | );
397 | $call->start($metadata);
398 |
399 | return $call;
400 | };
401 | }
402 |
403 | /**
404 | * Create a function which can be used to create UnaryCall
405 | *
406 | * @param Channel|InterceptorChannel $channel
407 | * @param callable $deserialize A function that deserializes the response
408 | *
409 | * @return \Closure
410 | */
411 | private function _UnaryUnaryCallFactory($channel)
412 | {
413 | if (is_a($channel, 'Grpc\Internal\InterceptorChannel')) {
414 | return function ($method,
415 | $argument,
416 | $deserialize,
417 | array $metadata = [],
418 | array $options = []) use ($channel) {
419 | return $channel->getInterceptor()->interceptUnaryUnary(
420 | $method,
421 | $argument,
422 | $deserialize,
423 | $metadata,
424 | $options,
425 | $this->_UnaryUnaryCallFactory($channel->getNext())
426 | );
427 | };
428 | }
429 | return $this->_GrpcUnaryUnary($channel);
430 | }
431 |
432 | /**
433 | * Create a function which can be used to create ServerStreamingCall
434 | *
435 | * @param Channel|InterceptorChannel $channel
436 | * @param callable $deserialize A function that deserializes the response
437 | *
438 | * @return \Closure
439 | */
440 | private function _UnaryStreamCallFactory($channel)
441 | {
442 | if (is_a($channel, 'Grpc\Internal\InterceptorChannel')) {
443 | return function ($method,
444 | $argument,
445 | $deserialize,
446 | array $metadata = [],
447 | array $options = []) use ($channel) {
448 | return $channel->getInterceptor()->interceptUnaryStream(
449 | $method,
450 | $argument,
451 | $deserialize,
452 | $metadata,
453 | $options,
454 | $this->_UnaryStreamCallFactory($channel->getNext())
455 | );
456 | };
457 | }
458 | return $this->_GrpcUnaryStream($channel);
459 | }
460 |
461 | /**
462 | * Create a function which can be used to create ClientStreamingCall
463 | *
464 | * @param Channel|InterceptorChannel $channel
465 | * @param callable $deserialize A function that deserializes the response
466 | *
467 | * @return \Closure
468 | */
469 | private function _StreamUnaryCallFactory($channel)
470 | {
471 | if (is_a($channel, 'Grpc\Internal\InterceptorChannel')) {
472 | return function ($method,
473 | $deserialize,
474 | array $metadata = [],
475 | array $options = []) use ($channel) {
476 | return $channel->getInterceptor()->interceptStreamUnary(
477 | $method,
478 | $deserialize,
479 | $metadata,
480 | $options,
481 | $this->_StreamUnaryCallFactory($channel->getNext())
482 | );
483 | };
484 | }
485 | return $this->_GrpcStreamUnary($channel);
486 | }
487 |
488 | /**
489 | * Create a function which can be used to create BidiStreamingCall
490 | *
491 | * @param Channel|InterceptorChannel $channel
492 | * @param callable $deserialize A function that deserializes the response
493 | *
494 | * @return \Closure
495 | */
496 | private function _StreamStreamCallFactory($channel)
497 | {
498 | if (is_a($channel, 'Grpc\Internal\InterceptorChannel')) {
499 | return function ($method,
500 | $deserialize,
501 | array $metadata = [],
502 | array $options = []) use ($channel) {
503 | return $channel->getInterceptor()->interceptStreamStream(
504 | $method,
505 | $deserialize,
506 | $metadata,
507 | $options,
508 | $this->_StreamStreamCallFactory($channel->getNext())
509 | );
510 | };
511 | }
512 | return $this->_GrpcStreamStream($channel);
513 | }
514 |
515 | /* This class is intended to be subclassed by generated code, so
516 | * all functions begin with "_" to avoid name collisions. */
517 | /**
518 | * Call a remote method that takes a single argument and has a
519 | * single output.
520 | *
521 | * @param string $method The name of the method to call
522 | * @param mixed $argument The argument to the method
523 | * @param callable $deserialize A function that deserializes the response
524 | * @param array $metadata A metadata map to send to the server
525 | * (optional)
526 | * @param array $options An array of options (optional)
527 | *
528 | * @return UnaryCall The active call object
529 | */
530 | protected function _simpleRequest(
531 | $method,
532 | $argument,
533 | $deserialize,
534 | array $metadata = [],
535 | array $options = []
536 | ) {
537 | $call_factory = $this->_UnaryUnaryCallFactory($this->channel);
538 | $call = $call_factory($method, $argument, $deserialize, $metadata, $options);
539 | return $call;
540 | }
541 |
542 | /**
543 | * Call a remote method that takes a stream of arguments and has a single
544 | * output.
545 | *
546 | * @param string $method The name of the method to call
547 | * @param callable $deserialize A function that deserializes the response
548 | * @param array $metadata A metadata map to send to the server
549 | * (optional)
550 | * @param array $options An array of options (optional)
551 | *
552 | * @return ClientStreamingCall The active call object
553 | */
554 | protected function _clientStreamRequest(
555 | $method,
556 | $deserialize,
557 | array $metadata = [],
558 | array $options = []
559 | ) {
560 | $call_factory = $this->_StreamUnaryCallFactory($this->channel);
561 | $call = $call_factory($method, $deserialize, $metadata, $options);
562 | return $call;
563 | }
564 |
565 | /**
566 | * Call a remote method that takes a single argument and returns a stream
567 | * of responses.
568 | *
569 | * @param string $method The name of the method to call
570 | * @param mixed $argument The argument to the method
571 | * @param callable $deserialize A function that deserializes the responses
572 | * @param array $metadata A metadata map to send to the server
573 | * (optional)
574 | * @param array $options An array of options (optional)
575 | *
576 | * @return ServerStreamingCall The active call object
577 | */
578 | protected function _serverStreamRequest(
579 | $method,
580 | $argument,
581 | $deserialize,
582 | array $metadata = [],
583 | array $options = []
584 | ) {
585 | $call_factory = $this->_UnaryStreamCallFactory($this->channel);
586 | $call = $call_factory($method, $argument, $deserialize, $metadata, $options);
587 | return $call;
588 | }
589 |
590 | /**
591 | * Call a remote method with messages streaming in both directions.
592 | *
593 | * @param string $method The name of the method to call
594 | * @param callable $deserialize A function that deserializes the responses
595 | * @param array $metadata A metadata map to send to the server
596 | * (optional)
597 | * @param array $options An array of options (optional)
598 | *
599 | * @return BidiStreamingCall The active call object
600 | */
601 | protected function _bidiRequest(
602 | $method,
603 | $deserialize,
604 | array $metadata = [],
605 | array $options = []
606 | ) {
607 | $call_factory = $this->_StreamStreamCallFactory($this->channel);
608 | $call = $call_factory($method, $deserialize, $metadata, $options);
609 | return $call;
610 | }
611 | }
612 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/src/lib/BidiStreamingCall.php:
--------------------------------------------------------------------------------
1 | call->startBatch([
37 | OP_SEND_INITIAL_METADATA => $metadata,
38 | ]);
39 | }
40 |
41 | /**
42 | * Reads the next value from the server.
43 | *
44 | * @return mixed The next value from the server, or null if there is none
45 | */
46 | public function read()
47 | {
48 | $batch = [OP_RECV_MESSAGE => true];
49 | if ($this->metadata === null) {
50 | $batch[OP_RECV_INITIAL_METADATA] = true;
51 | }
52 | $read_event = $this->call->startBatch($batch);
53 | if ($this->metadata === null) {
54 | $this->metadata = $read_event->metadata;
55 | }
56 |
57 | return $this->_deserializeResponse($read_event->message);
58 | }
59 |
60 | /**
61 | * Write a single message to the server. This cannot be called after
62 | * writesDone is called.
63 | *
64 | * @param ByteBuffer $data The data to write
65 | * @param array $options An array of options, possible keys:
66 | * 'flags' => a number (optional)
67 | */
68 | public function write($data, array $options = [])
69 | {
70 | $message_array = ['message' => $this->_serializeMessage($data)];
71 | if (array_key_exists('flags', $options)) {
72 | $message_array['flags'] = $options['flags'];
73 | }
74 | $this->call->startBatch([
75 | OP_SEND_MESSAGE => $message_array,
76 | ]);
77 | }
78 |
79 | /**
80 | * Indicate that no more writes will be sent.
81 | */
82 | public function writesDone()
83 | {
84 | $this->call->startBatch([
85 | OP_SEND_CLOSE_FROM_CLIENT => true,
86 | ]);
87 | }
88 |
89 | /**
90 | * Wait for the server to send the status, and return it.
91 | *
92 | * @return \stdClass The status object, with integer $code, string
93 | * $details, and array $metadata members
94 | */
95 | public function getStatus()
96 | {
97 | $status_event = $this->call->startBatch([
98 | OP_RECV_STATUS_ON_CLIENT => true,
99 | ]);
100 |
101 | $this->trailing_metadata = $status_event->status->metadata;
102 |
103 | return $status_event->status;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/src/lib/CallInvoker.php:
--------------------------------------------------------------------------------
1 | call->startBatch([
37 | OP_SEND_INITIAL_METADATA => $metadata,
38 | ]);
39 | }
40 |
41 | /**
42 | * Write a single message to the server. This cannot be called after
43 | * wait is called.
44 | *
45 | * @param ByteBuffer $data The data to write
46 | * @param array $options An array of options, possible keys:
47 | * 'flags' => a number (optional)
48 | */
49 | public function write($data, array $options = [])
50 | {
51 | $message_array = ['message' => $this->_serializeMessage($data)];
52 | if (array_key_exists('flags', $options)) {
53 | $message_array['flags'] = $options['flags'];
54 | }
55 | $this->call->startBatch([
56 | OP_SEND_MESSAGE => $message_array,
57 | ]);
58 | }
59 |
60 | /**
61 | * Wait for the server to respond with data and a status.
62 | *
63 | * @return array [response data, status]
64 | */
65 | public function wait()
66 | {
67 | $event = $this->call->startBatch([
68 | OP_SEND_CLOSE_FROM_CLIENT => true,
69 | OP_RECV_INITIAL_METADATA => true,
70 | OP_RECV_MESSAGE => true,
71 | OP_RECV_STATUS_ON_CLIENT => true,
72 | ]);
73 | $this->metadata = $event->metadata;
74 |
75 | $status = $event->status;
76 | $this->trailing_metadata = $status->metadata;
77 |
78 | return [$this->_deserializeResponse($event->message), $status];
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/src/lib/DefaultCallInvoker.php:
--------------------------------------------------------------------------------
1 | = 0; $i--) {
84 | $channel = new Internal\InterceptorChannel($channel, $interceptors[$i]);
85 | }
86 | } else {
87 | $channel = new Internal\InterceptorChannel($channel, $interceptors);
88 | }
89 | return $channel;
90 | }
91 | }
92 |
93 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/src/lib/Internal/InterceptorChannel.php:
--------------------------------------------------------------------------------
1 | interceptor = $interceptor;
44 | $this->next = $channel;
45 | }
46 |
47 | public function getNext()
48 | {
49 | return $this->next;
50 | }
51 |
52 | public function getInterceptor()
53 | {
54 | return $this->interceptor;
55 | }
56 |
57 | public function getTarget()
58 | {
59 | return $this->getNext()->getTarget();
60 | }
61 |
62 | public function watchConnectivityState($new_state, $deadline)
63 | {
64 | return $this->getNext()->watchConnectivityState($new_state, $deadline);
65 | }
66 |
67 | public function getConnectivityState($try_to_connect = false)
68 | {
69 | return $this->getNext()->getConnectivityState($try_to_connect);
70 | }
71 |
72 | public function close()
73 | {
74 | return $this->getNext()->close();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/src/lib/ServerStreamingCall.php:
--------------------------------------------------------------------------------
1 | a number (optional)
36 | */
37 | public function start($data, array $metadata = [], array $options = [])
38 | {
39 | $message_array = ['message' => $this->_serializeMessage($data)];
40 | if (array_key_exists('flags', $options)) {
41 | $message_array['flags'] = $options['flags'];
42 | }
43 | $this->call->startBatch([
44 | OP_SEND_INITIAL_METADATA => $metadata,
45 | OP_SEND_MESSAGE => $message_array,
46 | OP_SEND_CLOSE_FROM_CLIENT => true,
47 | ]);
48 | }
49 |
50 | /**
51 | * @return mixed An iterator of response values
52 | */
53 | public function responses()
54 | {
55 | $batch = [OP_RECV_MESSAGE => true];
56 | if ($this->metadata === null) {
57 | $batch[OP_RECV_INITIAL_METADATA] = true;
58 | }
59 | $read_event = $this->call->startBatch($batch);
60 | if ($this->metadata === null) {
61 | $this->metadata = $read_event->metadata;
62 | }
63 | $response = $read_event->message;
64 | while ($response !== null) {
65 | yield $this->_deserializeResponse($response);
66 | $response = $this->call->startBatch([
67 | OP_RECV_MESSAGE => true,
68 | ])->message;
69 | }
70 | }
71 |
72 | /**
73 | * Wait for the server to send the status, and return it.
74 | *
75 | * @return \stdClass The status object, with integer $code, string
76 | * $details, and array $metadata members
77 | */
78 | public function getStatus()
79 | {
80 | $status_event = $this->call->startBatch([
81 | OP_RECV_STATUS_ON_CLIENT => true,
82 | ]);
83 |
84 | $this->trailing_metadata = $status_event->status->metadata;
85 |
86 | return $status_event->status;
87 | }
88 |
89 | /**
90 | * @return mixed The metadata sent by the server
91 | */
92 | public function getMetadata()
93 | {
94 | if ($this->metadata === null) {
95 | $event = $this->call->startBatch([OP_RECV_INITIAL_METADATA => true]);
96 | $this->metadata = $event->metadata;
97 | }
98 | return $this->metadata;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/vendor/grpc/grpc/src/lib/UnaryCall.php:
--------------------------------------------------------------------------------
1 | a number (optional)
36 | */
37 | public function start($data, array $metadata = [], array $options = [])
38 | {
39 | $message_array = ['message' => $this->_serializeMessage($data)];
40 | if (isset($options['flags'])) {
41 | $message_array['flags'] = $options['flags'];
42 | }
43 | $this->call->startBatch([
44 | OP_SEND_INITIAL_METADATA => $metadata,
45 | OP_SEND_MESSAGE => $message_array,
46 | OP_SEND_CLOSE_FROM_CLIENT => true,
47 | ]);
48 | }
49 |
50 | /**
51 | * Wait for the server to respond with data and a status.
52 | *
53 | * @return array [response data, status]
54 | */
55 | public function wait()
56 | {
57 | $batch = [
58 | OP_RECV_MESSAGE => true,
59 | OP_RECV_STATUS_ON_CLIENT => true,
60 | ];
61 | if ($this->metadata === null) {
62 | $batch[OP_RECV_INITIAL_METADATA] = true;
63 | }
64 | $event = $this->call->startBatch($batch);
65 | if ($this->metadata === null) {
66 | $this->metadata = $event->metadata;
67 | }
68 | $status = $event->status;
69 | $this->trailing_metadata = $status->metadata;
70 |
71 | return [$this->_deserializeResponse($event->message), $status];
72 | }
73 |
74 | /**
75 | * @return mixed The metadata sent by the server
76 | */
77 | public function getMetadata()
78 | {
79 | if ($this->metadata === null) {
80 | $event = $this->call->startBatch([OP_RECV_INITIAL_METADATA => true]);
81 | $this->metadata = $event->metadata;
82 | }
83 | return $this->metadata;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------