Merge pull request #6503 from kpayson64/python_3_support

Initial Python3 support
diff --git a/doc/command_line_tool.md b/doc/command_line_tool.md
new file mode 100644
index 0000000..89a7054
--- /dev/null
+++ b/doc/command_line_tool.md
@@ -0,0 +1,77 @@
+# gRPC command line tool
+
+## Overview
+
+This document describes the command line tool that comes with gRPC repository. It is desireable to have command line
+tools written in other languages to roughly follow the same syntax and flags.
+
+At this point, the tool needs to be built from source, and it should be moved out to grpc-tools repository as a stand
+alone application once it is mature enough.
+
+## Core functionality
+
+The command line tool can do the following things:
+
+- Send unary rpc.
+- Attach metadata and display received metadata.
+- Handle common authentication to server.
+- Find the request/response types from a given proto file.
+- Read proto request in text form.
+- Read request in wire form (for protobuf messages, this means serialized binary form).
+- Display proto response in text form.
+- Write response in wire form to a file.
+
+The command line tool should support the following things:
+
+- List server services and methods through server reflection.
+- Infer request/response types from server reflection result.
+- Fine-grained auth control (such as, use this oauth token to talk to the server).
+- Send streaming rpc.
+
+## Code location
+
+To use the tool, you need to get the grpc repository and in the grpc directory execute
+
+```
+$ make grpc_cli
+```
+
+The main file can be found at
+https://github.com/grpc/grpc/blob/master/test/cpp/util/grpc_cli.cc
+
+## Usage
+
+### Basic usage
+
+Send a rpc to a helloworld server at `localhost:50051`:
+
+```
+$ bins/opt/grpc_cli call localhost:50051 SayHello examples/protos/helloworld.proto \
+    "name: 'world'"  --enable_ssl=false
+```
+
+On success, the tool will print out
+
+```
+Rpc succeeded with OK status
+Response: 
+ message: "Hello world"
+```
+
+The `localhost:50051` part indicates the server you are connecting to. `SayHello` is (part of) the
+gRPC method string. Then there is the path to the proto file containing the service definition,
+if it is not under current directory, you can use `--proto_path` to specify a new search root.
+`"name: 'world'"` is the text format of the request proto message. 
+We are not using ssl here by `--enable_ssl=false`. For information on more
+flags, look at the comments of `grpc_cli.cc`.
+
+### Send non-proto rpc
+
+For using gRPC with protocols other than probobuf, you will need the exact method name string
+and a file containing the raw bytes to be sent on the wire
+
+```
+$ bins/opt/grpc_cli call localhost:50051 /helloworld.Greeter/SayHello --input_binary_file=input.bin \
+    --output_binary_file=output.bin
+```
+On success, you will need to read or decode the response from the `output.bin` file.
diff --git a/examples/php/greeter_client.php b/examples/php/greeter_client.php
index 718ef88..a5c0865 100644
--- a/examples/php/greeter_client.php
+++ b/examples/php/greeter_client.php
@@ -32,19 +32,21 @@
  *
  */
 
-require dirname(__FILE__) . '/vendor/autoload.php';
-require dirname(__FILE__) . '/helloworld.php';
+require dirname(__FILE__).'/vendor/autoload.php';
+require dirname(__FILE__).'/helloworld.php';
 
-function greet($name) {
-  $client = new helloworld\GreeterClient('localhost:50051', [
-    'credentials' => Grpc\ChannelCredentials::createInsecure()
-  ]);
-  $request = new helloworld\HelloRequest();
-  $request->setName($name);
-  list($reply, $status) = $client->SayHello($request)->wait();
-  $message = $reply->getMessage();
-  return $message;
+function greet($name)
+{
+    $client = new helloworld\GreeterClient('localhost:50051', [
+        'credentials' => Grpc\ChannelCredentials::createInsecure(),
+    ]);
+    $request = new helloworld\HelloRequest();
+    $request->setName($name);
+    list($reply, $status) = $client->SayHello($request)->wait();
+    $message = $reply->getMessage();
+
+    return $message;
 }
 
 $name = !empty($argv[1]) ? $argv[1] : 'world';
-print(greet($name)."\n");
+echo greet($name)."\n";
diff --git a/examples/php/helloworld.php b/examples/php/helloworld.php
index 50923e6..697f52a 100644
--- a/examples/php/helloworld.php
+++ b/examples/php/helloworld.php
@@ -5,154 +5,164 @@
 
 namespace helloworld {
 
-  class HelloRequest extends \DrSlump\Protobuf\Message {
-
-    /**  @var string */
+  class HelloRequest extends \DrSlump\Protobuf\Message
+  {
+      /**  @var string */
     public $name = null;
-    
 
     /** @var \Closure[] */
     protected static $__extensions = array();
 
-    public static function descriptor()
-    {
-      $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'helloworld.HelloRequest');
+      public static function descriptor()
+      {
+          $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'helloworld.HelloRequest');
 
       // OPTIONAL STRING name = 1
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 1;
-      $f->name      = "name";
-      $f->type      = \DrSlump\Protobuf::TYPE_STRING;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $descriptor->addField($f);
+          $f->number = 1;
+          $f->name = 'name';
+          $f->type = \DrSlump\Protobuf::TYPE_STRING;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $descriptor->addField($f);
 
-      foreach (self::$__extensions as $cb) {
-        $descriptor->addField($cb(), true);
+          foreach (self::$__extensions as $cb) {
+              $descriptor->addField($cb(), true);
+          }
+
+          return $descriptor;
       }
 
-      return $descriptor;
+    /**
+     * Check if <name> has a value.
+     *
+     * @return bool
+     */
+    public function hasName()
+    {
+        return $this->_has(1);
     }
 
     /**
-     * Check if <name> has a value
-     *
-     * @return boolean
-     */
-    public function hasName(){
-      return $this->_has(1);
-    }
-    
-    /**
-     * Clear <name> value
+     * Clear <name> value.
      *
      * @return \helloworld\HelloRequest
      */
-    public function clearName(){
-      return $this->_clear(1);
+    public function clearName()
+    {
+        return $this->_clear(1);
     }
-    
+
     /**
-     * Get <name> value
+     * Get <name> value.
      *
      * @return string
      */
-    public function getName(){
-      return $this->_get(1);
+    public function getName()
+    {
+        return $this->_get(1);
     }
-    
+
     /**
-     * Set <name> value
+     * Set <name> value.
      *
      * @param string $value
+     *
      * @return \helloworld\HelloRequest
      */
-    public function setName( $value){
-      return $this->_set(1, $value);
+    public function setName($value)
+    {
+        return $this->_set(1, $value);
     }
   }
 }
 
 namespace helloworld {
 
-  class HelloReply extends \DrSlump\Protobuf\Message {
-
-    /**  @var string */
+  class HelloReply extends \DrSlump\Protobuf\Message
+  {
+      /**  @var string */
     public $message = null;
-    
 
     /** @var \Closure[] */
     protected static $__extensions = array();
 
-    public static function descriptor()
-    {
-      $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'helloworld.HelloReply');
+      public static function descriptor()
+      {
+          $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'helloworld.HelloReply');
 
       // OPTIONAL STRING message = 1
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 1;
-      $f->name      = "message";
-      $f->type      = \DrSlump\Protobuf::TYPE_STRING;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $descriptor->addField($f);
+          $f->number = 1;
+          $f->name = 'message';
+          $f->type = \DrSlump\Protobuf::TYPE_STRING;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $descriptor->addField($f);
 
-      foreach (self::$__extensions as $cb) {
-        $descriptor->addField($cb(), true);
+          foreach (self::$__extensions as $cb) {
+              $descriptor->addField($cb(), true);
+          }
+
+          return $descriptor;
       }
 
-      return $descriptor;
+    /**
+     * Check if <message> has a value.
+     *
+     * @return bool
+     */
+    public function hasMessage()
+    {
+        return $this->_has(1);
     }
 
     /**
-     * Check if <message> has a value
-     *
-     * @return boolean
-     */
-    public function hasMessage(){
-      return $this->_has(1);
-    }
-    
-    /**
-     * Clear <message> value
+     * Clear <message> value.
      *
      * @return \helloworld\HelloReply
      */
-    public function clearMessage(){
-      return $this->_clear(1);
+    public function clearMessage()
+    {
+        return $this->_clear(1);
     }
-    
+
     /**
-     * Get <message> value
+     * Get <message> value.
      *
      * @return string
      */
-    public function getMessage(){
-      return $this->_get(1);
+    public function getMessage()
+    {
+        return $this->_get(1);
     }
-    
+
     /**
-     * Set <message> value
+     * Set <message> value.
      *
      * @param string $value
+     *
      * @return \helloworld\HelloReply
      */
-    public function setMessage( $value){
-      return $this->_set(1, $value);
+    public function setMessage($value)
+    {
+        return $this->_set(1, $value);
     }
   }
 }
 
 namespace helloworld {
 
-  class GreeterClient extends \Grpc\BaseStub {
-
-    public function __construct($hostname, $opts) {
-      parent::__construct($hostname, $opts);
-    }
+  class GreeterClient extends \Grpc\BaseStub
+  {
+      public function __construct($hostname, $opts)
+      {
+          parent::__construct($hostname, $opts);
+      }
     /**
      * @param helloworld\HelloRequest $input
      */
-    public function SayHello(\helloworld\HelloRequest $argument, $metadata = array(), $options = array()) {
-      return $this->_simpleRequest('/helloworld.Greeter/SayHello', $argument, '\helloworld\HelloReply::deserialize', $metadata, $options);
+    public function SayHello(\helloworld\HelloRequest $argument, $metadata = array(), $options = array())
+    {
+        return $this->_simpleRequest('/helloworld.Greeter/SayHello', $argument, '\helloworld\HelloReply::deserialize', $metadata, $options);
     }
   }
 }
diff --git a/examples/php/route_guide/route_guide.php b/examples/php/route_guide/route_guide.php
index 0de3198..65045d0 100644
--- a/examples/php/route_guide/route_guide.php
+++ b/examples/php/route_guide/route_guide.php
@@ -5,725 +5,785 @@
 
 namespace routeguide {
 
-  class Point extends \DrSlump\Protobuf\Message {
+  class Point extends \DrSlump\Protobuf\Message
+  {
+      /**  @var int */
+    public $latitude = 0;
 
     /**  @var int */
-    public $latitude = 0;
-    
-    /**  @var int */
     public $longitude = 0;
-    
 
     /** @var \Closure[] */
     protected static $__extensions = array();
 
-    public static function descriptor()
-    {
-      $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Point');
+      public static function descriptor()
+      {
+          $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Point');
 
       // OPTIONAL INT32 latitude = 1
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 1;
-      $f->name      = "latitude";
-      $f->type      = \DrSlump\Protobuf::TYPE_INT32;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->default   = 0;
-      $descriptor->addField($f);
+          $f->number = 1;
+          $f->name = 'latitude';
+          $f->type = \DrSlump\Protobuf::TYPE_INT32;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->default = 0;
+          $descriptor->addField($f);
 
       // OPTIONAL INT32 longitude = 2
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 2;
-      $f->name      = "longitude";
-      $f->type      = \DrSlump\Protobuf::TYPE_INT32;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->default   = 0;
-      $descriptor->addField($f);
+          $f->number = 2;
+          $f->name = 'longitude';
+          $f->type = \DrSlump\Protobuf::TYPE_INT32;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->default = 0;
+          $descriptor->addField($f);
 
-      foreach (self::$__extensions as $cb) {
-        $descriptor->addField($cb(), true);
+          foreach (self::$__extensions as $cb) {
+              $descriptor->addField($cb(), true);
+          }
+
+          return $descriptor;
       }
 
-      return $descriptor;
+    /**
+     * Check if <latitude> has a value.
+     *
+     * @return bool
+     */
+    public function hasLatitude()
+    {
+        return $this->_has(1);
     }
 
     /**
-     * Check if <latitude> has a value
-     *
-     * @return boolean
-     */
-    public function hasLatitude(){
-      return $this->_has(1);
-    }
-    
-    /**
-     * Clear <latitude> value
+     * Clear <latitude> value.
      *
      * @return \routeguide\Point
      */
-    public function clearLatitude(){
-      return $this->_clear(1);
+    public function clearLatitude()
+    {
+        return $this->_clear(1);
     }
-    
+
     /**
-     * Get <latitude> value
+     * Get <latitude> value.
      *
      * @return int
      */
-    public function getLatitude(){
-      return $this->_get(1);
+    public function getLatitude()
+    {
+        return $this->_get(1);
     }
-    
+
     /**
-     * Set <latitude> value
+     * Set <latitude> value.
      *
      * @param int $value
-     * @return \routeguide\Point
-     */
-    public function setLatitude( $value){
-      return $this->_set(1, $value);
-    }
-    
-    /**
-     * Check if <longitude> has a value
-     *
-     * @return boolean
-     */
-    public function hasLongitude(){
-      return $this->_has(2);
-    }
-    
-    /**
-     * Clear <longitude> value
      *
      * @return \routeguide\Point
      */
-    public function clearLongitude(){
-      return $this->_clear(2);
+    public function setLatitude($value)
+    {
+        return $this->_set(1, $value);
     }
-    
+
     /**
-     * Get <longitude> value
+     * Check if <longitude> has a value.
+     *
+     * @return bool
+     */
+    public function hasLongitude()
+    {
+        return $this->_has(2);
+    }
+
+    /**
+     * Clear <longitude> value.
+     *
+     * @return \routeguide\Point
+     */
+    public function clearLongitude()
+    {
+        return $this->_clear(2);
+    }
+
+    /**
+     * Get <longitude> value.
      *
      * @return int
      */
-    public function getLongitude(){
-      return $this->_get(2);
+    public function getLongitude()
+    {
+        return $this->_get(2);
     }
-    
+
     /**
-     * Set <longitude> value
+     * Set <longitude> value.
      *
      * @param int $value
+     *
      * @return \routeguide\Point
      */
-    public function setLongitude( $value){
-      return $this->_set(2, $value);
+    public function setLongitude($value)
+    {
+        return $this->_set(2, $value);
     }
   }
 }
 
 namespace routeguide {
 
-  class Rectangle extends \DrSlump\Protobuf\Message {
+  class Rectangle extends \DrSlump\Protobuf\Message
+  {
+      /**  @var \routeguide\Point */
+    public $lo = null;
 
     /**  @var \routeguide\Point */
-    public $lo = null;
-    
-    /**  @var \routeguide\Point */
     public $hi = null;
-    
 
     /** @var \Closure[] */
     protected static $__extensions = array();
 
-    public static function descriptor()
-    {
-      $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Rectangle');
+      public static function descriptor()
+      {
+          $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Rectangle');
 
       // OPTIONAL MESSAGE lo = 1
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 1;
-      $f->name      = "lo";
-      $f->type      = \DrSlump\Protobuf::TYPE_MESSAGE;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->reference = '\routeguide\Point';
-      $descriptor->addField($f);
+          $f->number = 1;
+          $f->name = 'lo';
+          $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->reference = '\routeguide\Point';
+          $descriptor->addField($f);
 
       // OPTIONAL MESSAGE hi = 2
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 2;
-      $f->name      = "hi";
-      $f->type      = \DrSlump\Protobuf::TYPE_MESSAGE;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->reference = '\routeguide\Point';
-      $descriptor->addField($f);
+          $f->number = 2;
+          $f->name = 'hi';
+          $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->reference = '\routeguide\Point';
+          $descriptor->addField($f);
 
-      foreach (self::$__extensions as $cb) {
-        $descriptor->addField($cb(), true);
+          foreach (self::$__extensions as $cb) {
+              $descriptor->addField($cb(), true);
+          }
+
+          return $descriptor;
       }
 
-      return $descriptor;
+    /**
+     * Check if <lo> has a value.
+     *
+     * @return bool
+     */
+    public function hasLo()
+    {
+        return $this->_has(1);
     }
 
     /**
-     * Check if <lo> has a value
-     *
-     * @return boolean
-     */
-    public function hasLo(){
-      return $this->_has(1);
-    }
-    
-    /**
-     * Clear <lo> value
+     * Clear <lo> value.
      *
      * @return \routeguide\Rectangle
      */
-    public function clearLo(){
-      return $this->_clear(1);
+    public function clearLo()
+    {
+        return $this->_clear(1);
     }
-    
+
     /**
-     * Get <lo> value
+     * Get <lo> value.
      *
      * @return \routeguide\Point
      */
-    public function getLo(){
-      return $this->_get(1);
+    public function getLo()
+    {
+        return $this->_get(1);
     }
-    
+
     /**
-     * Set <lo> value
+     * Set <lo> value.
      *
      * @param \routeguide\Point $value
-     * @return \routeguide\Rectangle
-     */
-    public function setLo(\routeguide\Point $value){
-      return $this->_set(1, $value);
-    }
-    
-    /**
-     * Check if <hi> has a value
-     *
-     * @return boolean
-     */
-    public function hasHi(){
-      return $this->_has(2);
-    }
-    
-    /**
-     * Clear <hi> value
      *
      * @return \routeguide\Rectangle
      */
-    public function clearHi(){
-      return $this->_clear(2);
+    public function setLo(\routeguide\Point $value)
+    {
+        return $this->_set(1, $value);
     }
-    
+
     /**
-     * Get <hi> value
+     * Check if <hi> has a value.
+     *
+     * @return bool
+     */
+    public function hasHi()
+    {
+        return $this->_has(2);
+    }
+
+    /**
+     * Clear <hi> value.
+     *
+     * @return \routeguide\Rectangle
+     */
+    public function clearHi()
+    {
+        return $this->_clear(2);
+    }
+
+    /**
+     * Get <hi> value.
      *
      * @return \routeguide\Point
      */
-    public function getHi(){
-      return $this->_get(2);
+    public function getHi()
+    {
+        return $this->_get(2);
     }
-    
+
     /**
-     * Set <hi> value
+     * Set <hi> value.
      *
      * @param \routeguide\Point $value
+     *
      * @return \routeguide\Rectangle
      */
-    public function setHi(\routeguide\Point $value){
-      return $this->_set(2, $value);
+    public function setHi(\routeguide\Point $value)
+    {
+        return $this->_set(2, $value);
     }
   }
 }
 
 namespace routeguide {
 
-  class Feature extends \DrSlump\Protobuf\Message {
-
-    /**  @var string */
+  class Feature extends \DrSlump\Protobuf\Message
+  {
+      /**  @var string */
     public $name = null;
-    
+
     /**  @var \routeguide\Point */
     public $location = null;
-    
 
     /** @var \Closure[] */
     protected static $__extensions = array();
 
-    public static function descriptor()
-    {
-      $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Feature');
+      public static function descriptor()
+      {
+          $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Feature');
 
       // OPTIONAL STRING name = 1
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 1;
-      $f->name      = "name";
-      $f->type      = \DrSlump\Protobuf::TYPE_STRING;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $descriptor->addField($f);
+          $f->number = 1;
+          $f->name = 'name';
+          $f->type = \DrSlump\Protobuf::TYPE_STRING;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $descriptor->addField($f);
 
       // OPTIONAL MESSAGE location = 2
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 2;
-      $f->name      = "location";
-      $f->type      = \DrSlump\Protobuf::TYPE_MESSAGE;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->reference = '\routeguide\Point';
-      $descriptor->addField($f);
+          $f->number = 2;
+          $f->name = 'location';
+          $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->reference = '\routeguide\Point';
+          $descriptor->addField($f);
 
-      foreach (self::$__extensions as $cb) {
-        $descriptor->addField($cb(), true);
+          foreach (self::$__extensions as $cb) {
+              $descriptor->addField($cb(), true);
+          }
+
+          return $descriptor;
       }
 
-      return $descriptor;
+    /**
+     * Check if <name> has a value.
+     *
+     * @return bool
+     */
+    public function hasName()
+    {
+        return $this->_has(1);
     }
 
     /**
-     * Check if <name> has a value
-     *
-     * @return boolean
-     */
-    public function hasName(){
-      return $this->_has(1);
-    }
-    
-    /**
-     * Clear <name> value
+     * Clear <name> value.
      *
      * @return \routeguide\Feature
      */
-    public function clearName(){
-      return $this->_clear(1);
+    public function clearName()
+    {
+        return $this->_clear(1);
     }
-    
+
     /**
-     * Get <name> value
+     * Get <name> value.
      *
      * @return string
      */
-    public function getName(){
-      return $this->_get(1);
+    public function getName()
+    {
+        return $this->_get(1);
     }
-    
+
     /**
-     * Set <name> value
+     * Set <name> value.
      *
      * @param string $value
-     * @return \routeguide\Feature
-     */
-    public function setName( $value){
-      return $this->_set(1, $value);
-    }
-    
-    /**
-     * Check if <location> has a value
-     *
-     * @return boolean
-     */
-    public function hasLocation(){
-      return $this->_has(2);
-    }
-    
-    /**
-     * Clear <location> value
      *
      * @return \routeguide\Feature
      */
-    public function clearLocation(){
-      return $this->_clear(2);
+    public function setName($value)
+    {
+        return $this->_set(1, $value);
     }
-    
+
     /**
-     * Get <location> value
+     * Check if <location> has a value.
+     *
+     * @return bool
+     */
+    public function hasLocation()
+    {
+        return $this->_has(2);
+    }
+
+    /**
+     * Clear <location> value.
+     *
+     * @return \routeguide\Feature
+     */
+    public function clearLocation()
+    {
+        return $this->_clear(2);
+    }
+
+    /**
+     * Get <location> value.
      *
      * @return \routeguide\Point
      */
-    public function getLocation(){
-      return $this->_get(2);
+    public function getLocation()
+    {
+        return $this->_get(2);
     }
-    
+
     /**
-     * Set <location> value
+     * Set <location> value.
      *
      * @param \routeguide\Point $value
+     *
      * @return \routeguide\Feature
      */
-    public function setLocation(\routeguide\Point $value){
-      return $this->_set(2, $value);
+    public function setLocation(\routeguide\Point $value)
+    {
+        return $this->_set(2, $value);
     }
   }
 }
 
 namespace routeguide {
 
-  class RouteNote extends \DrSlump\Protobuf\Message {
-
-    /**  @var \routeguide\Point */
+  class RouteNote extends \DrSlump\Protobuf\Message
+  {
+      /**  @var \routeguide\Point */
     public $location = null;
-    
+
     /**  @var string */
     public $message = null;
-    
 
     /** @var \Closure[] */
     protected static $__extensions = array();
 
-    public static function descriptor()
-    {
-      $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteNote');
+      public static function descriptor()
+      {
+          $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteNote');
 
       // OPTIONAL MESSAGE location = 1
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 1;
-      $f->name      = "location";
-      $f->type      = \DrSlump\Protobuf::TYPE_MESSAGE;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->reference = '\routeguide\Point';
-      $descriptor->addField($f);
+          $f->number = 1;
+          $f->name = 'location';
+          $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->reference = '\routeguide\Point';
+          $descriptor->addField($f);
 
       // OPTIONAL STRING message = 2
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 2;
-      $f->name      = "message";
-      $f->type      = \DrSlump\Protobuf::TYPE_STRING;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $descriptor->addField($f);
+          $f->number = 2;
+          $f->name = 'message';
+          $f->type = \DrSlump\Protobuf::TYPE_STRING;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $descriptor->addField($f);
 
-      foreach (self::$__extensions as $cb) {
-        $descriptor->addField($cb(), true);
+          foreach (self::$__extensions as $cb) {
+              $descriptor->addField($cb(), true);
+          }
+
+          return $descriptor;
       }
 
-      return $descriptor;
+    /**
+     * Check if <location> has a value.
+     *
+     * @return bool
+     */
+    public function hasLocation()
+    {
+        return $this->_has(1);
     }
 
     /**
-     * Check if <location> has a value
-     *
-     * @return boolean
-     */
-    public function hasLocation(){
-      return $this->_has(1);
-    }
-    
-    /**
-     * Clear <location> value
+     * Clear <location> value.
      *
      * @return \routeguide\RouteNote
      */
-    public function clearLocation(){
-      return $this->_clear(1);
+    public function clearLocation()
+    {
+        return $this->_clear(1);
     }
-    
+
     /**
-     * Get <location> value
+     * Get <location> value.
      *
      * @return \routeguide\Point
      */
-    public function getLocation(){
-      return $this->_get(1);
+    public function getLocation()
+    {
+        return $this->_get(1);
     }
-    
+
     /**
-     * Set <location> value
+     * Set <location> value.
      *
      * @param \routeguide\Point $value
-     * @return \routeguide\RouteNote
-     */
-    public function setLocation(\routeguide\Point $value){
-      return $this->_set(1, $value);
-    }
-    
-    /**
-     * Check if <message> has a value
-     *
-     * @return boolean
-     */
-    public function hasMessage(){
-      return $this->_has(2);
-    }
-    
-    /**
-     * Clear <message> value
      *
      * @return \routeguide\RouteNote
      */
-    public function clearMessage(){
-      return $this->_clear(2);
+    public function setLocation(\routeguide\Point $value)
+    {
+        return $this->_set(1, $value);
     }
-    
+
     /**
-     * Get <message> value
+     * Check if <message> has a value.
+     *
+     * @return bool
+     */
+    public function hasMessage()
+    {
+        return $this->_has(2);
+    }
+
+    /**
+     * Clear <message> value.
+     *
+     * @return \routeguide\RouteNote
+     */
+    public function clearMessage()
+    {
+        return $this->_clear(2);
+    }
+
+    /**
+     * Get <message> value.
      *
      * @return string
      */
-    public function getMessage(){
-      return $this->_get(2);
+    public function getMessage()
+    {
+        return $this->_get(2);
     }
-    
+
     /**
-     * Set <message> value
+     * Set <message> value.
      *
      * @param string $value
+     *
      * @return \routeguide\RouteNote
      */
-    public function setMessage( $value){
-      return $this->_set(2, $value);
+    public function setMessage($value)
+    {
+        return $this->_set(2, $value);
     }
   }
 }
 
 namespace routeguide {
 
-  class RouteSummary extends \DrSlump\Protobuf\Message {
+  class RouteSummary extends \DrSlump\Protobuf\Message
+  {
+      /**  @var int */
+    public $point_count = 0;
 
     /**  @var int */
-    public $point_count = 0;
-    
-    /**  @var int */
     public $feature_count = 0;
-    
+
     /**  @var int */
     public $distance = 0;
-    
+
     /**  @var int */
     public $elapsed_time = 0;
-    
 
     /** @var \Closure[] */
     protected static $__extensions = array();
 
-    public static function descriptor()
-    {
-      $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteSummary');
+      public static function descriptor()
+      {
+          $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteSummary');
 
       // OPTIONAL INT32 point_count = 1
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 1;
-      $f->name      = "point_count";
-      $f->type      = \DrSlump\Protobuf::TYPE_INT32;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->default   = 0;
-      $descriptor->addField($f);
+          $f->number = 1;
+          $f->name = 'point_count';
+          $f->type = \DrSlump\Protobuf::TYPE_INT32;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->default = 0;
+          $descriptor->addField($f);
 
       // OPTIONAL INT32 feature_count = 2
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 2;
-      $f->name      = "feature_count";
-      $f->type      = \DrSlump\Protobuf::TYPE_INT32;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->default   = 0;
-      $descriptor->addField($f);
+          $f->number = 2;
+          $f->name = 'feature_count';
+          $f->type = \DrSlump\Protobuf::TYPE_INT32;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->default = 0;
+          $descriptor->addField($f);
 
       // OPTIONAL INT32 distance = 3
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 3;
-      $f->name      = "distance";
-      $f->type      = \DrSlump\Protobuf::TYPE_INT32;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->default   = 0;
-      $descriptor->addField($f);
+          $f->number = 3;
+          $f->name = 'distance';
+          $f->type = \DrSlump\Protobuf::TYPE_INT32;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->default = 0;
+          $descriptor->addField($f);
 
       // OPTIONAL INT32 elapsed_time = 4
       $f = new \DrSlump\Protobuf\Field();
-      $f->number    = 4;
-      $f->name      = "elapsed_time";
-      $f->type      = \DrSlump\Protobuf::TYPE_INT32;
-      $f->rule      = \DrSlump\Protobuf::RULE_OPTIONAL;
-      $f->default   = 0;
-      $descriptor->addField($f);
+          $f->number = 4;
+          $f->name = 'elapsed_time';
+          $f->type = \DrSlump\Protobuf::TYPE_INT32;
+          $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+          $f->default = 0;
+          $descriptor->addField($f);
 
-      foreach (self::$__extensions as $cb) {
-        $descriptor->addField($cb(), true);
+          foreach (self::$__extensions as $cb) {
+              $descriptor->addField($cb(), true);
+          }
+
+          return $descriptor;
       }
 
-      return $descriptor;
+    /**
+     * Check if <point_count> has a value.
+     *
+     * @return bool
+     */
+    public function hasPointCount()
+    {
+        return $this->_has(1);
     }
 
     /**
-     * Check if <point_count> has a value
-     *
-     * @return boolean
-     */
-    public function hasPointCount(){
-      return $this->_has(1);
-    }
-    
-    /**
-     * Clear <point_count> value
+     * Clear <point_count> value.
      *
      * @return \routeguide\RouteSummary
      */
-    public function clearPointCount(){
-      return $this->_clear(1);
+    public function clearPointCount()
+    {
+        return $this->_clear(1);
     }
-    
+
     /**
-     * Get <point_count> value
+     * Get <point_count> value.
      *
      * @return int
      */
-    public function getPointCount(){
-      return $this->_get(1);
+    public function getPointCount()
+    {
+        return $this->_get(1);
     }
-    
+
     /**
-     * Set <point_count> value
+     * Set <point_count> value.
      *
      * @param int $value
-     * @return \routeguide\RouteSummary
-     */
-    public function setPointCount( $value){
-      return $this->_set(1, $value);
-    }
-    
-    /**
-     * Check if <feature_count> has a value
-     *
-     * @return boolean
-     */
-    public function hasFeatureCount(){
-      return $this->_has(2);
-    }
-    
-    /**
-     * Clear <feature_count> value
      *
      * @return \routeguide\RouteSummary
      */
-    public function clearFeatureCount(){
-      return $this->_clear(2);
+    public function setPointCount($value)
+    {
+        return $this->_set(1, $value);
     }
-    
+
     /**
-     * Get <feature_count> value
+     * Check if <feature_count> has a value.
+     *
+     * @return bool
+     */
+    public function hasFeatureCount()
+    {
+        return $this->_has(2);
+    }
+
+    /**
+     * Clear <feature_count> value.
+     *
+     * @return \routeguide\RouteSummary
+     */
+    public function clearFeatureCount()
+    {
+        return $this->_clear(2);
+    }
+
+    /**
+     * Get <feature_count> value.
      *
      * @return int
      */
-    public function getFeatureCount(){
-      return $this->_get(2);
+    public function getFeatureCount()
+    {
+        return $this->_get(2);
     }
-    
+
     /**
-     * Set <feature_count> value
+     * Set <feature_count> value.
      *
      * @param int $value
-     * @return \routeguide\RouteSummary
-     */
-    public function setFeatureCount( $value){
-      return $this->_set(2, $value);
-    }
-    
-    /**
-     * Check if <distance> has a value
-     *
-     * @return boolean
-     */
-    public function hasDistance(){
-      return $this->_has(3);
-    }
-    
-    /**
-     * Clear <distance> value
      *
      * @return \routeguide\RouteSummary
      */
-    public function clearDistance(){
-      return $this->_clear(3);
+    public function setFeatureCount($value)
+    {
+        return $this->_set(2, $value);
     }
-    
+
     /**
-     * Get <distance> value
+     * Check if <distance> has a value.
+     *
+     * @return bool
+     */
+    public function hasDistance()
+    {
+        return $this->_has(3);
+    }
+
+    /**
+     * Clear <distance> value.
+     *
+     * @return \routeguide\RouteSummary
+     */
+    public function clearDistance()
+    {
+        return $this->_clear(3);
+    }
+
+    /**
+     * Get <distance> value.
      *
      * @return int
      */
-    public function getDistance(){
-      return $this->_get(3);
+    public function getDistance()
+    {
+        return $this->_get(3);
     }
-    
+
     /**
-     * Set <distance> value
+     * Set <distance> value.
      *
      * @param int $value
-     * @return \routeguide\RouteSummary
-     */
-    public function setDistance( $value){
-      return $this->_set(3, $value);
-    }
-    
-    /**
-     * Check if <elapsed_time> has a value
-     *
-     * @return boolean
-     */
-    public function hasElapsedTime(){
-      return $this->_has(4);
-    }
-    
-    /**
-     * Clear <elapsed_time> value
      *
      * @return \routeguide\RouteSummary
      */
-    public function clearElapsedTime(){
-      return $this->_clear(4);
+    public function setDistance($value)
+    {
+        return $this->_set(3, $value);
     }
-    
+
     /**
-     * Get <elapsed_time> value
+     * Check if <elapsed_time> has a value.
+     *
+     * @return bool
+     */
+    public function hasElapsedTime()
+    {
+        return $this->_has(4);
+    }
+
+    /**
+     * Clear <elapsed_time> value.
+     *
+     * @return \routeguide\RouteSummary
+     */
+    public function clearElapsedTime()
+    {
+        return $this->_clear(4);
+    }
+
+    /**
+     * Get <elapsed_time> value.
      *
      * @return int
      */
-    public function getElapsedTime(){
-      return $this->_get(4);
+    public function getElapsedTime()
+    {
+        return $this->_get(4);
     }
-    
+
     /**
-     * Set <elapsed_time> value
+     * Set <elapsed_time> value.
      *
      * @param int $value
+     *
      * @return \routeguide\RouteSummary
      */
-    public function setElapsedTime( $value){
-      return $this->_set(4, $value);
+    public function setElapsedTime($value)
+    {
+        return $this->_set(4, $value);
     }
   }
 }
 
 namespace routeguide {
 
-  class RouteGuideClient extends \Grpc\BaseStub {
-
-    public function __construct($hostname, $opts) {
-      parent::__construct($hostname, $opts);
-    }
+  class RouteGuideClient extends \Grpc\BaseStub
+  {
+      public function __construct($hostname, $opts)
+      {
+          parent::__construct($hostname, $opts);
+      }
     /**
      * @param routeguide\Point $input
      */
-    public function GetFeature(\routeguide\Point $argument, $metadata = array(), $options = array()) {
-      return $this->_simpleRequest('/routeguide.RouteGuide/GetFeature', $argument, '\routeguide\Feature::deserialize', $metadata, $options);
+    public function GetFeature(\routeguide\Point $argument, $metadata = array(), $options = array())
+    {
+        return $this->_simpleRequest('/routeguide.RouteGuide/GetFeature', $argument, '\routeguide\Feature::deserialize', $metadata, $options);
     }
     /**
      * @param routeguide\Rectangle $input
      */
-    public function ListFeatures($argument, $metadata = array(), $options = array()) {
-      return $this->_serverStreamRequest('/routeguide.RouteGuide/ListFeatures', $argument, '\routeguide\Feature::deserialize', $metadata, $options);
+    public function ListFeatures($argument, $metadata = array(), $options = array())
+    {
+        return $this->_serverStreamRequest('/routeguide.RouteGuide/ListFeatures', $argument, '\routeguide\Feature::deserialize', $metadata, $options);
     }
     /**
      * @param routeguide\Point $input
      */
-    public function RecordRoute($metadata = array()) {
-      return $this->_clientStreamRequest('/routeguide.RouteGuide/RecordRoute', '\routeguide\RouteSummary::deserialize', $metadata);
+    public function RecordRoute($metadata = array())
+    {
+        return $this->_clientStreamRequest('/routeguide.RouteGuide/RecordRoute', '\routeguide\RouteSummary::deserialize', $metadata);
     }
     /**
      * @param routeguide\RouteNote $input
      */
-    public function RouteChat($metadata = array()) {
-      return $this->_bidiRequest('/routeguide.RouteGuide/RouteChat', '\routeguide\RouteNote::deserialize', $metadata);
+    public function RouteChat($metadata = array())
+    {
+        return $this->_bidiRequest('/routeguide.RouteGuide/RouteChat', '\routeguide\RouteNote::deserialize', $metadata);
     }
   }
 }
diff --git a/examples/php/route_guide/route_guide_client.php b/examples/php/route_guide/route_guide_client.php
index 2f9533b..b3cd606 100644
--- a/examples/php/route_guide/route_guide_client.php
+++ b/examples/php/route_guide/route_guide_client.php
@@ -32,48 +32,50 @@
  *
  */
 
-require dirname(__FILE__) . '/../vendor/autoload.php';
-require dirname(__FILE__) . '/route_guide.php';
+require dirname(__FILE__).'/../vendor/autoload.php';
+require dirname(__FILE__).'/route_guide.php';
 
 define('COORD_FACTOR', 1e7);
 
 $client = new routeguide\RouteGuideClient('localhost:50051', [
-  'credentials' => Grpc\ChannelCredentials::createInsecure()
+    'credentials' => Grpc\ChannelCredentials::createInsecure(),
 ]);
 
-function printFeature($feature) {
-  $name = $feature->getName();
-  if (!$name) {
-    $name_str = "no feature";
-  } else {
-    $name_str = "feature called $name";
-  }
-  print sprintf("Found %s \n  at %f, %f\n", $name_str,
-                $feature->getLocation()->getLatitude() / COORD_FACTOR,
-                $feature->getLocation()->getLongitude() / COORD_FACTOR);
+function printFeature($feature)
+{
+    $name = $feature->getName();
+    if (!$name) {
+        $name_str = 'no feature';
+    } else {
+        $name_str = "feature called $name";
+    }
+    echo sprintf("Found %s \n  at %f, %f\n", $name_str,
+                 $feature->getLocation()->getLatitude() / COORD_FACTOR,
+                 $feature->getLocation()->getLongitude() / COORD_FACTOR);
 }
 
 /**
  * Run the getFeature demo. Calls getFeature with a point known to have a
  * feature and a point known not to have a feature.
  */
-function runGetFeature() {
-  print "Running GetFeature...\n";
-  global $client;
+function runGetFeature()
+{
+    echo "Running GetFeature...\n";
+    global $client;
 
-  $point = new routeguide\Point();
-  $points = array(
-    array(409146138, -746188906),
-    array(0, 0),
-  );
+    $point = new routeguide\Point();
+    $points = array(
+        array(409146138, -746188906),
+        array(0, 0),
+    );
 
-  foreach ($points as $p) {
-    $point->setLatitude($p[0]);
-    $point->setLongitude($p[1]);
-    // make a unary grpc call
-    list($feature, $status) = $client->GetFeature($point)->wait();
-    printFeature($feature);
-  }
+    foreach ($points as $p) {
+        $point->setLatitude($p[0]);
+        $point->setLongitude($p[1]);
+        // make a unary grpc call
+        list($feature, $status) = $client->GetFeature($point)->wait();
+        printFeature($feature);
+    }
 }
 
 /**
@@ -81,29 +83,30 @@
  * containing all of the features in the pre-generated
  * database. Prints each response as it comes in.
  */
-function runListFeatures() {
-  print "Running ListFeatures...\n";
-  global $client;
+function runListFeatures()
+{
+    echo "Running ListFeatures...\n";
+    global $client;
 
-  $lo_point = new routeguide\Point();
-  $hi_point = new routeguide\Point();
+    $lo_point = new routeguide\Point();
+    $hi_point = new routeguide\Point();
 
-  $lo_point->setLatitude(400000000);
-  $lo_point->setLongitude(-750000000);
-  $hi_point->setLatitude(420000000);
-  $hi_point->setLongitude(-730000000);
+    $lo_point->setLatitude(400000000);
+    $lo_point->setLongitude(-750000000);
+    $hi_point->setLatitude(420000000);
+    $hi_point->setLongitude(-730000000);
 
-  $rectangle = new routeguide\Rectangle();
-  $rectangle->setLo($lo_point);
-  $rectangle->setHi($hi_point);
+    $rectangle = new routeguide\Rectangle();
+    $rectangle->setLo($lo_point);
+    $rectangle->setHi($hi_point);
 
-  // start the server streaming call
-  $call = $client->ListFeatures($rectangle);
-  // an iterator over the server streaming responses
-  $features = $call->responses();
-  foreach ($features as $feature) {
-    printFeature($feature);
-  }
+    // start the server streaming call
+    $call = $client->ListFeatures($rectangle);
+    // an iterator over the server streaming responses
+    $features = $call->responses();
+    foreach ($features as $feature) {
+        printFeature($feature);
+    }
 }
 
 /**
@@ -111,96 +114,99 @@
  * pre-generated feature database with a variable delay in between. Prints
  * the statistics when they are sent from the server.
  */
-function runRecordRoute() {
-  print "Running RecordRoute...\n";
-  global $client, $argv;
+function runRecordRoute()
+{
+    echo "Running RecordRoute...\n";
+    global $client, $argv;
 
-  // start the client streaming call
-  $call = $client->RecordRoute();
+    // start the client streaming call
+    $call = $client->RecordRoute();
 
-  $db = json_decode(file_get_contents($argv[1]), true);
-  $num_points_in_db = count($db);
-  $num_points = 10;
-  for ($i = 0; $i < $num_points; $i++) {
-    $point = new routeguide\Point();
-    $index = rand(0, $num_points_in_db - 1);
-    $lat = $db[$index]['location']['latitude'];
-    $long = $db[$index]['location']['longitude'];
-    $feature_name = $db[$index]['name'];
-    $point->setLatitude($lat);
-    $point->setLongitude($long);
-    print sprintf("Visiting point %f, %f,\n  with feature name: %s\n",
-                  $lat / COORD_FACTOR, $long / COORD_FACTOR,
-                  $feature_name ? $feature_name : '<empty>');
-    usleep(rand(300000, 800000));
-    $call->write($point);
-  }
-  list($route_summary, $status) = $call->wait();
-  print sprintf("Finished trip with %d points\nPassed %d features\n".
-                "Travelled %d meters\nIt took %d seconds\n",
-                $route_summary->getPointCount(),
-                $route_summary->getFeatureCount(),
-                $route_summary->getDistance(),
-                $route_summary->getElapsedTime());
+    $db = json_decode(file_get_contents($argv[1]), true);
+    $num_points_in_db = count($db);
+    $num_points = 10;
+    for ($i = 0; $i < $num_points; ++$i) {
+        $point = new routeguide\Point();
+        $index = rand(0, $num_points_in_db - 1);
+        $lat = $db[$index]['location']['latitude'];
+        $long = $db[$index]['location']['longitude'];
+        $feature_name = $db[$index]['name'];
+        $point->setLatitude($lat);
+        $point->setLongitude($long);
+        echo sprintf("Visiting point %f, %f,\n  with feature name: %s\n",
+                     $lat / COORD_FACTOR, $long / COORD_FACTOR,
+                     $feature_name ? $feature_name : '<empty>');
+        usleep(rand(300000, 800000));
+        $call->write($point);
+    }
+    list($route_summary, $status) = $call->wait();
+    echo sprintf("Finished trip with %d points\nPassed %d features\n".
+                 "Travelled %d meters\nIt took %d seconds\n",
+                 $route_summary->getPointCount(),
+                 $route_summary->getFeatureCount(),
+                 $route_summary->getDistance(),
+                 $route_summary->getElapsedTime());
 }
 
 /**
  * Run the routeChat demo. Send some chat messages, and print any chat
  * messages that are sent from the server.
  */
-function runRouteChat() {
-  print "Running RouteChat...\n";
-  global $client;
+function runRouteChat()
+{
+    echo "Running RouteChat...\n";
+    global $client;
 
-  // start the bidirectional streaming call
-  $call = $client->RouteChat();
+    // start the bidirectional streaming call
+    $call = $client->RouteChat();
 
-  $notes = array(
-    array(1, 1, 'first message'),
-    array(1, 2, 'second message'),
-    array(2, 1, 'third message'),
-    array(1, 1, 'fourth message'),
-    array(1, 1, 'fifth message'),
-  );
+    $notes = array(
+        array(1, 1, 'first message'),
+        array(1, 2, 'second message'),
+        array(2, 1, 'third message'),
+        array(1, 1, 'fourth message'),
+        array(1, 1, 'fifth message'),
+    );
 
-  foreach ($notes as $n) {
-    $point = new routeguide\Point();
-    $point->setLatitude($lat = $n[0]);
-    $point->setLongitude($long = $n[1]);
+    foreach ($notes as $n) {
+        $point = new routeguide\Point();
+        $point->setLatitude($lat = $n[0]);
+        $point->setLongitude($long = $n[1]);
 
-    $route_note = new routeguide\RouteNote();
-    $route_note->setLocation($point);
-    $route_note->setMessage($message = $n[2]);
+        $route_note = new routeguide\RouteNote();
+        $route_note->setLocation($point);
+        $route_note->setMessage($message = $n[2]);
 
-    print sprintf("Sending message: '%s' at (%d, %d)\n",
-                  $message, $lat, $long);
-    // send a bunch of messages to the server
-    $call->write($route_note);
-  }
-  $call->writesDone();
+        echo sprintf("Sending message: '%s' at (%d, %d)\n",
+                     $message, $lat, $long);
+        // send a bunch of messages to the server
+        $call->write($route_note);
+    }
+    $call->writesDone();
 
-  // read from the server until there's no more
-  while ($route_note_reply = $call->read()) {
-    print sprintf("Previous left message at (%d, %d): '%s'\n",
-                  $route_note_reply->getLocation()->getLatitude(),
-                  $route_note_reply->getLocation()->getLongitude(),
-                  $route_note_reply->getMessage());
-  }
+    // read from the server until there's no more
+    while ($route_note_reply = $call->read()) {
+        echo sprintf("Previous left message at (%d, %d): '%s'\n",
+                     $route_note_reply->getLocation()->getLatitude(),
+                     $route_note_reply->getLocation()->getLongitude(),
+                     $route_note_reply->getMessage());
+    }
 }
 
 /**
- * Run all of the demos in order
+ * Run all of the demos in order.
  */
-function main() {
-  runGetFeature();
-  runListFeatures();
-  runRecordRoute();
-  runRouteChat();
+function main()
+{
+    runGetFeature();
+    runListFeatures();
+    runRecordRoute();
+    runRouteChat();
 }
 
 if (empty($argv[1])) {
-  print "Usage: php -d extension=grpc.so route_guide_client.php " .
+    echo 'Usage: php -d extension=grpc.so route_guide_client.php '.
         "<path to route_guide_db.json>\n";
-  exit(1);
+    exit(1);
 }
 main();
diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php
index 565bfce..c5bb7c4 100755
--- a/src/php/tests/interop/interop_client.php
+++ b/src/php/tests/interop/interop_client.php
@@ -477,7 +477,8 @@
     return $stub;
 }
 
-function interop_main($args, $stub = false) {
+function interop_main($args, $stub = false)
+{
     if (!$stub) {
         $stub = _makeStub($args);
     }
diff --git a/src/php/tests/interop/metrics_client.php b/src/php/tests/interop/metrics_client.php
index 46f4212..19510dc 100644
--- a/src/php/tests/interop/metrics_client.php
+++ b/src/php/tests/interop/metrics_client.php
@@ -39,11 +39,11 @@
 
 $socket = socket_create(AF_INET, SOCK_STREAM, 0);
 if (@!socket_connect($socket, $server_host, $server_port)) {
-  echo "Cannot connect to merics server...\n";
-  exit(1);
+    echo "Cannot connect to merics server...\n";
+    exit(1);
 }
 socket_write($socket, 'qps');
 while ($out = socket_read($socket, 1024)) {
-  echo "$out\n";
+    echo "$out\n";
 }
 socket_close($socket);
diff --git a/src/php/tests/interop/stress_client.php b/src/php/tests/interop/stress_client.php
index 2339f0d..419ef5b 100644
--- a/src/php/tests/interop/stress_client.php
+++ b/src/php/tests/interop/stress_client.php
@@ -32,50 +32,52 @@
  *
  */
 
-include_once('interop_client.php');
+include_once 'interop_client.php';
 
-function stress_main($args) {
-  mt_srand();
-  set_time_limit(0);
+function stress_main($args)
+{
+    mt_srand();
+    set_time_limit(0);
 
-  // open socket to listen as metrics server
-  $socket = socket_create(AF_INET, SOCK_STREAM, 0);
-  socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
-  if (@!socket_bind($socket, 'localhost', $args['metrics_port'])) {
-    echo "Cannot create socket for metrics server...\n";
-    exit(1);
-  }
-  socket_listen($socket);
-  socket_set_nonblock($socket);
-
-  $start_time = microtime(true);
-  $count = 0;
-  $deadline = $args['test_duration_secs'] ?
-              ($start_time + $args['test_duration_secs']) : false;
-  $num_test_cases = count($args['test_cases']);
-  $stub = false;
-
-  while (true) {
-    $current_time = microtime(true);
-    if ($deadline && $current_time > $deadline) {
-      break;
+    // open socket to listen as metrics server
+    $socket = socket_create(AF_INET, SOCK_STREAM, 0);
+    socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
+    if (@!socket_bind($socket, 'localhost', $args['metrics_port'])) {
+        echo "Cannot create socket for metrics server...\n";
+        exit(1);
     }
-    if ($client_connection = socket_accept($socket)) {
-      // there is an incoming request, respond with qps metrics
-      $input = socket_read($client_connection, 1024);
-      $qps = round($count / ($current_time - $start_time));
-      socket_write($client_connection, "qps: $qps");
-      socket_close($client_connection);
-    } else {
-      // do actual work, run one interop test case
-      $args['test_case'] =
-          $args['test_cases'][mt_rand(0, $num_test_cases - 1)];
-      $stub = @interop_main($args, $stub);
-      $count++;
+    socket_listen($socket);
+    socket_set_nonblock($socket);
+
+    $start_time = microtime(true);
+    $count = 0;
+    $deadline = $args['test_duration_secs'] ?
+                ($start_time + $args['test_duration_secs']) : false;
+    $num_test_cases = count($args['test_cases']);
+    $stub = false;
+
+    while (true) {
+        $current_time = microtime(true);
+        if ($deadline && $current_time > $deadline) {
+            break;
+        }
+        if ($client_connection = socket_accept($socket)) {
+            // there is an incoming request, respond with qps metrics
+            $input = socket_read($client_connection, 1024);
+            $qps = round($count / ($current_time - $start_time));
+            socket_write($client_connection, "qps: $qps");
+            socket_close($client_connection);
+        } else {
+            // do actual work, run one interop test case
+            $args['test_case'] =
+                $args['test_cases'][mt_rand(0, $num_test_cases - 1)];
+            $stub = @interop_main($args, $stub);
+            ++$count;
+        }
     }
-  }
-  socket_close($socket);
-  echo "Number of interop tests run in $args[test_duration_secs] seconds: $count.\n";
+    socket_close($socket);
+    echo "Number of interop tests run in $args[test_duration_secs] ".
+        "seconds: $count.\n";
 }
 
 // process command line arguments
@@ -85,31 +87,32 @@
    'metrics_port::',
    'test_duration_secs::',
    'num_channels_per_server::',
-   'num_stubs_per_channel::']);
+   'num_stubs_per_channel::',
+  ]);
 
 $args = [];
 
 if (empty($raw_args['server_addresses'])) {
-  $args['server_host'] = 'localhost';
-  $args['server_port'] = '8080';
+    $args['server_host'] = 'localhost';
+    $args['server_port'] = '8080';
 } else {
-  $parts = explode(':', $raw_args['server_addresses']);
-  $args['server_host'] = $parts[0];
-  $args['server_port'] = (count($parts) == 2) ? $parts[1] : '';
+    $parts = explode(':', $raw_args['server_addresses']);
+    $args['server_host'] = $parts[0];
+    $args['server_port'] = (count($parts) == 2) ? $parts[1] : '';
 }
 
 $args['metrics_port'] = empty($raw_args['metrics_port']) ?
-  '8081' : $args['metrics_port'];
+    '8081' : $args['metrics_port'];
 
 $args['test_duration_secs'] = empty($raw_args['test_duration_secs']) ||
-  $raw_args['test_duration_secs'] == -1 ?
-  false : $raw_args['test_duration_secs'];
+    $raw_args['test_duration_secs'] == -1 ?
+    false : $raw_args['test_duration_secs'];
 
 $test_cases = [];
 $test_case_strs = explode(',', $raw_args['test_cases']);
 foreach ($test_case_strs as $test_case_str) {
-  $parts = explode(':', $test_case_str);
-  $test_cases = array_merge($test_cases, array_fill(0, $parts[1], $parts[0]));
+    $parts = explode(':', $test_case_str);
+    $test_cases = array_merge($test_cases, array_fill(0, $parts[1], $parts[0]));
 }
 $args['test_cases'] = $test_cases;
 
diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py
index 555a92a..d9315d2 100644
--- a/src/python/grpcio/grpc/_channel.py
+++ b/src/python/grpcio/grpc/_channel.py
@@ -134,9 +134,9 @@
   for batch_operation in event.batch_operations:
     operation_type = batch_operation.type
     state.due.remove(operation_type)
-    if operation_type is cygrpc.OperationType.receive_initial_metadata:
+    if operation_type == cygrpc.OperationType.receive_initial_metadata:
       state.initial_metadata = batch_operation.received_metadata
-    elif operation_type is cygrpc.OperationType.receive_message:
+    elif operation_type == cygrpc.OperationType.receive_message:
       serialized_response = batch_operation.received_message.bytes()
       if serialized_response is not None:
         response = _common.deserialize(
@@ -146,7 +146,7 @@
           _abort(state, grpc.StatusCode.INTERNAL, details)
         else:
           state.response = response
-    elif operation_type is cygrpc.OperationType.receive_status_on_client:
+    elif operation_type == cygrpc.OperationType.receive_status_on_client:
       state.trailing_metadata = batch_operation.received_metadata
       if state.code is None:
         code = _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE.get(
diff --git a/templates/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile.template b/templates/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile.template
index c11cefd..e395379 100644
--- a/templates/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile.template
+++ b/templates/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile.template
@@ -34,6 +34,12 @@
   <%include file="../../apt_get_basic.include"/>
   <%include file="../../cxx_deps.include"/>
   <%include file="../../run_tests_addons.include"/>
+  
+  # The clang-3.6 symlink for the default clang version was added
+  # to Ubuntu 16.04 recently, so make sure it's installed.
+  # Also install clang3.7.
+  RUN apt-get update && apt-get -y install clang-3.6 clang-3.7 && apt-get clean
+  
   # Define the default command.
   CMD ["bash"]
   
\ No newline at end of file
diff --git a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile
index 02d3c0d..d356433 100644
--- a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile
@@ -82,5 +82,11 @@
 
 RUN mkdir /var/local/jenkins
 
+
+# The clang-3.6 symlink for the default clang version was added
+# to Ubuntu 16.04 recently, so make sure it's installed.
+# Also install clang3.7.
+RUN apt-get update && apt-get -y install clang-3.6 clang-3.7 && apt-get clean
+
 # Define the default command.
 CMD ["bash"]
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index f4582ad..3080d19 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -246,11 +246,17 @@
   def makefile_name(self):
     return 'Makefile'
 
-  def _clang_make_options(self):
-    return ['CC=clang', 'CXX=clang++', 'LD=clang', 'LDXX=clang++']
+  def _clang_make_options(self, version_suffix=''):
+    return ['CC=clang%s' % version_suffix,
+            'CXX=clang++%s' % version_suffix,
+            'LD=clang%s' % version_suffix,
+            'LDXX=clang++%s' % version_suffix]
 
-  def _gcc44_make_options(self):
-    return ['CC=gcc-4.4', 'CXX=g++-4.4', 'LD=gcc-4.4', 'LDXX=g++-4.4']
+  def _gcc_make_options(self, version_suffix):
+    return ['CC=gcc%s' % version_suffix,
+            'CXX=g++%s' % version_suffix,
+            'LD=gcc%s' % version_suffix,
+            'LDXX=g++%s' % version_suffix]
 
   def _compiler_options(self, use_docker, compiler):
     """Returns docker distro and make options to use for given compiler."""
@@ -260,13 +266,20 @@
     if compiler == 'gcc4.9' or compiler == 'default':
       return ('jessie', [])
     elif compiler == 'gcc4.4':
-      return ('wheezy', self._gcc44_make_options())
+      return ('wheezy', self._gcc_make_options(version_suffix='-4.4'))
+    elif compiler == 'gcc4.6':
+      return ('wheezy', self._gcc_make_options(version_suffix='-4.6'))
     elif compiler == 'gcc5.3':
       return ('ubuntu1604', [])
     elif compiler == 'clang3.4':
+      # on ubuntu1404, clang-3.4 alias doesn't exist, just use 'clang'
       return ('ubuntu1404', self._clang_make_options())
+    elif compiler == 'clang3.5':
+      return ('jessie', self._clang_make_options(version_suffix='-3.5'))
     elif compiler == 'clang3.6':
-      return ('ubuntu1604', self._clang_make_options())
+      return ('ubuntu1604', self._clang_make_options(version_suffix='-3.6'))
+    elif compiler == 'clang3.7':
+      return ('ubuntu1604', self._clang_make_options(version_suffix='-3.7'))
     else:
       raise Exception('Compiler %s not supported.' % compiler)
 
@@ -821,8 +834,8 @@
                   help='Selects architecture to target. For some platforms "default" is the only supported choice.')
 argp.add_argument('--compiler',
                   choices=['default',
-                           'gcc4.4', 'gcc4.9', 'gcc5.3',
-                           'clang3.4', 'clang3.6',
+                           'gcc4.4', 'gcc4.6', 'gcc4.9', 'gcc5.3',
+                           'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7',
                            'vs2010', 'vs2013', 'vs2015',
                            'python2.7', 'python3.4',
                            'node0.12', 'node4', 'node5'],