Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5986260
Dumper.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
Dumper.php
View Options
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2023 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Psy\VarDumper
;
use
Symfony\Component\Console\Formatter\OutputFormatter
;
use
Symfony\Component\VarDumper\Cloner\Cursor
;
use
Symfony\Component\VarDumper\Dumper\CliDumper
;
/**
* A PsySH-specialized CliDumper.
*/
class
Dumper
extends
CliDumper
{
private
OutputFormatter
$formatter
;
private
bool
$forceArrayIndexes
;
private
const
ONLY_CONTROL_CHARS
=
'/^[
\x
00-
\x
1F
\x
7F]+$/'
;
private
const
CONTROL_CHARS
=
'/([
\x
00-
\x
1F
\x
7F]+)/'
;
private
const
CONTROL_CHARS_MAP
=
[
"
\0
"
=>
'
\0
'
,
"
\t
"
=>
'
\t
'
,
"
\n
"
=>
'
\n
'
,
"
\v
"
=>
'
\v
'
,
"
\f
"
=>
'
\f
'
,
"
\r
"
=>
'
\r
'
,
"
\0
33"
=>
'
\e
'
,
];
public
function
__construct
(
OutputFormatter
$formatter
,
$forceArrayIndexes
=
false
)
{
$this
->
formatter
=
$formatter
;
$this
->
forceArrayIndexes
=
$forceArrayIndexes
;
parent
::
__construct
();
$this
->
setColors
(
false
);
}
/**
* {@inheritdoc}
*/
public
function
enterHash
(
Cursor
$cursor
,
$type
,
$class
,
$hasChild
):
void
{
if
(
Cursor
::
HASH_INDEXED
===
$type
||
Cursor
::
HASH_ASSOC
===
$type
)
{
$class
=
0
;
}
parent
::
enterHash
(
$cursor
,
$type
,
$class
,
$hasChild
);
}
/**
* {@inheritdoc}
*/
protected
function
dumpKey
(
Cursor
$cursor
):
void
{
if
(
$this
->
forceArrayIndexes
||
Cursor
::
HASH_INDEXED
!==
$cursor
->
hashType
)
{
parent
::
dumpKey
(
$cursor
);
}
}
protected
function
style
(
$style
,
$value
,
$attr
=
[]):
string
{
if
(
'ref'
===
$style
)
{
$value
=
\strtr
(
$value
,
'@'
,
'#'
);
}
$styled
=
''
;
$cchr
=
$this
->
styles
[
'cchr'
];
$chunks
=
\preg_split
(
self
::
CONTROL_CHARS
,
$value
,
-
1
,
\PREG_SPLIT_NO_EMPTY
|
\PREG_SPLIT_DELIM_CAPTURE
);
foreach
(
$chunks
as
$chunk
)
{
if
(
\preg_match
(
self
::
ONLY_CONTROL_CHARS
,
$chunk
))
{
$chars
=
''
;
$i
=
0
;
do
{
$chars
.=
isset
(
self
::
CONTROL_CHARS_MAP
[
$chunk
[
$i
]])
?
self
::
CONTROL_CHARS_MAP
[
$chunk
[
$i
]]
:
\sprintf
(
'
\x
%02X'
,
\ord
(
$chunk
[
$i
]));
}
while
(
isset
(
$chunk
[++
$i
]));
$chars
=
$this
->
formatter
->
escape
(
$chars
);
$styled
.=
"<{$cchr}>{$chars}</{$cchr}>"
;
}
else
{
$styled
.=
$this
->
formatter
->
escape
(
$chunk
);
}
}
$style
=
$this
->
styles
[
$style
];
return
"<{$style}>{$styled}</{$style}>"
;
}
/**
* {@inheritdoc}
*/
protected
function
dumpLine
(
$depth
,
$endOfValue
=
false
):
void
{
if
(
$endOfValue
&&
0
<
$depth
)
{
$this
->
line
.=
','
;
}
$this
->
line
=
$this
->
formatter
->
format
(
$this
->
line
);
parent
::
dumpLine
(
$depth
,
$endOfValue
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Oct 4, 00:03 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a4/80/30e6fa27fa1f4a380d0154044ec3
Default Alt Text
Dumper.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment