original_string: public static function keyValue($list, $keyProperty=null, $valueProperty=null)
      {
          $index = array();
          foreach ($list as $i) {
              if ($keyProperty) {
                  if (!$valueProperty) { 
                      throw new \InvalidArgumentException("Must set value property if setting key property");
                  }
                  $index[$i->$keyProperty] = $i->$valueProperty;
              }
              else {
                  $key = current($i);
                  next($i);
                  $value = current($i);
                  $index[$key] = $value;
              }
          }
          return $index;
      }
code: public static function keyValue($list, $keyProperty=null, $valueProperty=null)
      {
          $index = array();
          foreach ($list as $i) {
              if ($keyProperty) {
                  if (!$valueProperty) { 
                      throw new \InvalidArgumentException("Must set value property if setting key property");
                  }
                  $index[$i->$keyProperty] = $i->$valueProperty;
              }
              else {
                  $key = current($i);
                  next($i);
                  $value = current($i);
                  $index[$key] = $value;
              }
          }
          return $index;
      }
code_tokens: public static function keyValue ( $ list , $ keyProperty = null , $ valueProperty = null ) { $ index = array ( ) ; foreach ( $ list as $ i ) { if ( $ keyProperty ) { if ( ! $ valueProperty ) { throw new \ InvalidArgumentException ( "Must set value property if setting key property" ) ; } $ index [ $ i -> $ keyProperty ] = $ i -> $ valueProperty ; } else { $ key = current ( $ i ) ; next ( $ i ) ; $ value = current ( $ i ) ; $ index [ $ key ] = $ value ; } } return $ index ; }
docstring: Create a one-dimensional associative array from a list of objects, or a list of 2-tuples.
  
  @param object[]|array $list
  @param string $keyProperty
  @param string $valueProperty
  @return array
docstring_tokens: Create a one - dimensional associative array from a list of objects or a list of 2 - tuples .