MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / setAttributes

Method setAttributes

benches/fixtures/yii/Model.php:736–748  ·  view source on GitHub ↗

* Sets the attribute values in a massive way. * @param array $values attribute values (name => value) to be assigned to the model. * @param bool $safeOnly whether the assignments should only be done to the safe attributes. * A safe attribute is one that is associated with a validation rule in the current [[scenario]]. * @see safeAttributes() * @see attributes() */

($values, $safeOnly = true)

Source from the content-addressed store, hash-verified

734 * @see attributes()
735 */
736 public function setAttributes($values, $safeOnly = true)
737 {
738 if (is_array($values)) {
739 $attributes = array_flip($safeOnly ? $this->safeAttributes() : $this->attributes());
740 foreach ($values as $name => $value) {
741 if (isset($attributes[$name])) {
742 $this->$name = $value;
743 } elseif ($safeOnly) {
744 $this->onUnsafeAttribute($name, $value);
745 }
746 }
747 }
748 }
749
750 /**
751 * This method is invoked when an unsafe attribute is being massively assigned.

Callers 1

loadMethod · 0.95

Calls 3

safeAttributesMethod · 0.95
attributesMethod · 0.95
onUnsafeAttributeMethod · 0.95

Tested by

no test coverage detected