original_string: public function setName(string $name)
      {
          $this->name = $name;
          while (preg_match('/^(.*)\[([^\]]*)\]$/', $name, $matches) === 1)
          {
              if (empty($matches[2]))
              {
                  if ($this->name_depth > 1)
                      throw new \InvalidArgumentException("Invalid name: {$this->name}");
                  $this->is_array = true;
              } 
              else
                  array_unshift($this->name_parts, $matches[2]);
  
              $name = $matches[1];
              ++$this->name_depth;
          }
          array_unshift($this->name_parts, $name);
  
          return $this;
      }
code: public function setName(string $name)
      {
          $this->name = $name;
          while (preg_match('/^(.*)\[([^\]]*)\]$/', $name, $matches) === 1)
          {
              if (empty($matches[2]))
              {
                  if ($this->name_depth > 1)
                      throw new \InvalidArgumentException("Invalid name: {$this->name}");
                  $this->is_array = true;
              } 
              else
                  array_unshift($this->name_parts, $matches[2]);
  
              $name = $matches[1];
              ++$this->name_depth;
          }
          array_unshift($this->name_parts, $name);
  
          return $this;
      }
code_tokens: public function setName ( string $ name ) { $ this -> name = $ name ; while ( preg_match ( '/^(.*)\[([^\]]*)\]$/' , $ name , $ matches ) === 1 ) { if ( empty ( $ matches [ 2 ] ) ) { if ( $ this -> name_depth > 1 ) throw new \ InvalidArgumentException ( "Invalid name: {$this->name}" ) ; $ this -> is_array = true ; } else array_unshift ( $ this -> name_parts , $ matches [ 2 ] ) ; $ name = $ matches [ 1 ] ; ++ $ this -> name_depth ; } array_unshift ( $ this -> name_parts , $ name ) ; return $ this ; }
docstring: Change the name of the field.
  @param string $name The name to set. If the name contains [] pairs,
  the field type will be set to array.
  @return FormField Provides fluent interface
  @throws InvalidArgumentException When an invalid names as used. An invalid name
  is a name with more than one empty array pair,
  like foo[][]
docstring_tokens: Change the name of the field .