diff options
author | Zhouyihai Ding <ddyihai@google.com> | 2018-01-30 13:26:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-30 13:26:47 -0800 |
commit | 9233201cc34e478e2a4d290c53bcf782a3864676 (patch) | |
tree | 059f3b67e8dd3e2104afccd481262f7ae882d0f2 | |
parent | 486a619af2e25bff9de034eb2888fb9fcdeedff4 (diff) | |
parent | 1ac45e116e4e6155b821d25d010f4e70b132827b (diff) | |
download | grpc-grpc-9233201cc34e478e2a4d290c53bcf782a3864676.tar.gz |
Merge pull request #13541 from Kunde21/php/constructor-cleanup
php: Removed opts checks in BaseStub when Channel is passed as argument
-rw-r--r-- | src/php/lib/Grpc/BaseStub.php | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index 67378a34a8..5f3a96feaa 100644 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -54,6 +54,18 @@ class BaseStub } unset($opts['update_metadata']); } + if (!empty($opts['grpc.ssl_target_name_override'])) { + $this->hostname_override = $opts['grpc.ssl_target_name_override']; + } + if ($channel) { + if (!is_a($channel, 'Grpc\Channel')) { + throw new \Exception('The channel argument is not a'. + 'Channel object'); + } + $this->channel = $channel; + return; + } + $package_config = json_decode( file_get_contents(dirname(__FILE__).'/../../composer.json'), true); if (!empty($opts['grpc.primary_user_agent'])) { @@ -61,9 +73,6 @@ class BaseStub } else { $opts['grpc.primary_user_agent'] = ''; } - if (!empty($opts['grpc.ssl_target_name_override'])) { - $this->hostname_override = $opts['grpc.ssl_target_name_override']; - } $opts['grpc.primary_user_agent'] .= 'grpc-php/'.$package_config['version']; if (!array_key_exists('credentials', $opts)) { @@ -71,15 +80,7 @@ class BaseStub 'required. Please see one of the '. 'ChannelCredentials::create methods'); } - if ($channel) { - if (!is_a($channel, 'Grpc\Channel')) { - throw new \Exception('The channel argument is not a'. - 'Channel object'); - } - $this->channel = $channel; - } else { - $this->channel = new Channel($hostname, $opts); - } + $this->channel = new Channel($hostname, $opts); } /** |