Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1431630
AbstractCloner.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
22 KB
Referenced Files
None
Subscribers
None
AbstractCloner.php
View Options
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\VarDumper\Cloner
;
use
Symfony\Component\VarDumper\Caster\Caster
;
use
Symfony\Component\VarDumper\Exception\ThrowingCasterException
;
/**
* AbstractCloner implements a generic caster mechanism for objects and resources.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
abstract
class
AbstractCloner
implements
ClonerInterface
{
public
static
array
$defaultCasters
=
[
'__PHP_Incomplete_Class'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\C
aster'
,
'castPhpIncompleteClass'
],
'Symfony
\C
omponent
\V
arDumper
\C
aster
\C
utStub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'castStub'
],
'Symfony
\C
omponent
\V
arDumper
\C
aster
\C
utArrayStub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'castCutArray'
],
'Symfony
\C
omponent
\V
arDumper
\C
aster
\C
onstStub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'castStub'
],
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
numStub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'castEnum'
],
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
calarStub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'castScalar'
],
'Fiber'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\F
iberCaster'
,
'castFiber'
],
'Closure'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castClosure'
],
'Generator'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castGenerator'
],
'ReflectionType'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castType'
],
'ReflectionAttribute'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castAttribute'
],
'ReflectionGenerator'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castReflectionGenerator'
],
'ReflectionClass'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castClass'
],
'ReflectionClassConstant'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castClassConstant'
],
'ReflectionFunctionAbstract'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castFunctionAbstract'
],
'ReflectionMethod'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castMethod'
],
'ReflectionParameter'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castParameter'
],
'ReflectionProperty'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castProperty'
],
'ReflectionReference'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castReference'
],
'ReflectionExtension'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castExtension'
],
'ReflectionZendExtension'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
eflectionCaster'
,
'castZendExtension'
],
'Doctrine
\C
ommon
\P
ersistence
\O
bjectManager'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'Doctrine
\C
ommon
\P
roxy
\P
roxy'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
octrineCaster'
,
'castCommonProxy'
],
'Doctrine
\O
RM
\P
roxy
\P
roxy'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
octrineCaster'
,
'castOrmProxy'
],
'Doctrine
\O
RM
\P
ersistentCollection'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
octrineCaster'
,
'castPersistentCollection'
],
'Doctrine
\P
ersistence
\O
bjectManager'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'DOMException'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castException'
],
'Dom
\E
xception'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castException'
],
'DOMStringList'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castLength'
],
'DOMNameList'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castLength'
],
'DOMImplementation'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castImplementation'
],
'Dom
\I
mplementation'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castImplementation'
],
'DOMImplementationList'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castLength'
],
'DOMNode'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castNode'
],
'Dom
\N
ode'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castNode'
],
'DOMNameSpaceNode'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castNameSpaceNode'
],
'DOMDocument'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castDocument'
],
'Dom
\X
MLDocument'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castXMLDocument'
],
'Dom
\H
TMLDocument'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castHTMLDocument'
],
'DOMNodeList'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castLength'
],
'Dom
\N
odeList'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castLength'
],
'DOMNamedNodeMap'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castLength'
],
'Dom
\D
TDNamedNodeMap'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castLength'
],
'DOMCharacterData'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castCharacterData'
],
'Dom
\C
haracterData'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castCharacterData'
],
'DOMAttr'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castAttr'
],
'Dom
\A
ttr'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castAttr'
],
'DOMElement'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castElement'
],
'Dom
\E
lement'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castElement'
],
'DOMText'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castText'
],
'Dom
\T
ext'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castText'
],
'DOMDocumentType'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castDocumentType'
],
'Dom
\D
ocumentType'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castDocumentType'
],
'DOMNotation'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castNotation'
],
'Dom
\N
otation'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castNotation'
],
'DOMEntity'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castEntity'
],
'Dom
\E
ntity'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castEntity'
],
'DOMProcessingInstruction'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castProcessingInstruction'
],
'Dom
\P
rocessingInstruction'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castProcessingInstruction'
],
'DOMXPath'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
OMCaster'
,
'castXPath'
],
'XMLReader'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\X
mlReaderCaster'
,
'castXmlReader'
],
'ErrorException'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
xceptionCaster'
,
'castErrorException'
],
'Exception'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
xceptionCaster'
,
'castException'
],
'Error'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
xceptionCaster'
,
'castError'
],
'Symfony
\B
ridge
\M
onolog
\L
ogger'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'Symfony
\C
omponent
\D
ependencyInjection
\C
ontainerInterface'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'Symfony
\C
omponent
\E
ventDispatcher
\E
ventDispatcherInterface'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'Symfony
\C
omponent
\H
ttpClient
\A
mpHttpClient'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castHttpClient'
],
'Symfony
\C
omponent
\H
ttpClient
\C
urlHttpClient'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castHttpClient'
],
'Symfony
\C
omponent
\H
ttpClient
\N
ativeHttpClient'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castHttpClient'
],
'Symfony
\C
omponent
\H
ttpClient
\R
esponse
\A
mpResponse'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castHttpClientResponse'
],
'Symfony
\C
omponent
\H
ttpClient
\R
esponse
\A
mpResponseV4'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castHttpClientResponse'
],
'Symfony
\C
omponent
\H
ttpClient
\R
esponse
\A
mpResponseV5'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castHttpClientResponse'
],
'Symfony
\C
omponent
\H
ttpClient
\R
esponse
\C
urlResponse'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castHttpClientResponse'
],
'Symfony
\C
omponent
\H
ttpClient
\R
esponse
\N
ativeResponse'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castHttpClientResponse'
],
'Symfony
\C
omponent
\H
ttpFoundation
\R
equest'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castRequest'
],
'Symfony
\C
omponent
\U
id
\U
lid'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castUlid'
],
'Symfony
\C
omponent
\U
id
\U
uid'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castUuid'
],
'Symfony
\C
omponent
\V
arExporter
\I
nternal
\L
azyObjectState'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
ymfonyCaster'
,
'castLazyObjectState'
],
'Symfony
\C
omponent
\V
arDumper
\E
xception
\T
hrowingCasterException'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
xceptionCaster'
,
'castThrowingCasterException'
],
'Symfony
\C
omponent
\V
arDumper
\C
aster
\T
raceStub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
xceptionCaster'
,
'castTraceStub'
],
'Symfony
\C
omponent
\V
arDumper
\C
aster
\F
rameStub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
xceptionCaster'
,
'castFrameStub'
],
'Symfony
\C
omponent
\V
arDumper
\C
loner
\A
bstractCloner'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'Symfony
\C
omponent
\E
rrorHandler
\E
xception
\F
lattenException'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
xceptionCaster'
,
'castFlattenException'
],
'Symfony
\C
omponent
\E
rrorHandler
\E
xception
\S
ilencedErrorContext'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\E
xceptionCaster'
,
'castSilencedErrorContext'
],
'Imagine
\I
mage
\I
mageInterface'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\I
magineCaster'
,
'castImage'
],
'Ramsey
\U
uid
\U
uidInterface'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\U
uidCaster'
,
'castRamseyUuid'
],
'ProxyManager
\P
roxy
\P
roxyInterface'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\P
roxyManagerCaster'
,
'castProxy'
],
'PHPUnit_Framework_MockObject_MockObject'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'PHPUnit
\F
ramework
\M
ockObject
\M
ockObject'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'PHPUnit
\F
ramework
\M
ockObject
\S
tub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'Prophecy
\P
rophecy
\P
rophecySubjectInterface'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'Mockery
\M
ockInterface'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
tubCaster'
,
'cutInternals'
],
'PDO'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\P
doCaster'
,
'castPdo'
],
'PDOStatement'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\P
doCaster'
,
'castPdoStatement'
],
'AMQPConnection'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\A
mqpCaster'
,
'castConnection'
],
'AMQPChannel'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\A
mqpCaster'
,
'castChannel'
],
'AMQPQueue'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\A
mqpCaster'
,
'castQueue'
],
'AMQPExchange'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\A
mqpCaster'
,
'castExchange'
],
'AMQPEnvelope'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\A
mqpCaster'
,
'castEnvelope'
],
'ArrayObject'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castArrayObject'
],
'ArrayIterator'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castArrayIterator'
],
'SplDoublyLinkedList'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castDoublyLinkedList'
],
'SplFileInfo'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castFileInfo'
],
'SplFileObject'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castFileObject'
],
'SplHeap'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castHeap'
],
'SplObjectStorage'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castObjectStorage'
],
'SplPriorityQueue'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castHeap'
],
'OuterIterator'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castOuterIterator'
],
'WeakMap'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castWeakMap'
],
'WeakReference'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\S
plCaster'
,
'castWeakReference'
],
'Redis'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
edisCaster'
,
'castRedis'
],
'Relay
\R
elay'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
edisCaster'
,
'castRedis'
],
'RedisArray'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
edisCaster'
,
'castRedisArray'
],
'RedisCluster'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
edisCaster'
,
'castRedisCluster'
],
'DateTimeInterface'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
ateCaster'
,
'castDateTime'
],
'DateInterval'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
ateCaster'
,
'castInterval'
],
'DateTimeZone'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
ateCaster'
,
'castTimeZone'
],
'DatePeriod'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
ateCaster'
,
'castPeriod'
],
'GMP'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\G
mpCaster'
,
'castGmp'
],
'MessageFormatter'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\I
ntlCaster'
,
'castMessageFormatter'
],
'NumberFormatter'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\I
ntlCaster'
,
'castNumberFormatter'
],
'IntlTimeZone'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\I
ntlCaster'
,
'castIntlTimeZone'
],
'IntlCalendar'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\I
ntlCaster'
,
'castIntlCalendar'
],
'IntlDateFormatter'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\I
ntlCaster'
,
'castIntlDateFormatter'
],
'Memcached'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\M
emcachedCaster'
,
'castMemcached'
],
'Ds
\C
ollection'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
sCaster'
,
'castCollection'
],
'Ds
\M
ap'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
sCaster'
,
'castMap'
],
'Ds
\P
air'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
sCaster'
,
'castPair'
],
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
sPairStub'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\D
sCaster'
,
'castPairStub'
],
'mysqli_driver'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\M
ysqliCaster'
,
'castMysqliDriver'
],
'CurlHandle'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castCurl'
],
':dba'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castDba'
],
':dba persistent'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castDba'
],
'GdImage'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castGd'
],
':gd'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castGd'
],
':pgsql large object'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\P
gSqlCaster'
,
'castLargeObject'
],
':pgsql link'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\P
gSqlCaster'
,
'castLink'
],
':pgsql link persistent'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\P
gSqlCaster'
,
'castLink'
],
':pgsql result'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\P
gSqlCaster'
,
'castResult'
],
':process'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castProcess'
],
':stream'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castStream'
],
'OpenSSLCertificate'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castOpensslX509'
],
':OpenSSL X.509'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castOpensslX509'
],
':persistent stream'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castStream'
],
':stream-context'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
esourceCaster'
,
'castStreamContext'
],
'XmlParser'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\X
mlResourceCaster'
,
'castXml'
],
':xml'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\X
mlResourceCaster'
,
'castXml'
],
'RdKafka'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castRdKafka'
],
'RdKafka
\C
onf'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castConf'
],
'RdKafka
\K
afkaConsumer'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castKafkaConsumer'
],
'RdKafka
\M
etadata
\B
roker'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castBrokerMetadata'
],
'RdKafka
\M
etadata
\C
ollection'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castCollectionMetadata'
],
'RdKafka
\M
etadata
\P
artition'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castPartitionMetadata'
],
'RdKafka
\M
etadata
\T
opic'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castTopicMetadata'
],
'RdKafka
\M
essage'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castMessage'
],
'RdKafka
\T
opic'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castTopic'
],
'RdKafka
\T
opicPartition'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castTopicPartition'
],
'RdKafka
\T
opicConf'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\R
dKafkaCaster'
,
'castTopicConf'
],
'FFI
\C
Data'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\F
FICaster'
,
'castCTypeOrCData'
],
'FFI
\C
Type'
=>
[
'Symfony
\C
omponent
\V
arDumper
\C
aster
\F
FICaster'
,
'castCTypeOrCData'
],
];
protected
int
$maxItems
=
2500
;
protected
int
$maxString
=
-
1
;
protected
int
$minDepth
=
1
;
/**
* @var array<string, list<callable>>
*/
private
array
$casters
=
[];
/**
* @var callable|null
*/
private
$prevErrorHandler
;
private
array
$classInfo
=
[];
private
int
$filter
=
0
;
/**
* @param callable[]|null $casters A map of casters
*
* @see addCasters
*/
public
function
__construct
(?
array
$casters
=
null
)
{
$this
->
addCasters
(
$casters
??
static
::
$defaultCasters
);
}
/**
* Adds casters for resources and objects.
*
* Maps resources or objects types to a callback.
* Types are in the key, with a callable caster for value.
* Resource types are to be prefixed with a `:`,
* see e.g. static::$defaultCasters.
*
* @param callable[] $casters A map of casters
*/
public
function
addCasters
(
array
$casters
):
void
{
foreach
(
$casters
as
$type
=>
$callback
)
{
$this
->
casters
[
$type
][]
=
$callback
;
}
}
/**
* Sets the maximum number of items to clone past the minimum depth in nested structures.
*/
public
function
setMaxItems
(
int
$maxItems
):
void
{
$this
->
maxItems
=
$maxItems
;
}
/**
* Sets the maximum cloned length for strings.
*/
public
function
setMaxString
(
int
$maxString
):
void
{
$this
->
maxString
=
$maxString
;
}
/**
* Sets the minimum tree depth where we are guaranteed to clone all the items. After this
* depth is reached, only setMaxItems items will be cloned.
*/
public
function
setMinDepth
(
int
$minDepth
):
void
{
$this
->
minDepth
=
$minDepth
;
}
/**
* Clones a PHP variable.
*
* @param int $filter A bit field of Caster::EXCLUDE_* constants
*/
public
function
cloneVar
(
mixed
$var
,
int
$filter
=
0
):
Data
{
$this
->
prevErrorHandler
=
set_error_handler
(
function
(
$type
,
$msg
,
$file
,
$line
,
$context
=
[])
{
if
(
\E_RECOVERABLE_ERROR
===
$type
||
\E_USER_ERROR
===
$type
)
{
// Cloner never dies
throw
new
\ErrorException
(
$msg
,
0
,
$type
,
$file
,
$line
);
}
if
(
$this
->
prevErrorHandler
)
{
return
(
$this
->
prevErrorHandler
)(
$type
,
$msg
,
$file
,
$line
,
$context
);
}
return
false
;
});
$this
->
filter
=
$filter
;
if
(
$gc
=
gc_enabled
())
{
gc_disable
();
}
try
{
return
new
Data
(
$this
->
doClone
(
$var
));
}
finally
{
if
(
$gc
)
{
gc_enable
();
}
restore_error_handler
();
$this
->
prevErrorHandler
=
null
;
}
}
/**
* Effectively clones the PHP variable.
*/
abstract
protected
function
doClone
(
mixed
$var
):
array
;
/**
* Casts an object to an array representation.
*
* @param bool $isNested True if the object is nested in the dumped structure
*/
protected
function
castObject
(
Stub
$stub
,
bool
$isNested
):
array
{
$obj
=
$stub
->
value
;
$class
=
$stub
->
class
;
if
(
str_contains
(
$class
,
"@anonymous
\0
"
))
{
$stub
->
class
=
get_debug_type
(
$obj
);
}
if
(
isset
(
$this
->
classInfo
[
$class
]))
{
[
$i
,
$parents
,
$hasDebugInfo
,
$fileInfo
]
=
$this
->
classInfo
[
$class
];
}
else
{
$i
=
2
;
$parents
=
[
$class
];
$hasDebugInfo
=
method_exists
(
$class
,
'__debugInfo'
);
foreach
(
class_parents
(
$class
)
as
$p
)
{
$parents
[]
=
$p
;
++
$i
;
}
foreach
(
class_implements
(
$class
)
as
$p
)
{
$parents
[]
=
$p
;
++
$i
;
}
$parents
[]
=
'*'
;
$r
=
new
\ReflectionClass
(
$class
);
$fileInfo
=
$r
->
isInternal
()
||
$r
->
isSubclassOf
(
Stub
::
class
)
?
[]
:
[
'file'
=>
$r
->
getFileName
(),
'line'
=>
$r
->
getStartLine
(),
];
$this
->
classInfo
[
$class
]
=
[
$i
,
$parents
,
$hasDebugInfo
,
$fileInfo
];
}
$stub
->
attr
+=
$fileInfo
;
$a
=
Caster
::
castObject
(
$obj
,
$class
,
$hasDebugInfo
,
$stub
->
class
);
try
{
while
(
$i
--)
{
if
(!
empty
(
$this
->
casters
[
$p
=
$parents
[
$i
]]))
{
foreach
(
$this
->
casters
[
$p
]
as
$callback
)
{
$a
=
$callback
(
$obj
,
$a
,
$stub
,
$isNested
,
$this
->
filter
);
}
}
}
}
catch
(
\Exception
$e
)
{
$a
=
[(
Stub
::
TYPE_OBJECT
===
$stub
->
type
?
Caster
::
PREFIX_VIRTUAL
:
''
).
'⚠'
=>
new
ThrowingCasterException
(
$e
)]
+
$a
;
}
return
$a
;
}
/**
* Casts a resource to an array representation.
*
* @param bool $isNested True if the object is nested in the dumped structure
*/
protected
function
castResource
(
Stub
$stub
,
bool
$isNested
):
array
{
$a
=
[];
$res
=
$stub
->
value
;
$type
=
$stub
->
class
;
try
{
if
(!
empty
(
$this
->
casters
[
':'
.
$type
]))
{
foreach
(
$this
->
casters
[
':'
.
$type
]
as
$callback
)
{
$a
=
$callback
(
$res
,
$a
,
$stub
,
$isNested
,
$this
->
filter
);
}
}
}
catch
(
\Exception
$e
)
{
$a
=
[(
Stub
::
TYPE_OBJECT
===
$stub
->
type
?
Caster
::
PREFIX_VIRTUAL
:
''
).
'⚠'
=>
new
ThrowingCasterException
(
$e
)]
+
$a
;
}
return
$a
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 20:52 (1 d, 12 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e4/f9/21991292639b3ac94b894372d0c2
Default Alt Text
AbstractCloner.php (22 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment