You are here

private function Instantiator::buildFactory in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php \Doctrine\Instantiator\Instantiator::buildFactory()

Builds a {invoking its constructor.

Parameters

string $className:

Return value

Closure

See also

\Closure} capable of instantiating the given $className without

1 call to Instantiator::buildFactory()
Instantiator::buildAndCacheFromFactory in vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php
Builds the requested object and caches it in static properties for performance

File

vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php, line 98

Class

Instantiator
@author Marco Pivetta <ocramius@gmail.com>

Namespace

Doctrine\Instantiator

Code

private function buildFactory($className) {
  $reflectionClass = $this
    ->getReflectionClass($className);
  if ($this
    ->isInstantiableViaReflection($reflectionClass)) {
    return function () use ($reflectionClass) {
      return $reflectionClass
        ->newInstanceWithoutConstructor();
    };
  }
  $serializedString = sprintf('%s:%d:"%s":0:{}', $this
    ->getSerializationFormat($reflectionClass), strlen($className), $className);
  $this
    ->checkIfUnSerializationIsSupported($reflectionClass, $serializedString);
  return function () use ($serializedString) {
    return unserialize($serializedString);
  };
}