Instantiator
in package
implements
InstantiatorInterface
FinalYes
Table of Contents
Interfaces
- InstantiatorInterface
- Instantiator provides utility methods to build objects without invoking their constructors
Constants
- SERIALIZATION_FORMAT_AVOID_UNSERIALIZER = 'O'
- SERIALIZATION_FORMAT_USE_UNSERIALIZER = 'C'
- Markers used internally by PHP to define whether {@see \unserialize} should invoke the method {@see \Serializable::unserialize()} when dealing with classes implementing the {@see \Serializable} interface.
Properties
- $cachedCloneables : array<string|int, object>
- Array of objects that can directly be cloned, indexed by class name.
- $cachedInstantiators : array<string|int, callable>
- Used to instantiate specific classes, indexed by class name.
Methods
- instantiate() : object
- attemptInstantiationViaUnSerialization() : void
- buildAndCacheFromFactory() : object
- Builds the requested object and caches it in static properties for performance
- buildFactory() : callable
- Builds a callable capable of instantiating the given $className without invoking its constructor.
- checkIfUnSerializationIsSupported() : void
- getReflectionClass() : ReflectionClass
- hasInternalAncestors() : bool
- Verifies whether the given class is to be considered internal
- isInstantiableViaReflection() : bool
- isSafeToClone() : bool
- Checks if a class is cloneable
Constants
SERIALIZATION_FORMAT_AVOID_UNSERIALIZER
private
mixed
SERIALIZATION_FORMAT_AVOID_UNSERIALIZER
= 'O'
SERIALIZATION_FORMAT_USE_UNSERIALIZER
Markers used internally by PHP to define whether {@see \unserialize} should invoke the method {@see \Serializable::unserialize()} when dealing with classes implementing the {@see \Serializable} interface.
This constant will be private in 2.0
private
mixed
SERIALIZATION_FORMAT_USE_UNSERIALIZER
= 'C'
Properties
$cachedCloneables
Array of objects that can directly be cloned, indexed by class name.
private
static array<string|int, object>
$cachedCloneables
= []
$cachedInstantiators
Used to instantiate specific classes, indexed by class name.
private
static array<string|int, callable>
$cachedInstantiators
= []
Methods
instantiate()
public
instantiate(string $className) : object
Parameters
- $className : string
Tags
Return values
objectattemptInstantiationViaUnSerialization()
private
attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, string $serializedString) : void
Parameters
- $reflectionClass : ReflectionClass
- $serializedString : string
Tags
buildAndCacheFromFactory()
Builds the requested object and caches it in static properties for performance
private
buildAndCacheFromFactory(string $className) : object
Parameters
- $className : string
Tags
Return values
objectbuildFactory()
Builds a callable capable of instantiating the given $className without invoking its constructor.
private
buildFactory(string $className) : callable
Parameters
- $className : string
Tags
Return values
callablecheckIfUnSerializationIsSupported()
private
checkIfUnSerializationIsSupported(ReflectionClass $reflectionClass, string $serializedString) : void
Parameters
- $reflectionClass : ReflectionClass
- $serializedString : string
Tags
getReflectionClass()
private
getReflectionClass(string $className) : ReflectionClass
Parameters
- $className : string
Tags
Return values
ReflectionClasshasInternalAncestors()
Verifies whether the given class is to be considered internal
private
hasInternalAncestors(ReflectionClass $reflectionClass) : bool
Parameters
- $reflectionClass : ReflectionClass
Tags
Return values
boolisInstantiableViaReflection()
private
isInstantiableViaReflection(ReflectionClass $reflectionClass) : bool
Parameters
- $reflectionClass : ReflectionClass
Tags
Return values
boolisSafeToClone()
Checks if a class is cloneable
private
isSafeToClone(ReflectionClass $reflectionClass) : bool
Classes implementing __clone
cannot be safely cloned, as that may cause side-effects.
Parameters
- $reflectionClass : ReflectionClass