@param DataInterface $object
@param string        $attribute
@param mixed         $rawValue
@param array         $context

@return array
482730
protected function getAttributeContext(
        DataInterface $object,
        $attribute,
        /** @noinspection PhpUnusedParameterInspection */
        $rawValue,
        array $context
    ) {
        return array_merge(
            $context,
            [
                'parent' => $object,
                'attribute' => $attribute,
            ]
        );
    }
129557
protected function parseObject(ObjectInterface $object, array $data)
    {
        foreach ($data as $index => $value) {
            if (false !== strpos($index, '$')) {
                $index = str_replace('$', '_', $index);
            }

            if (property_exists($object, $index)) {
                $object = $this->parseProperty($object, $index, $value);
            } elseif (true == ($fieldTypeClassName = $object->isFieldPatternedField($index))) {
                $object = $this->parsePatternedField($object, $fieldTypeClassName, $index, $value);
            }
        }

        return $object;
    }
1064595
protected static function rawData( $object )
    {
        if ( is_object( $object ) )
        {
            $hash = spl_object_hash( $object );

            if ( isset( self::$rawCheck[$hash] ) )
            {
                return array( '#recursion#' => $hash );
            }

            self::$rawCheck[$hash] = true;
        }

        $object = (array) $object;

        foreach ( $object as $key => $value )
        {
            if ( is_array( $value ) || is_object( $value ) )
            {
                $object[$key] = self::rawData( $value );
            }
        }

        return (object) $object;
    }
615163
public function attributeUseHandler(
        string $attribute,
        Type\HandlerDeserializerInterface $deserialize,
        Type\HandlerSerializerInterface $serialize
    ): ObjectInterface {
        return $this;
    }
923504
public function normalize($object, $format = null, array $context = [])
    {
        if (isset($context['api_resource'])) {
            $originalResource = $context['api_resource'];
            unset($context['api_resource']);
        }

        $data = $this->decorated->normalize($object, $format, $context);
        if (!\is_array($data)) {
            throw new UnexpectedValueException('Expected data to be an array');
        }

        // when using an output class, get the IRI from the resource
        if (isset($originalResource) && isset($data['id'])) {
            $data['_id'] = $data['id'];
            $data['id'] = $this->iriConverter->getIriFromItem($originalResource);
        }

        $data[self::ITEM_RESOURCE_CLASS_KEY] = $this->getObjectClass($object);
        $data[self::ITEM_IDENTIFIERS_KEY] = $this->identifiersExtractor->getIdentifiersFromItem($object);

        return $data;
    }
299999
public function hydrateObject($object, $data, $class, $format, $context)
    {
        $attributes = $this->getAttributes($class, $format, $context);
        foreach ($attributes as $attribute) {
            $value = isset($data[$attribute]) ? $data[$attribute] : null;
            $value = $this->denormalizeProperty($value, null, $attribute, $format, $context);

            $this->setAttributeValue($object, $attribute, $value, $format, $context);
        }

        return $object;
    }
275338
public function performMappingOnObject(DataObject $object)
    {
        //By default, we already have our data mapped in the object (hopefully properly)
        //But we do need to convert things that may need converting
        foreach ($this->mapping as $field => $variable) {
            $modifier = false;
            $newField = $variable;

            if (strpos($variable, ':') !== false) {
                list($newField, $modifier) = explode(':', $variable);
                $object->$newField = $this->getMappedValue($object, $newField, $variable);
            }
        }
    }
293136
protected function isEAVGroupAllowed(/** @noinspection PhpUnusedParameterInspection */
        DataInterface $object,
        AttributeInterface $attribute,
        array $context
    ) {
        if (!isset($context[static::GROUPS]) || !\is_array($context[static::GROUPS])) {
            return true;
        }

        $serializerOptions = $attribute->getOption(static::SERIALIZER_OPTIONS, []);
        if (!array_key_exists(static::GROUPS, $serializerOptions)) {
            return false;
        }

        $groups = $serializerOptions[static::GROUPS];
        if (!\is_array($groups)) {
            throw new InvalidArgumentException(
                "Invalid 'serializer.groups' option for attribute {$attribute->getCode()} : should be an array"
            );
        }

        return 0 < \count(array_intersect($groups, $context[static::GROUPS]));
    }
157837
public function createValue(AttributeInterface $attribute, array $context = null)
    {
        $this->checkAttribute($attribute);

        return $this->getFamily()->createValue($this, $attribute, $context);
    }
267765
protected function isAllowedEAVAttribute(
        DataInterface $object,
        AttributeInterface $attribute,
        /** @noinspection PhpUnusedParameterInspection */
        $format = null,
        array $context = []
    ) {
        $options = $attribute->getOption(static::SERIALIZER_OPTIONS, []);

        // Ignore attributes set as serializer: expose: false
        if (array_key_exists(static::EXPOSE_KEY, $options) && !$options[static::EXPOSE_KEY]) {
            return false;
        }

        // If normalizing by reference, we just check if it's among the allowed attributes
        if ($this->byReferenceHandler->isByReference($context)) {
            return \in_array($attribute->getCode(), $this->referenceAttributes, true);
        }

        // Also check ignored attributes
        if (\in_array($attribute->getCode(), $this->ignoredAttributes, true)) {
            return false;
        }

        return $this->isEAVGroupAllowed($object, $attribute, $context);
    }
278207
protected function validateAttribute($object, $attribute)
    {
        $method = $this->method;
        $object->{$method}($attribute, $this->params);
    }
861412
protected function getInternalValues(AttributeInterface $attribute = null, array $context = null)
    {
        if ($context) {
            $context = array_merge($this->getCurrentContext(), $context);
        } else {
            $context = $this->getCurrentContext();
        }

        if (null === $attribute) {
            $values = new ArrayCollection();
            foreach ($this->values as $value) {
                if (!$this->getFamily()->hasAttribute($value->getAttributeCode())) {
                    $this->removeValue($value);
                    continue;
                }
                $attribute = $this->getFamily()->getAttribute($value->getAttributeCode());
                if ($attribute->isContextMatching($value, $context)) {
                    $values->add($value);
                }
            }

            return $values;
        }
        $this->checkAttribute($attribute);

        $values = new ArrayCollection();
        foreach ($this->getValuesByAttribute($attribute) as $value) {
            if ($value instanceof ContextualValueInterface) {
                if ($attribute->isContextMatching($value, $context)) {
                    $values->add($value);
                }
            } else {
                $values->add($value);
            }
        }

        return $values;
    }
1374895
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null)
    {
        if (null !== $object = $this->extractObjectToPopulate($class, $context, static::OBJECT_TO_POPULATE)) {
            unset($context[static::OBJECT_TO_POPULATE]);

            return $object;
        }

        if ($this->classDiscriminatorResolver && $mapping = $this->classDiscriminatorResolver->getMappingForClass($class)) {
            if (!isset($data[$mapping->getTypeProperty()])) {
                throw new RuntimeException(sprintf('Type property "%s" not found for the abstract object "%s"', $mapping->getTypeProperty(), $class));
            }

            $type = $data[$mapping->getTypeProperty()];
            if (null === ($mappedClass = $mapping->getClassForType($type))) {
                throw new RuntimeException(sprintf('The type "%s" has no mapped class for the abstract object "%s"', $type, $class));
            }

            $class = $mappedClass;
            $reflectionClass = new \ReflectionClass($class);
        }

        $constructor = $this->getConstructor($data, $class, $context, $reflectionClass, $allowedAttributes);
        if ($constructor) {
            $constructorParameters = $constructor->getParameters();

            $params = [];
            foreach ($constructorParameters as $constructorParameter) {
                $paramName = $constructorParameter->name;
                $key = $this->nameConverter ? $this->nameConverter->normalize($paramName, $class, $format, $context) : $paramName;

                $allowed = false === $allowedAttributes || (\is_array($allowedAttributes) && \in_array($paramName, $allowedAttributes, true));
                $ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context);
                if ($constructorParameter->isVariadic()) {
                    if ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
                        if (!\is_array($data[$paramName])) {
                            throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name));
                        }

                        $params = array_merge($params, $data[$paramName]);
                    }
                } elseif ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
                    $params[] = $this->createConstructorArgument($data[$key], $key, $constructorParameter, $context, $format);

                    // Don't run set for a parameter passed to the constructor
                    unset($data[$key]);
                } elseif (isset($context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class][$key])) {
                    $params[] = $context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class][$key];
                } elseif ($constructorParameter->isDefaultValueAvailable()) {
                    $params[] = $constructorParameter->getDefaultValue();
                } else {
                    throw new MissingConstructorArgumentsException(
                        sprintf(
                            'Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.',
                            $class,
                            $constructorParameter->name
                        )
                    );
                }
            }

            if ($constructor->isConstructor()) {
                return $reflectionClass->newInstanceArgs($params);
            }

            return $constructor->invokeArgs(null, $params);
        }

        return new $class();
    }
1357652
private function setArrayAndCheckNullWithKey(array $data, $object, $key, $attribute): array
    {
        $value = $this->setArray($object);

        if ($this->checkNullForAttribute($value, $key) === false) {
            $data[$attribute][$key] = $value;
        }

        return $data;
    }
165900
public function parseDateTime($rawValue) {
		if (null === $rawValue) return null;
		
		try {
			return DateUtils::createDateTimeFromFormat(SqliteDateTimeColumn::FORMAT_DATE_TIME, $rawValue);
		} catch (\n2n\util\DateParseException $e) {
			throw new \InvalidArgumentException($e->getMessage(), 0, $e);
		}
	}
884367
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
    {
        if (
            isset($context['object_to_populate']) &&
            is_object($context['object_to_populate']) &&
            $class === get_class($context['object_to_populate'])
        ) {
            return $context['object_to_populate'];
        }

        $format = null;
        if (isset($context['format'])) {
            $format = $context['format'];
        }

        $constructor = $reflectionClass->getConstructor();
        if (!$constructor) {
            return new $class();
        }

        $constructorParameters = $constructor->getParameters();

        $params = array();
        foreach ($constructorParameters as $constructorParameter) {
            $paramName = $constructorParameter->name;
            $key = $this->nameConverter ? $this->nameConverter->normalize($paramName) : $paramName;

            $allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes);
            $ignored = in_array($paramName, $this->ignoredAttributes);

            if (!$allowed || $ignored) {
                continue;
            }

            $missing = !isset($data[$key]) && !array_key_exists($key, $data);
            $variadic = method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic();

            if ($variadic && !$missing && !is_array($data[$paramName])) {
                $message = 'Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.';
                throw new RuntimeException(sprintf($message, $class, $constructorParameter->name));
            }

            if ($variadic && !$missing) {
                $params = array_merge($params, $data[$paramName]);

                continue;
            }

            if ($missing && !$variadic && !$constructorParameter->isDefaultValueAvailable()) {
                $message = 'Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.';
                throw new RuntimeException(sprintf($message, $class, $constructorParameter->name));
            }

            if ($missing && $constructorParameter->isDefaultValueAvailable()) {
                $params[] = $constructorParameter->getDefaultValue();

                continue;
            }

            if (!$missing) {
                $params[] = $this->denormalizeProperty($data[$key], $class, $key, $format, $context);

                unset($data[$key]);
            }
        }

        return $reflectionClass->newInstanceArgs($params);
    }
125400
protected function createDefaultValues(AttributeInterface $attribute, array $context = null)
    {
        $default = $attribute->getDefault();
        if (!$attribute->isCollection()) {
            $default = (array) $default;
        }

        return $this->setInternalValuesData($attribute, $default, $context);
    }