original_string: public static function setByPath(&$subject, array $path, $value)
      {
          $ptr = & $subject;
          foreach ($path as $key) {
              if (is_object($ptr)) {
                  if (!isset($ptr->$key)) {
                      $ptr->$key = array();
                  }
                  $ptr = & $ptr->$key;
              } elseif (is_array($ptr)) {
                  if (!isset($ptr[$key])) {
                      $ptr[$key] = array();
                  }
                  $ptr = & $ptr[$key];
              }
          }
          $ptr = $value;
          return $subject;
      }
code: public static function setByPath(&$subject, array $path, $value)
      {
          $ptr = & $subject;
          foreach ($path as $key) {
              if (is_object($ptr)) {
                  if (!isset($ptr->$key)) {
                      $ptr->$key = array();
                  }
                  $ptr = & $ptr->$key;
              } elseif (is_array($ptr)) {
                  if (!isset($ptr[$key])) {
                      $ptr[$key] = array();
                  }
                  $ptr = & $ptr[$key];
              }
          }
          $ptr = $value;
          return $subject;
      }
code_tokens: public static function setByPath ( & $ subject , array $ path , $ value ) { $ ptr = & $ subject ; foreach ( $ path as $ key ) { if ( is_object ( $ ptr ) ) { if ( ! isset ( $ ptr -> $ key ) ) { $ ptr -> $ key = array ( ) ; } $ ptr = & $ ptr -> $ key ; } elseif ( is_array ( $ ptr ) ) { if ( ! isset ( $ ptr [ $ key ] ) ) { $ ptr [ $ key ] = array ( ) ; } $ ptr = & $ ptr [ $ key ] ; } } $ ptr = $ value ; return $ subject ; }
docstring: Set a property value by a path of property or key names.
  
  @param mixed &$subject
  @param array $path
  @param mixed $value
  @return mixed
docstring_tokens: Set a property value by a path of property or key names .