Given a $property and its $value, sets that property on the given $document
by using a closures if available, otherwise fall back to reflection.

@param mixed $document
@param string $property
@param string $value
978974
public function setDocumentValue($document, $property, $value)
    {
        $setter = \Closure::bind(function ($document, $property, $value) {
                $document->$property = $value;
            }, null, $document
        );
        $setter($document, $property, $value);
    }
711423
public function set($property, $value)
    {
        // we need to convert booleans into string, because these are query parameters
        if (is_bool($value)) {
            $value = $value
                ? 'true'
                : 'false';
        }

        $this->container[$property] = $value;

        return $this;
    }
404033
public static void set(Object obj, String property, Object value) throws Throwable {
        getSetterMethod(obj.getClass(), property).invoke(obj, value);
    }
350143
public function setFieldValue(object $document, string $field, $value) : void
    {
        if ($document instanceof GhostObjectInterface && ! $document->isProxyInitialized()) {
            //property changes to an uninitialized proxy will not be tracked or persisted,
            //so the proxy needs to be loaded first.
            $document->initializeProxy();
        }

        $this->reflFields[$field]->setValue($document, $value);
    }
1035648
protected function instanceWrite($property, $value)
    {
        $field = "{$this->name}_{$property}";

        // This is not fillable as it is the one required attribute
        if ($property === 'file_name') {
            $this->getInstance()->setAttribute($field, $value);
        }

        // Queue state is optional and outside of the fillable
        elseif (preg_match('/^queue(d?)_/', $property)) {
            if ($this->isQueueable()) {
                $this->getInstance()->setAttribute($field, $value);
            }
        }

        // All other attributes must be fillable to have their values set
        else {
            if (in_array($field, $this->getInstance()->getFillable())) {
                $this->getInstance()->setAttribute($field, $value);
            }
        }
    }
747779
public function setNewValue(string $field, $value) : void
    {
        $this->assertValidField($field);

        $this->documentChangeSet[$field][1] = $value;
        $this->getDocumentManager()->getUnitOfWork()->setDocumentChangeSet($this->getDocument(), $this->documentChangeSet);
    }
329312
public function set($property, $value = null)
    {
        if (is_array($property)) {
            foreach ($property as $k => $v) {
                $this->set($k, $v);
            }

            return $this;
        }

        if ($this->has($property)) {
            $method = 'set' . Str::studly($property);
            $value  = $this->sanitizeSetterValue($method, $value);

            $this->message->{$method}($value);
        }

        return $this;
    }
1340425
public static function setValueInEntity($entity, $property, $value)
    {
        $setter = self::createSetter($entity, $property);
        $entity->$setter($value);
    }
360521
public function set($property, $value = null)
    {
        if (is_object($property)) {
            $property = get_object_vars($property);
        }

        if (is_array($property)) {
            foreach ($property as $k => $v) {
                $this->set($k, $v);
            }
        } elseif ('_' != substr($property, 0, 1)) {
            if (method_exists($this, 'set'.ucfirst($property))) {
                $this->{'set'.ucfirst($property)}($value);
            } else {
                $this->$property = $value;
            }
        }

        return $this;
    }
1108221
public function setProperty(&$object, string $propertyName, $value)
    {
        $reflection = new ReflectionClass(get_class($object));

        /** @var ReflectionProperty $property */
        $property = $reflection->getProperty($propertyName);
        $property->setAccessible(true);

        $property->setValue($object, $value);
    }
535559
public function set($property, $value)
    {
        if($property == 'module')
        {
            $value = clone $value;

            if(is_string($value->params)) {
                $value->params = $this->getObject('object.config.factory')->fromString('json', $value->params);
            }
        }

        parent::set($property, $value);
    }
803482
public void setProperty(final String property, final Object newValue) {
        if (property.startsWith("@")) {
            if (newValue instanceof String || newValue instanceof GString) {
                final Iterator iter = iterator();

                while (iter.hasNext()) {
                    final NodeChild child = (NodeChild) iter.next();

                    child.attributes().put(property.substring(1), newValue);
                }
            }
        } else {
            final GPathResult result = new NodeChildren(this, property, this.namespaceTagHints);

            if (newValue instanceof Map) {
                for (Object o : ((Map) newValue).entrySet()) {
                    final Map.Entry entry = (Map.Entry) o;
                    result.setProperty("@" + entry.getKey(), entry.getValue());
                }
            } else {
                if (newValue instanceof Closure) {
                    result.replaceNode((Closure) newValue);
                } else {
                    result.replaceBody(newValue);
                }
            }
        }
    }
466270
private function setObjectValue(&$object, FieldDefinition $fieldDefinition, $value): void
    {
        //using setter
        $accessor = new PropertyAccessor();
        $propertyName = $fieldDefinition->getOriginName();
        if (\is_array($object)) {
            $object[$propertyName ?? $fieldDefinition->getName()] = $value;
        } else {
            if ($accessor->isWritable($object, $propertyName)) {
                $accessor->setValue($object, $propertyName, $value);
            } else {
                //using reflection
                $refClass = new \ReflectionClass(\get_class($object));
                if ($refClass->hasProperty($object) && $property = $refClass->getProperty($object)) {
                    $property->setAccessible(true);
                    $property->setValue($object, $value);
                }
            }
        }
    }
532958
public static function setPropertyValue($object,$propertyName,$value)
    {
        $setter = "set" . ucfirst($propertyName);
        if (method_exists($object, $setter)) {
            $object->$setter($value);
        }
    }
980637
public function addProperty(Property $property) {
        $properties = $this->getProperties();
        $properties[] = $property;
        $this->setProperties($properties);
    }
367971
public function addPropertyOnDemand($property, $value)
    {
        if ((bool) $value === true) {
            $this->addProperty($property);
        }

        return $this;
    }
256538
protected function setValue($object, $property, $value)
    {
        $reflectionClass = new ReflectionClass($object);

        if (!$reflectionClass->hasProperty($property)) {
            $object->{$property} = $value;

            return;
        }

        $reflectionProperty = $reflectionClass->getProperty($property);
        $reflectionProperty->setAccessible(true);

        $reflectionProperty->setValue($object, $value);
    }