@param $value
@param $className
@param ReflectionClass $reflection
@param Driver          $serializer

@return array
979781
public static function getRelationshipAsPropertyName(
        $value,
        $className,
        ReflectionClass $reflection,
        Driver $serializer
    ) {
        $methods = [];
        foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
            if (ltrim($method->class, '\\') !== ltrim($className, '\\')) {
                continue;
            }

            $name = $method->name;
            $reflectionMethod = $reflection->getMethod($name);

            if (!self::isAllowedEloquentModelFunction($name) || $reflectionMethod->getNumberOfParameters() > 0) {
                continue;
            }

            if (in_array($name, $value->getHidden(), true)) {
                continue;
            }

            try {
                $returned = $reflectionMethod->invoke($value);

                if (!(\is_object($returned) && self::isAnEloquentRelation($returned))) {
                    continue;
                }

                $relationData = $returned->getResults();

                if ($relationData instanceof Traversable) {
                    //Something traversable with Models
                    $items = [];

                    foreach ($relationData as $model) {
                        if ($model instanceof Model) {
                            $items[] = self::getModelData($serializer, $model);
                        }
                    }

                    $methods[$name] = [
                        Serializer::MAP_TYPE => 'array',
                        Serializer::SCALAR_VALUE => $items,
                    ];
                } elseif ($relationData instanceof Model) {
                    //Single element returned.
                    $methods[$name] = self::getModelData($serializer, $relationData);
                }

            } catch (ErrorException $e) {
            }
        }

        return $methods;
    }
707091
public function getProperties($value, ReflectionClass $class, $propertyFilter)
	{
		$attributes = array_merge($value->getAttributes(), $value->getRelations());

		$visible = $value->getVisible();

		if (count($visible) === 0)
		{
			$visible = array_diff(array_keys($attributes), $value->getHidden());
		}

		if ( ! $this->showHidden($propertyFilter))
		{
			return array_intersect_key($attributes, array_flip($visible));
		}

		$properties = [];

		foreach ($attributes as $key => $value)
		{
			if ( ! in_array($key, $visible))
			{
				$key = sprintf('<protected>%s</protected>', $key);
			}

			$properties[$key] = $value;
		}

		return $properties;
	}
805595
protected function getApiMapping($className)
    {
        $apiMapping = Config::inst()->get($className, 'api_field_mapping');
        if ($apiMapping && is_array($apiMapping)) {
            return $apiMapping;
        }
        return [];
    }
1313489
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null)
    {
        $beanName = $objectAnnotation->getName();
        $beanName = empty($beanName) ? $className : $beanName;
        $scope    = Scope::SINGLETON;

        DefinitionCollector::collect($className, $objectAnnotation, $propertyName, $methodName, $propertyValue);

        return [$beanName, $scope, ""];
    }
333444
public function parser(
        string $className,
        $objectAnnotation = null,
        string $propertyName = '',
        string $methodName = '',
        $propertyValue = null
    ) {
        $collector = ControllerCollector::getCollector();

        if (!isset($collector[$className])) {
            return;
        }

        // Collect requestMapping
        ControllerCollector::collect($className, $objectAnnotation, $propertyName, $methodName, $propertyValue);
    }
219080
public static function collect(
        string $className,
        $objectAnnotation = null,
        string $propertyName = '',
        string $methodName = '',
        $propertyValue = null
    ) {
        if ($objectAnnotation instanceof Statement) {
            $driver                    = $objectAnnotation->getDriver();
            self::$statements[$driver] = $className;
        }
    }
161455
private function deserializeValue($value)
    {
        if (is_array($value) && isset($value['class']) && isset($value['payload'])) {
            return $this->deserializeObjectRecursively($value);
        } elseif (is_array($value)) {
            return $this->deserializeArrayRecursively($value);
        }

        return $value;
    }
680007
public function serialize($value)
    {
        $this->reset();

        return $this->serializationStrategy->serialize($this->serializeData($value));
    }
1293262
private Class<?> serializerToClass(String value) {
    try {
      return Thread.currentThread().getContextClassLoader().loadClass(value);
    } catch (ClassNotFoundException e) {
      throw new ConfigurationException("unknown serializable type: " + value);
    }
  }
723099
public static function unserialize(Serializer $serializer, $className, array $value)
    {
        $dateTimeZone = DateTimeZoneSerializer::unserialize(
            $serializer,
            'DateTimeZone',
            array($serializer->unserialize($value['data']['timezone']))
        );

        $ref = new ReflectionClass($className);

        return $ref->newInstanceArgs(
            array($serializer->unserialize($value['data']['date']), $dateTimeZone)
        );
    }
914167
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null)
    {
        $scope    = Scope::PROTOTYPE;
        $name     = $objectAnnotation->getName();
        $beanName = empty($name) ? $className : $name;

        ProcessCollector::collect($className, $objectAnnotation, $propertyName, $methodName, $propertyValue);

        return [$beanName, $scope, ""];
    }
281017
public function getRealFields($className, $fields)
    {
        $apiMapping = $this->getApiMapping($className);
        if (is_array($apiMapping) && is_array($fields)) {
            $mappedFields = [];
            foreach ($fields as $field) {
                $mappedFields[] = $this->getMappedKey($apiMapping, $field);
            }
            return $mappedFields;
        }
        return $fields;
    }
709271
public function create(string $className): array
    {
        $this->findIdentityField($className);

        $class = $this->metadata->getReflectionClass();
        $methods = $class->getMethods(ReflectionMethod::IS_PUBLIC);
        $fieldConfigurations = [];
        foreach ($methods as $method) {
            // Skip non-callable or non-instance
            if ($method->isAbstract() || $method->isStatic()) {
                continue;
            }

            // Skip non-getter methods
            $name = $method->getName();
            if (!preg_match($this->getMethodPattern(), $name)) {
                continue;
            }

            // Skip exclusion specified by user
            if ($this->isExcluded($method)) {
                continue;
            }

            $configuration = $this->methodToConfiguration($method);
            if ($configuration) {
                $fieldConfigurations[] = $configuration;
            }
        }

        return $fieldConfigurations;
    }
385325
protected function unserializeObject(array $value)
    {
        $className = $value[self::CLASS_IDENTIFIER_KEY];
        unset($value[self::CLASS_IDENTIFIER_KEY]);

        if (isset($value[self::MAP_TYPE])) {
            unset($value[self::MAP_TYPE]);
            unset($value[self::SCALAR_VALUE]);
        }

        if ($className[0] === '@') {
            return self::$objectMapping[substr($className, 1)];
        }

        if (!class_exists($className)) {
            throw new SerializerException('Unable to find class '.$className);
        }

        return (null === ($obj = $this->unserializeDateTimeFamilyObject($value, $className)))
            ? $this->unserializeUserDefinedObject($value, $className) : $obj;
    }
810089
private function getBindParams(string $className, string $methodName, \Throwable $throwable)
    {
        $reflectClass  = new \ReflectionClass($className);
        $reflectMethod = $reflectClass->getMethod($methodName);
        $reflectParams = $reflectMethod->getParameters();
        $response      = RequestContext::getResponse();
        $request       = RequestContext::getRequest();

        // binding params
        $bindParams = [];
        foreach ($reflectParams as $key => $reflectParam) {
            $reflectType = $reflectParam->getType();

            // undefined type of the param
            if ($reflectType === null) {
                $bindParams[$key] = null;
                continue;
            }

            /**
             * defined type of the param
             * @notice \ReflectType::getName() is not supported in PHP 7.0, that is why use __toString()
             */
            $type = $reflectType->__toString();
            if ($type === Request::class) {
                $bindParams[$key] = $request;
            } elseif ($type == Response::class) {
                $bindParams[$key] = $response;
            } elseif ($type == \Throwable::class) {
                $bindParams[$key] = $throwable;
            } else {
                $bindParams[$key] = null;
            }
        }

        return $bindParams;
    }
501804
protected static function getTypedValue(Serializer $serializer, array $value)
    {
        foreach ($value as &$v) {
            $v = $serializer->unserialize($v);
        }

        return $value;
    }
268558
protected function getValueArray($name, $value = null)
    {
        // Looks for the values in "old"
        if (!$this->oldInputIsEmpty()) {
            if (is_null($this->session->getOldInput($name))) { // we have old input, but none for this name
                return [];
            } else {
                return $this->session->getOldInput($name);
            }
        }
        // Looks for the values in the Request
        if (isset($this->request) and $this->request->input($name)) {
            return $this->request->input($name);
        }
        // Returns the default value
        return empty($value) ? [] : $value;
    }