@param array     $json
@param string    $class
@param Callable  $callback

@return mixed
421449
private static function transformArray(array $json, $class, $callback)
    {
        return array_map(function ($json) use ($class, $callback) {
            return static::transformObject($json, $class, $callback);
        }, $json);
    }
958368
public static Object toArray( JSONArray jsonArray, Class objectClass ) {
      JsonConfig jsonConfig = new JsonConfig();
      jsonConfig.setRootClass( objectClass );
      return toArray( jsonArray, jsonConfig );
   }
1068543
protected function callClassBasedExtension( $callback, $parameters )
	{
		if ( Str::contains( $callback, '@' ) )
			list( $class, $method ) = explode( '@', $callback );
		else
			list( $class, $method ) = [$callback, 'validate'];

		return call_user_func_array( [BindingBuilder::resolveBinding( $class ), $method], $parameters );
	}
1286321
protected function transformResponse(string $class = null)
    {
        if (200 !== $this->getResponse()->getStatusCode()
            && 201 !== $this->getResponse()->getStatusCode()
        ) {
            return $this->handleException();
        }

        if (null === $this->getInstapushClient()->getTransformer() || null === $class) {
            return \json_decode($this->getResponse()->getBody()->getContents(), true);
        }

        return $this->getInstapushClient()->getTransformer()->transform($this->getResponse(), $class);
    }
429280
function (callback) {
    var data = JSON.stringify(this);
    this.cloneWithoutData(function(clone) {
      clone.loadFromJSON(data, function() {
        callback && callback(clone);
      });
    });
  }
731015
static function executeCallback($callback, array $params = array()) {
    // If callback has @
    if (is_string($callback) && strpos($callback, '@') !== false) {
      // Split
      $arrCallback = explode('@', $callback);
      // Set object
      $object = class_exists($arrCallback[0]) ? (new $arrCallback[0]()) : null;
      // Set method
      $method = isset($arrCallback[0]) ? $arrCallback[0] : null;
      // Set callback
      $callback = array($object, $method);
    }
    // If not callable
    if ( ! is_callable($callback)) {
      // Throw error
      throw new InvalidCallback('Callback must be callable');
    }
    // Execute and return
    return call_user_func_array($callback, $params);
  }
728128
protected function handleClassCallback(string $callback): array
    {
        list($class, $method) = $this->parseCallback($callback);
        $instance = $this->container->make($class);

        return [$instance, $method];
    }
1132428
private function implementJsonSerialize(Type $type, ClassGenerator $class)
    {
        $methodName = 'jsonSerialize';
        $class->removeMethod($methodName);
        $class->addMethodFromGenerator(
            MethodGenerator::fromArray([
                'name' => $methodName,
                'parameters' => [],
                'visibility' => MethodGenerator::VISIBILITY_PUBLIC,
                'body' => $this->generateJsonSerializeBody($type, $class),
                'docblock' => DocBlockGeneratorFactory::fromArray([
                    'tags' => [
                        [
                            'name' => 'return',
                            'description' => 'array'
                        ]
                    ]
                ])
            ])
        );
    }
834561
public function serialize($jobId, $class, $args = [], $retry = true, $queue = null)
    {
        $class = is_object($class) ? get_class($class) : $class;

        $data = [
            'class' => $class,
            'jid' => $jobId,
            'created_at' => microtime(true),
            'enqueued_at' => microtime(true),
            'args' => $args,
            'retry' => $retry,
        ];

        if ($queue !== null) {
            $data['queue'] = $queue;
        }

        $jsonEncodedData = json_encode($data);

        if ($jsonEncodedData === false) {
            throw new JsonEncodeException($data, json_last_error(), json_last_error_msg());
        }

        return $jsonEncodedData;
    }
268726
public function jsonp($content = [], $jsonCallback = 'callback')
	{
		$response = new JsonResponse();
		$response->setData($content);
		$response->setCallback($jsonCallback);
		$response->send();
	}
1152907
private static function MakeMapperThrowIfJsonDefNotValid(
        string $class,
        array $jsonDef,
        array $array
    ) : Closure {
        $mapper =
            /**
            * @return scalar|array|object|null
            */
            function (string $prop) use ($jsonDef, $array, $class) {
                if (isset($jsonDef[$prop]) && false === is_array($array[$prop])) {
                    static::ThrowBecauseArrayJsonTypeNotValid(
                        $class,
                        $jsonDef[$prop],
                        $prop
                    );
                }

                return $array[$prop];
            };

        return $mapper;
    }
313891
private function __setCallback($type, $class, array $args)
    {
        if (!is_array($class)) {
            $this->{$type} = [
                [
                    'class' => $class,
                    'args' => $args
                ]
            ];

            return $this;
        } elseif (is_array($class) && count($class) == 2) {
            $className = $class[0];
            $methodName = $class[1];
        } else {
            if (is_array($class)) {
                $class = implode($class);
            }
            throw new \InvalidArgumentException("{$class} is missformated");
        }

        $this->{$type} = [
            [
                'class' => [$className, $methodName],
                'args' => $args
            ]
        ];

        return $this;
    }
314246
private function createInstance(string $class, array $data)
    {
        $rule = $this->rules[$class];

        $reflectionClass = new \ReflectionClass($class);
        $object = $reflectionClass->newInstanceWithoutConstructor();
        $reflectionObject = new \ReflectionObject($object);

        foreach ($rule->getMap() as $property => $key) {
            $reflectionProperty = $reflectionObject->getProperty($property);
            $reflectionProperty->setAccessible(true);

            $constructor = $rule->getConstructor($property);

            $reflectionProperty->setValue($object, is_callable($constructor) ? $constructor($data[$key]) : $data[$key]);
        }

        return $object;
    }
468200
public static function newObject(string $class, array $args = [], $callGetClass = false)
    {
        $class = $callGetClass ? static::getClass($class) : $class;
        $rc = new \ReflectionClass($class);
        return $rc->newInstanceArgs($args);
    }
128987
public static function createFromJSON($className, $json, $isError=false) {
        if(!$className) {
            throw new Exception('Invalid className:'.$className);
        }
        $model = new $className();
        self::fillFromJSON($model, $json, $isError);
        return $model;
    }
839459
private function wrapResponse($class, $httpResponse = null)
    {
        $data = [];
        try {
            if (isset($httpResponse)) {
                $this->checkResponse($httpResponse);
                $body = (string)$httpResponse->getBody();
                if (!$this->isJson($body)) {
                    $this->log('error', "Response is not valid JSON");
                    $this->addError(self::ERROR_INVALID_JSON);
                } else {
                    $data = json_decode($body, true);
                }
            } else {
                $this->log('error', "Response from gateway is empty");
                $this->addError(self::ERROR_EMPTY_RESPONSE);
            }
        } catch (RequestException $e) {
            // An error code is already provided by checkResponse
        }

        /** @var AbstractResponse $response */
        $response = new $class($data);
        foreach ($this->getErrors() as $errorCode) {
            $response->addError($errorCode);
        }

        return $response;
    }
890885
public static function object(\Closure $callback) {
		$obj = new Object;
		$callback->__invoke($obj);
		return json_encode($obj);
	}