Add the property to the object

@param $object
@param $name
@throws Exception

@return $this
760728
protected function setProperty($object, $name)
    {
        $this->loadPropertyTypes();
        if (empty($this->restrictedProperties) && $this->frozen) {
            $this->restrictedProperties = $this->getRestrictedProperties(get_class());
        }
        if ($name) {
            $this->assignProperty($name, $object);
        } else {
            $objectClass = get_class($object);
            $match = null;
            foreach ($this->propertyTypes as $name => $type) {
                if ($object instanceof $type) {
                    if ($match) {
                        throw new \FW\DI\Exception("You must specify a name for the property of type $objectClass,
                        since at least two parameters ($match and $name) share the same class");
                    }
                    $match = $name;
                }
            }
            if (!$match) {
                // We gave an unused class in the DI, it doesn't serve any purpose but it won't break the build
                trigger_error("Object of class $objectClass given to " . get_class() . " but it seems unused.", E_USER_WARNING);
            } else {
                $this->assignProperty($match, $object);
            }
        }
        return $this;
    }
355616
public function invokeMethod($object, $name, array $args = [])
    {
        $method = new ReflectionMethod($object, $name);
        $method->setAccessible(true);

        if (empty($args)) {
            return $method->invoke($object);
        }

        return $method->invokeArgs($object, $args);
    }
240722
public function add(GroupObject $object) : Group
    {
        if (count($this->objects) < 2)
        {
            $this->objects[] = $object;
        }
        else
        {
            throw new Exception(
                "An XORGroup may not contain more than two objects."
            );
        }

        return $this;
    }
1106576
public function add($name, $value)
    {
        if ($this->has($name)) {
            $this->updateAttribute($name, $value);
        }
        else {
            $this->makeAttribute($name, $value);
        }

        return $this;
    }
444824
public function withInitialValuesFrom($object) : FormWithBinding
    {
        $form = $this->binding->getForm($object);

        return new self(
            $form->getSections(),
            $form->getProcessors(),
            $this->binding->getObjectType(),
            $this->binding->getFieldBindings()
        );
    }
144291
public function isObject(DataObject $object, $name)
    {
        $identifier = ltrim($name, '->');
        
        return ($this->isObjectIdentifier($name) && is_object($object->$identifier));
    }
695447
public function set($key, $object) {
		
		if (! is_object($object)) {
			throw new \InvalidArgumentException("Registry only accepts objects, given: ".gettype($object));
		}
		
		$this->_data[$key] = $object;
		
		return $this;
	}
493552
public function setObject($object)
    {
        if ( ! is_object($object))
        {
            throw new InvalidArgumentException(
                'Expected an object, but got '.gettype($object)
            );
        }

        $this->object = new ReflectionClass($object);
    }
57327
public function addFrom( $email, $name = null )
	{
		$this->object->addFrom( $email, $name );
		return $this;
	}
626091
public function mergeProperties($object)
    {
        $defaultValues = get_class_vars(get_class($this));
        $currentValues = get_object_vars($this);
        foreach ($object as $property => $value) {
            if ($property === '_context') {
                continue;
            }
            if ($currentValues[$property] === $defaultValues[$property]) { // Overwrite default values
                $this->$property = $value;
                continue;
            }
            if ($property === '_unmerged') {
                $this->_unmerged = array_merge($this->_unmerged, $value);
                continue;
            }
            if ($currentValues[$property] !== $value) { // New value is not the same?
                if ($defaultValues[$property] === $value) { // but is the same as the default?
                    continue; // Keep current, no notice
                }
                $identity = method_exists($object, 'identity') ? $object->identity() : get_class($object);
                $context1 = $this->_context;
                $context2 = property_exists($object, '_context') ? $object->_context : 'unknown';
                if (is_object($this->$property) && $this->$property instanceof AbstractAnnotation) {
                    $context1 = $this->$property->_context;
                }
                Logger::warning('Multiple definitions for ' . $identity . '->' . $property . "\n     Using: " . $context1 . "\n  Skipping: " . $context2);
            }
        }
    }
902053
public function setObject($object)
    {
        if (! is_object($object)) {
            throw new InvalidArgumentException(
                sprintf('The parameter given to setObject method of %s class is not an object', get_called_class())
            );
        }

        $this->object = $object;
        return $this;
    }
531982
public function addNewInstance($object, FieldDescriptionInterface $fieldDescription)
    {
        $instance = $fieldDescription->getAssociationAdmin()->getNewInstance();
        $mapping = $fieldDescription->getAssociationMapping();

        $method = sprintf('add%s', Inflector::classify($mapping['fieldName']));

        if (!method_exists($object, $method)) {
            $method = rtrim($method, 's');

            if (!method_exists($object, $method)) {
                $method = sprintf('add%s', Inflector::classify(Inflector::singularize($mapping['fieldName'])));

                if (!method_exists($object, $method)) {
                    throw new \RuntimeException(
                        sprintf('Please add a method %s in the %s class!', $method, ClassUtils::getClass($object))
                    );
                }
            }
        }

        $object->$method($instance);
    }
665713
public function add($object)
    {
        if (!$this->isNewObject($object)) {
            throw new KnownObjectException('The object of type "' . get_class($object) . '" (identifier: "' . $this->getIdentifierByObject($object) . '") which was passed to EntityManager->add() is not a new object. Check the code which adds this entity to the repository and make sure that only objects are added which were not persisted before. Alternatively use update() for updating existing objects."', 1337934295);
        } else {
            try {
                $this->entityManager->persist($object);
            } catch (\Exception $exception) {
                throw new PersistenceException('Could not add object of type "' . get_class($object) . '"', 1337934455, $exception);
            }
        }
    }
199117
public function addItem($object, ?string $key = null) : void
    {
        $this->checkCallback();

        if (null !== $key) {
            if (isset($this->members[$key])) {
                throw new CollectionException('Unable to add to collection - key ' . $key . ' already used.');
            } else {
                $this->members[$key] = $object;
            }
        } else {
            $this->members[] = $object;
        }
    }
990534
public function configureObject($object, $properties) {
        foreach ($properties as $name => $value) {
            $object->$name = $value;
        }

        return $object;
    }
287001
public static function _callStatic($object, $name, $arguments)
    {
		if (is_object($object))
		{
			$object = ($object instanceof AltrEgo) ? $object->getObject() : $object;
		} elseif (!class_exists($object))
		{
			throw new \Exception('Static call (callStatic) to AltrEgo must be passed either an object or an accessible class name');
		}

        try
    	{
			$method = new \ReflectionMethod($object, $name);
			if ($method->isStatic())
			{
        		$method->setAccessible(true);
        		return $method->invokeArgs($object, (array) $arguments);
			}
		} catch (\Exception $e)
		{
		}
		throw new \Exception('Unable to call static method "' . $name . '" on class ' . get_class($object));
    }
979337
public function add($object)
	{
		if (is_a($object, 'Closure')) {
			return $this->closures[] = $object;
		}

		$this->validateObject($object);

		$data = $object->getSitemapData();
		$this->addRaw($data);
	}