public static function f($class) { $reflector = self::
$reflectors[$class] ??= self::
getClassReflector($class, true, false
);
return self::
$factories[$class] =
[$reflector, 'newInstanceWithoutConstructor'
](...
);
} public static function getClassReflector($class,
$instantiableWithoutConstructor = false,
$cloneable = null
) { if (!
($isClass =
class_exists($class)) && !
interface_exists($class, false
) && !
trait_exists($class, false
)) { throw new ClassNotFoundException($class);
} $reflector =
new \
ReflectionClass($class);
if ($instantiableWithoutConstructor) { $proto =
$reflector->
newInstanceWithoutConstructor();
} elseif (!
$isClass ||
$reflector->
isAbstract()) { throw new NotInstantiableTypeException($class);
} elseif ($reflector->name !==
$class) { $reflector = self::
$reflectors[$name =
$reflector->name
] ??= self::
getClassReflector($name, false,
$cloneable);
self::
$cloneable[$class] = self::
$cloneable[$name];
self::
$instantiableWithoutConstructor[$class] = self::
$instantiableWithoutConstructor[$name];