We are looking for strong, experienced Senior PHP Developer/Symfony. We expect him/her to participate in improving and extending a system built using microservice architecture by means of modern technologies.

A cloner is used to create an intermediate representation of any PHP variable.
Its output is a Data
object that wraps this representation.

You can create a Data object this way:

1
2
3
4
5
6
7

useSymfony\Component\VarDumper\Cloner\VarCloner;$cloner=newVarCloner();$data=$cloner->cloneVar($myVar);// this is commonly then passed to the dumper// see the example at the top of this page// $dumper->dump($data);

configures the maximum number of items that will be cloned
past the first nesting level. Items are counted using a breadth-first
algorithm so that lower level items have higher priority than deeply nested
items;

By using the first argument of the constructor, you can select the output
stream where the dump will be written. By default, the CliDumper writes
on php://stdout and the HtmlDumper on php://output. But any PHP
stream (resource or URL) is acceptable.

Instead of a stream destination, you can also pass it a callable that
will be called repeatedly for each line generated by a dumper. This
callable can be configured using the first argument of a dumper's constructor,
but also using the
setOutput()
method or the second argument of the
dump() method.

For example, to get a dump as a string in a variable, you can do:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

useSymfony\Component\VarDumper\Cloner\VarCloner;useSymfony\Component\VarDumper\Dumper\CliDumper;$cloner=newVarCloner();$dumper=newCliDumper();$output='';$dumper->dump($cloner->cloneVar($variable),function($line,$depth)use(&$output){// A negative depth means "end of dump"if($depth>=0){// Adds a two spaces indentation to the line$output.=str_repeat(' ',$depth).$line."\n";}});// $output is now populated with the dump representation of $variable

Another option for doing the same could be:

1
2
3
4
5
6
7
8
9
10
11

useSymfony\Component\VarDumper\Cloner\VarCloner;useSymfony\Component\VarDumper\Dumper\CliDumper;$cloner=newVarCloner();$dumper=newCliDumper();$output=fopen('php://memory','r+b');$dumper->dump($cloner->cloneVar($variable),$output);$output=stream_get_contents($output,-1,0);// $output is now populated with the dump representation of $variable

Tip

You can pass true to the second argument of the
dump()
method to make it return the dump as a string:

1

$output=$dumper->dump($cloner->cloneVar($variable),true);

New in version 3.2: The ability to return a string was introduced in Symfony 3.2.

The HtmlDumper limits string
length and nesting depth of the output to make it more readable. These options
can be overriden by the third optional parameter of the
dump(Data $data)
method:

1
2
3
4
5
6
7
8
9
10

useSymfony\Component\VarDumper\Dumper\HtmlDumper;$output=fopen('php://memory','r+b');$dumper=newHtmlDumper();$dumper->dump($var,$output,array(// 1 and 160 are the default values for these options'maxDepth'=>1,'maxStringLength'=>160));

New in version 3.2: Support for passing display options to the dump() method was introduced
in Symfony 3.2.

The output format of a dumper can be fine tuned by the two flags
DUMP_STRING_LENGTH and DUMP_LIGHT_ARRAY which are passed as a bitmap
in the third constructor argument. They can also be set via environment
variables when using
assertDumpEquals($dump, $data, $message)
during unit testing.

New in version 3.1: The DUMP_STRING_LENGTH and DUMP_LIGHT_ARRAY flags were introduced
in Symfony 3.1.

If DUMP_STRING_LENGTH is set, then the length of a string is displayed
next to its content:

Objects and resources nested in a PHP variable are "cast" to arrays in the
intermediate Data
representation. You can customize the array representation for each object/resource
by hooking a Caster into this process. The component already includes many
casters for base PHP classes and other common classes.

If you want to build your own Caster, you can register one before cloning
a PHP variable. Casters are registered using either a Cloner's constructor
or its addCasters() method:

As you can notice, resource types are prefixed by a : to prevent
colliding with a class name.

Because an object has one main class and potentially many parent classes
or interfaces, many casters can be applied to one object. In this case,
casters are called one after the other, starting from casters bound to the
interfaces, the parents classes and then the main class. Several casters
can also be registered for the same resource type/class/interface.
They are called in registration order.

Casters are responsible for returning the properties of the object or resource
being cloned in an array. They are callables that accept five arguments:

For objects, the $array parameter comes pre-populated using PHP's native
(array) casting operator or with the return value of $object->__debugInfo()
if the magic method exists. Then, the return value of one Caster is given
as the array argument to the next Caster in the chain.

When casting with the (array) operator, PHP prefixes protected properties
with a \0*\0 and private ones with the class owning the property. For example,
\0Foobar\0 will be the prefix for all private properties of objects of
type Foobar. Casters follow this convention and add two more prefixes: \0~\0
is used for virtual properties and \0+\0 for dynamic ones (runtime added
properties not in the class declaration).

Note

Although you can, it is advised to not alter the state of an object
while casting it in a Caster.

New in version 3.2: As of Symfony 3.2, casters can attach metadata attributes to
Stub objects to inform
dumpers about the precise type of the dumped values.

Since casters are hooked on specific classes or interfaces, they know about the
objects they manipulate. By altering the $stub object (the third argument of
any caster), one can transfer this knowledge to the resulting Data object,
thus to dumpers. To help you do this (see the source code for how it works),
the component comes with a set of wrappers for common additional semantics. You
can use: