Fill in any missing values using $defaults.

@param mixed $object
@param mixed $defaults
@return mixed
963313
public function defaults($object, $defaults)
    {
        if (is_array($defaults))
        {
            foreach ($defaults as $default)
            {
                $this->defaults($object, $default);
            }

            return $object;
        }

        foreach ($defaults as $key => $value)
        {
            if ( ! property_exists($object, $key))
            {
                $object->{$key} = $value;
            }
        }

        return $object;
    }
28201
private function emptyCollections($object)
    {
        $deepcopy = new DeepCopy();
        $deepcopy->addFilter(new DoctrineEmptyCollectionFilter(), new PropertyTypeMatcher('Doctrine\Common\Collections\Collection'));

        return $deepcopy->copy($object);
    }
58858
private function ensureDefaults(ContentObject $object)
    {
        $defaultProperties = ['main_language_code'];

        foreach ($defaultProperties as $defaultOption) {
            if (!$object->getProperty($defaultOption)) {
                $object->setProperty($defaultOption, $this->options[$defaultOption]);
            }
        }
    }
377616
public function hasRequirements($object = null)
    {
        if ($object === null) {
            return count($this->requirements) > 0;
        }

        $requirements = $this->getRequirementsObject($object);

        return !empty($requirements);
    }
1203631
protected function initDefaults($defaults)
    {
        if (!$defaults) {
            return;
        }

        $defaults = $this->fetchParameters($defaults);
        $this->initDefaultsInConfigArray($defaults);
    }
154728
public function get($property, $default = null)
    {

        //if its an array of properties;
        if (is_array($property)) {
            $values = array();

            foreach ($property as $key => $prop) {
                if (isset($this->$prop)) {
                    $values[$prop] = $this->$prop;
                }
            }
            return (!empty($values)) ? $values : $default;
        }

        if (isset($this->$property)) {
            return $this->$property;
        }
        return $default;
    }
699728
def with_defaults(self, obj):
        
        self.check_valid_keys(obj)
        obj = dict(obj)
        for (key, value) in self.defaults.items():
            if key not in obj:
                obj[key] = value
        return obj
1181865
function defaults(object, defs) {
  var key;
  object = assign({}, object);
  defs = defs || {};
  // Iterate over object non-prototype properties:
  for (key in defs) {
    if (defs.hasOwnProperty(key)) {
      // Replace values with defaults only if undefined (allow empty/zero values):
      if (object[key] == null) {
        object[key] = defs[key];
      }
    }
  }
  return object;
}
830930
public function get(array $array, $keys, $default = null)
    {
        $keys = $this->parseKeys($keys);

        if (is_array($array) && $keys) {
            $key = array_shift($keys);
            if (array_key_exists($key, $array)) {
                $value = $array[$key];
                if (!$keys) {
                    return $value;
                }

                if (is_array($value)) {
                    return $this->get($value, $keys, $default);
                }
            }
        }

        return $default;
    }
1141832
function _setParams( $params, $defaults=FALSE ) {
    if( !is_array( $params))
      $params = array();
    $input = array();
    foreach( $params as $paramKey => $paramValue ) {
      if( is_array( $paramValue )) {
        foreach( $paramValue as $pkey => $pValue ) {
          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
            $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
        }
      }
      elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
        $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
      if( 'VALUE' == strtoupper( $paramKey ))
        $input['VALUE']                 = strtoupper( $paramValue );
      else
        $input[strtoupper( $paramKey )] = $paramValue;
    }
    if( is_array( $defaults )) {
      foreach( $defaults as $paramKey => $paramValue ) {
        if( !isset( $input[$paramKey] ))
          $input[$paramKey] = $paramValue;
      }
    }
    return (0 < count( $input )) ? $input : null;
  }
826865
function fixMissing (obj, defaults) {
  Object.keys(defaults).forEach(function (key) {
    obj[key] = obj[key] || defaults[key];
  });
}
908721
public function setDefaults(array $defaults)
    {
        $this->defaults = array_merge($this->_global_defaults, $defaults, $this->defaults);
        return $this;
    }
1297404
function assignDefaults(defaults, options) {
  var keys = Object.keys(defaults),
      i = keys.length,
      k;

  options = options || {};

  while (i--) {
    k = keys[i];
    if (!(k in options)) {
      options[k] = defaults[k];
    }
  }

  return options;
}
704985
function defaults(array, defaults) {

  if(!isArray(array) || !isObject(defaults)) {
    return array;
  }
  //get defaults keys(include nested).
  var keys = deepKeys(defaults);

  array.forEach(function(elm) {
    //loop through all the keys
    keys.forEach(function(key) {
      var getter = $parse(key);
      var setter = getter.assign;
      //if it's not exist
      if(isUndefined(getter(elm))) {
        //get from defaults, and set to the returned object
        setter(elm, getter(defaults))
      }
    });
  });

  return array;
}
1093039
function defaults(target, defs) {
  if (target == null) target = {};
  var ret = {};
  var keys = Object.keys(defs);
  for (var i = 0, len = keys.length; i < len; i++) {
    var key = keys[i];
    ret[key] = target[key] || defs[key];
  }
  return ret;
}
1028541
private function _recursiveGetObjectVars($object)
    {
        $vars = $object;
        if ( is_object($object) ) {
            $vars = get_object_vars($object);
            foreach ($vars as $key => $value) {
                $vars[$key] = $this->_recursiveGetObjectVars($value);
            }
        }

        return $vars;
    }
1234256
function defaults(object, options) {
  object = object || {};
  for (var i in options) {
    if (undefined === object[i] && options.hasOwnProperty(i)) {
      object[i] = options[i];
    }
  }
  return object;
}