src/TypedClass.php
protected function _setByName($propName, $in)
	{
		if (array_key_exists($propName, $this->_map)) {
			$propName = $this->_map[$propName];
		}

		$setter = '_set_' . $propName;
		if (method_exists($this->_calledClass, $setter)) {
			$this->{$setter}($in);
			return;
		}

		/** All properties are now handled as objects. */
		$propertyDefaultValue = $this->_defaultValues[$propName];

		//	Handle our atomic types.
		if ($propertyDefaultValue instanceof AtomicInterface) {
			$this->{$propName}->set($in);
			return;
		}

		//	Handle our two special object types.
		if ($propertyDefaultValue instanceof TypedAbstract) {
			$this->{$propName}->assign($in);
			return;
		}

		//	Handler for other types of objects.
		$propertyClassType = get_class($propertyDefaultValue);

		//	Treat DateTime related objects as atomic.
		if ($propertyDefaultValue instanceof DateTime) {
			$this->{$propName} = new $propertyClassType($in);
			return;
		}

		switch (gettype($in)) {
			case 'object':
				//	if identical types then reference the original object
				if ($propertyClassType === get_class($in)) {
					$this->{$propName} = $in;
				}

				//	Else give up.
				else {
					throw new InvalidArgumentException('cannot coerce object types');
				}
				break;

			case 'null':
			case 'NULL':
				$this->{$propName} = clone $propertyDefaultValue;
				break;

			case 'array':
				if ($propertyClassType === 'stdClass') {
					$this->{$propName} = (object)$in;
					break;
				}
			//	fall through

			default:
				//	Other classes might be able to absorb/convert other input,
				//		like «DateTime::__construct("now")» accepts a string.
				$this->{$propName} = new $propertyClassType($in);
		}
	}
protected function _setByName($propName, $in)
	{
		if (array_key_exists($propName, $this->_map)) {
			$propName = $this->_map[$propName];
		}

		$setter = '_set_' . $propName;
		if (method_exists($this->_calledClass, $setter)) {
			$this->{$setter}($in);
			return;
		}

		/** All properties are now handled as objects. */
		$propertyDefaultValue = $this->_defaultValues[$propName];

		//	Handle our atomic types.
		if ($propertyDefaultValue instanceof AtomicInterface) {
			$this->{$propName}->set($in);
			return;
		}

		//	Handle our two special object types.
		if ($propertyDefaultValue instanceof TypedAbstract) {
			$this->{$propName}->assign($in);
			return;
		}

		//	Handler for other types of objects.
		$propertyClassType = get_class($propertyDefaultValue);

		//	Treat DateTime related objects as atomic.
		if ($propertyDefaultValue instanceof DateTime) {
			$this->{$propName} = new $propertyClassType($in);
			return;
		}

		switch (gettype($in)) {
			case 'object':
				//	if identical types then reference the original object
				if ($propertyClassType === get_class($in)) {
					$this->{$propName} = $in;
				}

				//	Else give up.
				else {
					throw new InvalidArgumentException('cannot coerce object types');
				}
				break;

			case 'null':
			case 'NULL':
				$this->{$propName} = clone $propertyDefaultValue;
				break;

			case 'array':
				if ($propertyClassType === 'stdClass') {
					$this->{$propName} = (object)$in;
					break;
				}
			//	fall through

			default:
				//	Other classes might be able to absorb/convert other input,
				//		like «DateTime::__construct("now")» accepts a string.
				$this->{$propName} = new $propertyClassType($in);
		}
	}
Set data to named variable.
Casts the incoming data ($v) to the same type as the named ($k) property.

@param string $propName
@param mixed  $in

@throws InvalidArgumentException