PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/google/grpc/grpc/src/lib/BaseStub.php +37 -37 1.2.3 → 1.4.2 View file →
@@ -16,9 +16,9 @@
16 16 * See the License for the specific language governing permissions and
17 17 * limitations under the License.
18 18 *
19 19 */
20 -namespace Dudlewebs\WPMCS\Grpc;
20 +namespace Dudlewebs\WPMCS\GCP\Grpc;
21 21
22 22 /**
23 23 * Base class for generated client stubs. Stub methods are expected to call
24 24 * _simpleRequest or _streamRequest and return the result.
@@ -40,16 +40,16 @@
40 40 * @param Channel|InterceptorChannel $channel An already created Channel or InterceptorChannel object (optional)
41 41 */
42 42 public function __construct($hostname, $opts, $channel = null)
43 43 {
44 - if (!method_exists('Dudlewebs\WPMCS\Grpc\ChannelCredentials', 'isDefaultRootsPemSet') || !ChannelCredentials::isDefaultRootsPemSet()) {
45 - $ssl_roots = file_get_contents(dirname(__FILE__) . '/../../etc/roots.pem');
44 + if (!\method_exists('Dudlewebs\\WPMCS\\GCP\\Grpc\\ChannelCredentials', 'isDefaultRootsPemSet') || !ChannelCredentials::isDefaultRootsPemSet()) {
45 + $ssl_roots = \file_get_contents(\dirname(__FILE__) . '/../../etc/roots.pem');
46 46 ChannelCredentials::setDefaultRootsPem($ssl_roots);
47 47 }
48 48 $this->hostname = $hostname;
49 49 $this->update_metadata = null;
50 50 if (isset($opts['update_metadata'])) {
51 - if (is_callable($opts['update_metadata'])) {
51 + if (\is_callable($opts['update_metadata'])) {
52 52 $this->update_metadata = $opts['update_metadata'];
53 53 }
54 54 unset($opts['update_metadata']);
55 55 }
@@ -65,9 +65,9 @@
65 65 return;
66 66 }
67 67 $this->call_invoker = new DefaultCallInvoker();
68 68 if ($channel) {
69 - if (!is_a($channel, 'Grpc\Channel') && !is_a($channel, 'Dudlewebs\WPMCS\Grpc\Internal\InterceptorChannel')) {
69 + if (!\is_a($channel, 'Grpc\\Channel') && !\is_a($channel, 'Dudlewebs\\WPMCS\\GCP\\Grpc\\Internal\\InterceptorChannel')) {
70 70 throw new \Exception('The channel argument is not a Channel object ' . 'or an InterceptorChannel object created by ' . 'Interceptor::intercept($channel, Interceptor|Interceptor[] $interceptors)');
71 71 }
72 72 $this->channel = $channel;
73 73 return;
@@ -80,20 +80,20 @@
80 80 $opts['grpc.primary_user_agent'] .= ' ';
81 81 } else {
82 82 $opts['grpc.primary_user_agent'] = '';
83 83 }
84 - if (defined('Dudlewebs\WPMCS\Grpc\VERSION')) {
85 - $version_str = \Dudlewebs\WPMCS\Grpc\VERSION;
84 + if (\defined('Dudlewebs\\WPMCS\\GCP\\Grpc\\VERSION')) {
85 + $version_str = \Dudlewebs\WPMCS\GCP\Grpc\VERSION;
86 86 } else {
87 - if (!file_exists($composerFile = __DIR__ . '/../../composer.json')) {
87 + if (!\file_exists($composerFile = __DIR__ . '/../../composer.json')) {
88 88 // for grpc/grpc-php subpackage
89 89 $composerFile = __DIR__ . '/../composer.json';
90 90 }
91 - $package_config = json_decode(file_get_contents($composerFile), \true);
91 + $package_config = \json_decode(\file_get_contents($composerFile), \true);
92 92 $version_str = $package_config['version'];
93 93 }
94 94 $opts['grpc.primary_user_agent'] .= 'grpc-php/' . $version_str;
95 - if (!array_key_exists('credentials', $opts)) {
95 + if (!\array_key_exists('credentials', $opts)) {
96 96 throw new \Exception("The opts['credentials'] key is now " . 'required. Please see one of the ' . 'ChannelCredentials::create methods');
97 97 }
98 98 return $opts;
99 99 }
@@ -189,13 +189,13 @@
189 189 // also provides the correct value of "aud" claim
190 190 // in the grpc_auth_metadata_context.service_url field.
191 191 // Trying to do the construction of "aud" field ourselves
192 192 // is bad.
193 - $last_slash_idx = strrpos($method, '/');
193 + $last_slash_idx = \strrpos($method, '/');
194 194 if ($last_slash_idx === \false) {
195 195 throw new \InvalidArgumentException('service name must have a slash');
196 196 }
197 - $service_name = substr($method, 0, $last_slash_idx);
197 + $service_name = \substr($method, 0, $last_slash_idx);
198 198 if ($this->hostname_override) {
199 199 $hostname = $this->hostname_override;
200 200 } else {
201 201 $hostname = $this->hostname;
@@ -200,11 +200,11 @@
200 200 } else {
201 201 $hostname = $this->hostname;
202 202 }
203 203 // Remove the port if it is 443
204 - // See https://github.com/grpc/grpc/blob/07c9f7a36b2a0d34fcffebc85649cf3b8c339b5d/src/core/lib/security/transport/client_auth_filter.cc#L205
205 - if (strlen($hostname) > 4 && substr($hostname, -4) === ":443") {
206 - $hostname = substr($hostname, 0, -4);
204 + // See https://github.com/grpc/grpc/blob/07c9f7a36b2a0d34fcffebc85649cf3b8c339b5d/src/core/filter/auth/client_auth_filter.cc#L205
205 + if (\strlen($hostname) > 4 && \substr($hostname, -4) === ":443") {
206 + $hostname = \substr($hostname, 0, -4);
207 207 }
208 208 return 'https://' . $hostname . $service_name;
209 209 }
210 210 /**
@@ -218,12 +218,12 @@
218 218 private function _validate_and_normalize_metadata($metadata)
219 219 {
220 220 $metadata_copy = [];
221 221 foreach ($metadata as $key => $value) {
222 - if (!preg_match('/^[.A-Za-z\d_-]+$/', $key)) {
222 + if (!\preg_match('/^[.A-Za-z\\d_-]+$/', $key)) {
223 223 throw new \InvalidArgumentException('Metadata keys must be nonempty strings containing only ' . 'alphanumeric characters, hyphens, underscores and dots');
224 224 }
225 - $metadata_copy[strtolower($key)] = $value;
225 + $metadata_copy[\strtolower($key)] = $value;
226 226 }
227 227 return $metadata_copy;
228 228 }
229 229 /**
@@ -235,13 +235,13 @@
235 235 * @return \Closure
236 236 */
237 237 private function _GrpcUnaryUnary($channel)
238 238 {
239 - return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use ($channel) {
239 + return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use($channel) {
240 240 $call = $this->call_invoker->UnaryCall($channel, $method, $deserialize, $options);
241 241 $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
242 - if (is_callable($this->update_metadata)) {
243 - $metadata = call_user_func($this->update_metadata, $metadata, $jwt_aud_uri);
242 + if (\is_callable($this->update_metadata)) {
243 + $metadata = \call_user_func($this->update_metadata, $metadata, $jwt_aud_uri);
244 244 }
245 245 $metadata = $this->_validate_and_normalize_metadata($metadata);
246 246 $call->start($argument, $metadata, $options);
247 247 return $call;
@@ -256,13 +256,13 @@
256 256 * @return \Closure
257 257 */
258 258 private function _GrpcStreamUnary($channel)
259 259 {
260 - return function ($method, $deserialize, array $metadata = [], array $options = []) use ($channel) {
260 + return function ($method, $deserialize, array $metadata = [], array $options = []) use($channel) {
261 261 $call = $this->call_invoker->ClientStreamingCall($channel, $method, $deserialize, $options);
262 262 $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
263 - if (is_callable($this->update_metadata)) {
264 - $metadata = call_user_func($this->update_metadata, $metadata, $jwt_aud_uri);
263 + if (\is_callable($this->update_metadata)) {
264 + $metadata = \call_user_func($this->update_metadata, $metadata, $jwt_aud_uri);
265 265 }
266 266 $metadata = $this->_validate_and_normalize_metadata($metadata);
267 267 $call->start($metadata);
268 268 return $call;
@@ -277,13 +277,13 @@
277 277 * @return \Closure
278 278 */
279 279 private function _GrpcUnaryStream($channel)
280 280 {
281 - return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use ($channel) {
281 + return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use($channel) {
282 282 $call = $this->call_invoker->ServerStreamingCall($channel, $method, $deserialize, $options);
283 283 $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
284 - if (is_callable($this->update_metadata)) {
285 - $metadata = call_user_func($this->update_metadata, $metadata, $jwt_aud_uri);
284 + if (\is_callable($this->update_metadata)) {
285 + $metadata = \call_user_func($this->update_metadata, $metadata, $jwt_aud_uri);
286 286 }
287 287 $metadata = $this->_validate_and_normalize_metadata($metadata);
288 288 $call->start($argument, $metadata, $options);
289 289 return $call;
@@ -298,13 +298,13 @@
298 298 * @return \Closure
299 299 */
300 300 private function _GrpcStreamStream($channel)
301 301 {
302 - return function ($method, $deserialize, array $metadata = [], array $options = []) use ($channel) {
302 + return function ($method, $deserialize, array $metadata = [], array $options = []) use($channel) {
303 303 $call = $this->call_invoker->BidiStreamingCall($channel, $method, $deserialize, $options);
304 304 $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
305 - if (is_callable($this->update_metadata)) {
306 - $metadata = call_user_func($this->update_metadata, $metadata, $jwt_aud_uri);
305 + if (\is_callable($this->update_metadata)) {
306 + $metadata = \call_user_func($this->update_metadata, $metadata, $jwt_aud_uri);
307 307 }
308 308 $metadata = $this->_validate_and_normalize_metadata($metadata);
309 309 $call->start($metadata);
310 310 return $call;
@@ -319,10 +319,10 @@
319 319 * @return \Closure
320 320 */
321 321 private function _UnaryUnaryCallFactory($channel)
322 322 {
323 - if (is_a($channel, 'Dudlewebs\WPMCS\Grpc\Internal\InterceptorChannel')) {
324 - return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use ($channel) {
323 + if (\is_a($channel, 'Dudlewebs\\WPMCS\\GCP\\Grpc\\Internal\\InterceptorChannel')) {
324 + return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use($channel) {
325 325 return $channel->getInterceptor()->interceptUnaryUnary($method, $argument, $deserialize, $this->_UnaryUnaryCallFactory($channel->getNext()), $metadata, $options);
326 326 };
327 327 }
328 328 return $this->_GrpcUnaryUnary($channel);
@@ -336,10 +336,10 @@
336 336 * @return \Closure
337 337 */
338 338 private function _UnaryStreamCallFactory($channel)
339 339 {
340 - if (is_a($channel, 'Dudlewebs\WPMCS\Grpc\Internal\InterceptorChannel')) {
341 - return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use ($channel) {
340 + if (\is_a($channel, 'Dudlewebs\\WPMCS\\GCP\\Grpc\\Internal\\InterceptorChannel')) {
341 + return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use($channel) {
342 342 return $channel->getInterceptor()->interceptUnaryStream($method, $argument, $deserialize, $this->_UnaryStreamCallFactory($channel->getNext()), $metadata, $options);
343 343 };
344 344 }
345 345 return $this->_GrpcUnaryStream($channel);
@@ -353,10 +353,10 @@
353 353 * @return \Closure
354 354 */
355 355 private function _StreamUnaryCallFactory($channel)
356 356 {
357 - if (is_a($channel, 'Dudlewebs\WPMCS\Grpc\Internal\InterceptorChannel')) {
358 - return function ($method, $deserialize, array $metadata = [], array $options = []) use ($channel) {
357 + if (\is_a($channel, 'Dudlewebs\\WPMCS\\GCP\\Grpc\\Internal\\InterceptorChannel')) {
358 + return function ($method, $deserialize, array $metadata = [], array $options = []) use($channel) {
359 359 return $channel->getInterceptor()->interceptStreamUnary($method, $deserialize, $this->_StreamUnaryCallFactory($channel->getNext()), $metadata, $options);
360 360 };
361 361 }
362 362 return $this->_GrpcStreamUnary($channel);
@@ -370,10 +370,10 @@
370 370 * @return \Closure
371 371 */
372 372 private function _StreamStreamCallFactory($channel)
373 373 {
374 - if (is_a($channel, 'Dudlewebs\WPMCS\Grpc\Internal\InterceptorChannel')) {
375 - return function ($method, $deserialize, array $metadata = [], array $options = []) use ($channel) {
374 + if (\is_a($channel, 'Dudlewebs\\WPMCS\\GCP\\Grpc\\Internal\\InterceptorChannel')) {
375 + return function ($method, $deserialize, array $metadata = [], array $options = []) use($channel) {
376 376 return $channel->getInterceptor()->interceptStreamStream($method, $deserialize, $this->_StreamStreamCallFactory($channel->getNext()), $metadata, $options);
377 377 };
378 378 }
379 379 return $this->_GrpcStreamStream($channel);